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

Function roundtrip

pulley/fuzz/src/roundtrip.rs:6–28  ·  view source on GitHub ↗
(ops: Vec<Op>)

Source from the content-addressed store, hash-verified

4};
5
6pub fn roundtrip(ops: Vec<Op>) {
7 let _ = env_logger::try_init();
8
9 log::trace!("input: {ops:#?}");
10
11 let mut encoded = vec![];
12 for op in &ops {
13 let before = encoded.len();
14 op.encode(&mut encoded);
15 let size = encoded.len() - before;
16 assert_eq!(size, op.width().into());
17 }
18 log::trace!("encoded: {encoded:?}");
19
20 let mut materializer = MaterializeOpsVisitor::new(SafeBytecodeStream::new(&encoded));
21 let decoded = Decoder::decode_all(&mut materializer).expect("should decode okay");
22 log::trace!("decoded: {decoded:#?}");
23
24 assert_eq!(
25 decoded, ops,
26 "`decode(encode(ops))` should be equal to the original `ops`"
27 );
28}

Callers 2

pulley_roundtripFunction · 0.50
assembler_roundtripFunction · 0.50

Calls 4

newFunction · 0.50
lenMethod · 0.45
encodeMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected