neo-decompiler 0.10.2

Neo N3 NEF decompiler: parse, disassemble, lift bytecode to high-level pseudocode and C# skeletons, with a CLI, JSON reports, and optional WebAssembly bindings.
Documentation
use super::super::*;

#[test]
fn reduce_double_parens_collapses_nested_pairs() {
    // The single-use-temp inliner unconditionally wraps multi-token
    // substitutions in parens. When the substitution lands inside a
    // call argument (or any already-parenthesised context), we end up
    // with `assert((x > 0))` and similar double parens. The pass
    // strips one redundant pair while preserving the operator's
    // precedence-safe outer parens.
    let mut statements = vec![
        "assert((x > 0));".to_string(),
        "let y = ((a + b));".to_string(),
        "if (((cond))) {".to_string(),
        "foo((x), (y));".to_string(), // these parens are NOT redundant
    ];

    HighLevelEmitter::reduce_double_parens(&mut statements);

    assert_eq!(statements[0], "assert(x > 0);");
    assert_eq!(statements[1], "let y = (a + b);");
    assert_eq!(statements[2], "if (cond) {");
    assert_eq!(
        statements[3], "foo((x), (y));",
        "function-call argument parens around different operands must not collapse"
    );
}