use super::*;
use crate::instruction::OpCode;
#[test]
fn untranslated_opcode_inline_comment_survives_clean_mode() {
let script = [0xFFu8, OpCode::Ret.byte()]; let nef_bytes = build_nef(&script);
let decompilation = Decompiler::with_unknown_handling(UnknownHandling::Permit)
.with_trace_comments(false)
.decompile_bytes(&nef_bytes)
.expect("decompile in clean mode");
let high_level = decompilation
.high_level
.as_deref()
.expect("high-level output");
assert!(
high_level.contains("UNKNOWN_0xFF (not yet translated)"),
"clean-mode high-level should still surface the inline untranslated marker:\n{high_level}"
);
assert!(
decompilation
.warnings
.iter()
.any(|w| w.contains("UNKNOWN_0xFF (not yet translated)")),
"structured warning channel should also surface the untranslated marker:\n{:?}",
decompilation.warnings,
);
}
#[test]
fn tolerant_mode_emits_unknown_opcode() {
let script = [0xFFu8, OpCode::Ret.byte()]; let nef_bytes = build_nef(&script);
let decompilation = Decompiler::with_unknown_handling(UnknownHandling::Permit)
.decompile_bytes(&nef_bytes)
.expect("decompile in tolerant mode");
assert!(
decompilation
.pseudocode
.as_deref()
.expect("pseudocode output")
.contains("0000: UNKNOWN_0xFF"),
"pseudocode should include unknown opcode"
);
assert!(
decompilation
.high_level
.as_deref()
.expect("high-level output")
.contains("UNKNOWN_0xFF (not yet translated)"),
"high-level output should note unknown opcode"
);
}