1 //! Arbitrarily choose a spec test from the list of known spec tests.
2 
3 use arbitrary::{Arbitrary, Unstructured};
4 
5 // See `build.rs` for how the `FILES` array is generated.
6 include!(concat!(env!("OUT_DIR"), "/wasttests.rs"));
7 
8 /// A wast test from this repository.
9 #[derive(Debug)]
10 pub struct WastTest {
11     #[expect(missing_docs, reason = "self-describing field")]
12     pub test: wasmtime_test_util::wast::WastTest,
13 }
14 
15 impl<'a> Arbitrary<'a> for WastTest {
arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self>16     fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
17         log::debug!("{}", u.is_empty());
18         Ok(WastTest {
19             test: u.choose(FILES)?(),
20         })
21     }
22 
size_hint(_depth: usize) -> (usize, Option<usize>)23     fn size_hint(_depth: usize) -> (usize, Option<usize>) {
24         (1, Some(std::mem::size_of::<usize>()))
25     }
26 }
27