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

Function mismatched_arguments

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

Source from the content-addressed store, hash-verified

511
512#[test]
513fn mismatched_arguments() -> Result<()> {
514 let mut store = Store::<()>::default();
515 let binary = wat::parse_str(
516 r#"
517 (module $a
518 (func (export "foo") (param i32))
519 )
520 "#,
521 )?;
522
523 let module = Module::new(store.engine(), &binary)?;
524 let instance = Instance::new(&mut store, &module, &[])?;
525 let func = instance.get_func(&mut store, "foo").unwrap();
526 assert_eq!(
527 func.call(&mut store, &[], &mut []).unwrap_err().to_string(),
528 "expected 1 arguments, got 0"
529 );
530 let e = func.call(&mut store, &[Val::F32(0)], &mut []).unwrap_err();
531 e.assert_contains("argument type mismatch");
532 e.assert_contains("expected i32, found f32");
533 assert_eq!(
534 func.call(&mut store, &[Val::I32(0), Val::I32(1)], &mut [])
535 .unwrap_err()
536 .to_string(),
537 "expected 1 arguments, got 2"
538 );
539 Ok(())
540}
541
542#[test]
543fn call_signature_mismatch() -> Result<()> {

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
assert_containsMethod · 0.80
newFunction · 0.50
engineMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected