);
// indent due to opening braces
if line.split("//").collect::<Vec<&str>>().first().unwrap_or(&"").trim().ends_with('{') {
indentation += 1;
}
}
cleaned_lines
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_remove_double_negation() {
let line = "iszero(iszero(add(0x00, 0x01)))";
let cleaned = remove_double_negation(line);
assert_eq!(cleaned, "add(0x00, 0x01)");
}
#[test]
fn test_convert_bitmask_to_casting_address() {
let line = "and(0xffffffffffffffffffffffffffffffffffffffff, calldataload(0x04))";
let cleaned = convert_bitmask_to_casting(line);
assert_eq!(cleaned, "castToAddress(calldataload(0x04))");
}
#[test]
fn test_convert_bitmask_to_casting_bytes32() {
let line = "and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, calldataload(0x04))";
let cleaned = convert_bitmask_to_casting(line);
assert_eq!(cleaned, "bytes32(calldataload(0x04))");
}
#[test]
fn test_remove_replace_casts() {
let line = "bytes32(0x00)";
let cleaned = remove_replace_casts(line).expect("failed to remove replace casts");
assert_eq!(cleaned, "0x00");
}
// TODO : more coverage after i get core to compile lol
}
New Codebase TODO
: more coverage after i get core to compile lol
Location
https://github.com/Jon-Becker/heimdall-rs/blob/bc0137ba559e98ba58ca3352ed5bc2aa753b7154/core/src/decompile/out/postprocessers/yul.rs#L267