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

Function sanity

cranelift/interpreter/src/interpreter.rs:574–594  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

572 // filetest infrastructure.
573 #[test]
574 fn sanity() {
575 let code = "function %test() -> i8 {
576 block0:
577 v0 = iconst.i32 1
578 v5 = iconst.i32 1
579 v1 = iadd v0, v5
580 v6 = iconst.i32 44
581 v2 = isub v6, v1 ; 44 - 2 == 42
582 v4 = iconst.i32 42
583 v3 = icmp eq v2, v4
584 return v3
585 }";
586
587 let func = parse_functions(code).unwrap().into_iter().next().unwrap();
588 let mut env = FunctionStore::default();
589 env.add(func.name.to_string(), &func);
590 let state = InterpreterState::default().with_function_store(env);
591 let result = Interpreter::new(state).call_by_name("%test", &[]).unwrap();
592
593 assert_eq!(result, ControlFlow::Return(smallvec![DataValue::I8(1)]));
594 }
595
596 // We don't have a way to check for traps with the current filetest infrastructure
597 #[test]

Callers

nothing calls this directly

Calls 9

parse_functionsFunction · 0.85
with_function_storeMethod · 0.80
call_by_nameMethod · 0.80
newFunction · 0.50
unwrapMethod · 0.45
nextMethod · 0.45
into_iterMethod · 0.45
addMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected