MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / trap_with_array_to_wasm_stack_args

Function trap_with_array_to_wasm_stack_args

tests/all/traps.rs:1386–1436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1384
1385#[test]
1386fn trap_with_array_to_wasm_stack_args() -> Result<()> {
1387 let engine = Engine::default();
1388 let mut store = Store::new(&engine, ());
1389 let module = Module::new(
1390 &engine,
1391 r#"
1392 (module
1393 (func $trap
1394 unreachable)
1395 (func $run (param i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64)
1396 call $trap)
1397 (export "run" (func $run))
1398 )
1399 "#,
1400 )?;
1401
1402 let instance = Instance::new(&mut store, &module, &[])?;
1403 let run = instance.get_func(&mut store, "run").unwrap();
1404
1405 let err = run
1406 .call(
1407 &mut store,
1408 &[
1409 Val::I64(0),
1410 Val::I64(0),
1411 Val::I64(0),
1412 Val::I64(0),
1413 Val::I64(0),
1414 Val::I64(0),
1415 Val::I64(0),
1416 Val::I64(0),
1417 Val::I64(0),
1418 Val::I64(0),
1419 Val::I64(0),
1420 Val::I64(0),
1421 Val::I64(0),
1422 Val::I64(0),
1423 Val::I64(0),
1424 ],
1425 &mut [],
1426 )
1427 .unwrap_err();
1428 assert!(err.is::<Trap>());
1429
1430 let trace = err.downcast_ref::<WasmBacktrace>().unwrap();
1431 assert_eq!(trace.frames().len(), 2);
1432 assert_eq!(trace.frames()[0].func_name(), Some("trap"));
1433 assert_eq!(trace.frames()[1].func_name(), Some("run"));
1434
1435 Ok(())
1436}
1437
1438#[test]
1439fn trap_with_native_to_wasm_stack_args() -> Result<()> {

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
newFunction · 0.50
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected