1 #![cfg(arc_try_new)]
2
3 use wasmtime::{
4 Config, Engine, FuncType, GlobalType, MemoryType, Mutability, RefType, Result, TableType,
5 ValType,
6 };
7 use wasmtime_fuzzing::oom::OomTest;
8
9 #[test]
func_type_params_results() -> Result<()>10 fn func_type_params_results() -> Result<()> {
11 OomTest::new().test(|| {
12 let mut config = Config::new();
13 config.enable_compiler(false);
14 let engine = Engine::new(&config)?;
15 let ty = FuncType::try_new(&engine, [ValType::I32, ValType::I64], [ValType::F32])?;
16 assert_eq!(ty.params().len(), 2);
17 assert_eq!(ty.results().len(), 1);
18 Ok(())
19 })
20 }
21
22 #[test]
table_type_accessors() -> Result<()>23 fn table_type_accessors() -> Result<()> {
24 OomTest::new().test(|| {
25 let ty = TableType::new(RefType::FUNCREF, 1, Some(10));
26 assert_eq!(ty.minimum(), 1);
27 assert_eq!(ty.maximum(), Some(10));
28 Ok(())
29 })
30 }
31
32 #[test]
memory_type_accessors() -> Result<()>33 fn memory_type_accessors() -> Result<()> {
34 OomTest::new().test(|| {
35 let ty = MemoryType::new(1, Some(10));
36 assert_eq!(ty.minimum(), 1);
37 assert_eq!(ty.maximum(), Some(10));
38 assert!(!ty.is_64());
39 assert!(!ty.is_shared());
40 Ok(())
41 })
42 }
43
44 #[test]
global_type_accessors() -> Result<()>45 fn global_type_accessors() -> Result<()> {
46 OomTest::new().test(|| {
47 let ty = GlobalType::new(ValType::I32, Mutability::Var);
48 assert!(ty.content().is_i32());
49 assert_eq!(ty.mutability(), Mutability::Var);
50 Ok(())
51 })
52 }
53
54 // Note: ExnType::new, StructType::new, and ArrayType::new are not tested under
55 // OOM yet because their construction goes through the type registry and GC
56 // layout computation which has additional .panic_on_oom() calls deep in
57 // crates/environ/src/gc.rs that need to be addressed first.
58