File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1356,4 +1356,33 @@ mod tests {
13561356 Error :: InvalidMemoryOffsetOrSize
13571357 ) ;
13581358 }
1359+
1360+ #[ test]
1361+ fn execute_with_missing_import ( ) {
1362+ /* wat2wasm
1363+ (module
1364+ (func $adler32 (import "env" "adler32") (param i32 i32) (result i32))
1365+ (memory (export "memory") 1)
1366+ (data (i32.const 0) "abcd")
1367+ (func (export "test") (result i32)
1368+ i32.const 0
1369+ i32.const 4
1370+ call $adler32
1371+ )
1372+ )
1373+ */
1374+ let input = hex:: decode (
1375+ "0061736d01000000010b0260027f7f017f6000017f020f0103656e760761646c657233320000030201010503010001071102066d656d6f72790200047465737400010a0a0108004100410410000b0b0a010041000b0461626364" ) . unwrap ( ) ;
1376+
1377+ let module = parse ( & input) ;
1378+ assert ! ( module. is_ok( ) ) ;
1379+ let instance = module. unwrap ( ) . instantiate ( ) ;
1380+ assert ! ( instance. is_err( ) ) ;
1381+ assert_eq ! (
1382+ instance. err( ) . unwrap( ) ,
1383+ Error :: InstantiationFailed (
1384+ "module requires 1 imported functions, 0 provided" . to_string( )
1385+ )
1386+ ) ;
1387+ }
13591388}
You can’t perform that action at this time.
0 commit comments