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

Function assert_one

pulley/tests/all/interp.rs:29–71  ·  view source on GitHub ↗
(
    xs: impl IntoIterator<Item = (R0, V)>,
    op: impl Into<Op> + Debug,
    result: R1,
    expected: u64,
)

Source from the content-addressed store, hash-verified

27}
28
29unsafe fn assert_one<R0, R1, V>(
30 xs: impl IntoIterator<Item = (R0, V)>,
31 op: impl Into<Op> + Debug,
32 result: R1,
33 expected: u64,
34) where
35 R0: Into<AnyReg>,
36 R1: Into<AnyReg>,
37 V: Into<Val>,
38{
39 eprintln!("=======================================================");
40 let mut vm = Vm::new().unwrap();
41
42 for (reg, val) in xs {
43 let reg = reg.into();
44 let val = val.into();
45 eprintln!("{reg} = {val:#018x}");
46 match (reg, val) {
47 (AnyReg::X(r), Val::XReg(v)) => vm.state_mut()[r] = v,
48 (AnyReg::F(r), Val::FReg(v)) => vm.state_mut()[r] = v,
49 (AnyReg::V(_), Val::VReg(_)) => todo!(),
50 (kind, val) => panic!("register kind and value mismatch: {kind:?} and {val:?}"),
51 }
52 }
53
54 eprintln!("op = {op:?}");
55 let op = op.into();
56
57 unsafe {
58 run(&mut vm, &[op, Op::Ret(Ret {})]).expect("should not trap");
59 }
60
61 eprintln!("expected = {expected:#018x}");
62
63 let actual = match result.into() {
64 AnyReg::X(r) => vm.state_mut()[r].get_u64(),
65 AnyReg::F(r) => vm.state_mut()[r].get_f64().to_bits(),
66 AnyReg::V(_) => todo!(),
67 };
68 eprintln!("actual = {actual:#018x}");
69
70 assert_eq!(expected, actual);
71}
72
73fn x(x: u8) -> XReg {
74 XReg::new(x).unwrap()

Callers 15

xconst8Function · 0.85
xconst16Function · 0.85
xconst32Function · 0.85
xconst64Function · 0.85
xadd32Function · 0.85
xadd64Function · 0.85
xeq64Function · 0.85
xneq64Function · 0.85
xslt64Function · 0.85
xslteq64Function · 0.85
xult64Function · 0.85
xulteq64Function · 0.85

Calls 8

state_mutMethod · 0.80
runFunction · 0.70
newFunction · 0.50
unwrapMethod · 0.45
expectMethod · 0.45
get_u64Method · 0.45
to_bitsMethod · 0.45
get_f64Method · 0.45

Tested by

no test coverage detected