()
| 954 | |
| 955 | #[test] |
| 956 | fn libcall() { |
| 957 | let code = "function %test() -> i64 { |
| 958 | fn0 = colocated %CeilF32 (f32) -> f32 fast |
| 959 | block0: |
| 960 | v1 = f32const 0x0.5 |
| 961 | v2 = call fn0(v1) |
| 962 | return v2 |
| 963 | }"; |
| 964 | |
| 965 | let func = parse_functions(code).unwrap().into_iter().next().unwrap(); |
| 966 | let mut env = FunctionStore::default(); |
| 967 | env.add(func.name.to_string(), &func); |
| 968 | let state = InterpreterState::default() |
| 969 | .with_function_store(env) |
| 970 | .with_libcall_handler(|libcall, args| { |
| 971 | Ok(smallvec![match (libcall, &args[..]) { |
| 972 | (LibCall::CeilF32, [DataValue::F32(a)]) => DataValue::F32(a.ceil()), |
| 973 | _ => panic!("Unexpected args"), |
| 974 | }]) |
| 975 | }); |
| 976 | |
| 977 | let result = Interpreter::new(state).call_by_name("%test", &[]).unwrap(); |
| 978 | |
| 979 | assert_eq!( |
| 980 | result, |
| 981 | ControlFlow::Return(smallvec![DataValue::F32(Ieee32::with_float(1.0))]) |
| 982 | ) |
| 983 | } |
| 984 | |
| 985 | #[test] |
| 986 | fn misaligned_store_traps() { |
nothing calls this directly
no test coverage detected