use super::super::super::*;
#[test]
fn high_level_lifts_reverse3_operation() {
let script = [0x11, 0x12, 0x13, 0x53, 0x40];
let nef_bytes = build_nef(&script);
let decompilation = Decompiler::new()
.decompile_bytes(&nef_bytes)
.expect("decompile succeeds");
let high_level = decompilation
.high_level
.as_deref()
.expect("high-level output");
assert!(
high_level.contains("return 1;") || high_level.contains("return t0;"),
"REVERSE3 should expose PUSH1's value at the top via return: {high_level}",
);
}
#[test]
fn high_level_lifts_reverse4_operation() {
let script = [0x11, 0x12, 0x13, 0x14, 0x54, 0x40];
let nef_bytes = build_nef(&script);
let decompilation = Decompiler::new()
.decompile_bytes(&nef_bytes)
.expect("decompile succeeds");
let high_level = decompilation
.high_level
.as_deref()
.expect("high-level output");
assert!(
high_level.contains("return 1;") || high_level.contains("return t0;"),
"REVERSE4 should expose PUSH1's value at the top via return: {high_level}",
);
}
#[test]
fn high_level_lifts_reversen_operation() {
let script = [0x11, 0x12, 0x13, 0x13, 0x55, 0x40];
let nef_bytes = build_nef(&script);
let decompilation = Decompiler::new()
.decompile_bytes(&nef_bytes)
.expect("decompile succeeds");
let high_level = decompilation
.high_level
.as_deref()
.expect("high-level output");
assert!(
high_level.contains("return 1;") || high_level.contains("return t0;"),
"REVERSEN should expose PUSH1's value at the top via return: {high_level}",
);
}
#[test]
fn high_level_unpack_of_stored_packed_value_keeps_reverse3_stack_shape() {
let script = [
0x57, 0x01, 0x00, 0x11, 0x12, 0x12, 0xC0, 0x70, 0x13, 0x68, 0xC1, 0x45, 0x53, 0x40, ];
let nef_bytes = build_nef(&script);
let decompilation = Decompiler::new()
.decompile_bytes(&nef_bytes)
.expect("decompile succeeds");
let high_level = decompilation
.high_level
.as_deref()
.expect("high-level output");
assert!(
high_level.contains("pack 2 element"),
"script should include literal PACK shape used for UNPACK modeling: {high_level}"
);
assert!(
!high_level.contains("insufficient values on stack for REVERSE3"),
"UNPACK from stored PACK value should preserve enough stack entries for REVERSE3: {high_level}"
);
}