#![allow(clippy::unwrap_used)]
#![allow(clippy::expect_used)]
use crate::Config;
#[test]
fn test_IR_EXPR_032_format_concat_via_println() {
let out = transpile_full(
r#"
fn main() {
let name = "World";
println!("Hello {}", name);
}
"#,
);
assert!(
out.contains("echo") || out.contains("printf"),
"Expected echo or printf for println! in:\n{out}"
);
assert!(
out.contains("Hello") || out.contains("hello"),
"Expected Hello in output:\n{out}"
);
}
#[test]
fn test_IR_EXPR_033_nested_arithmetic() {
let out = transpile_full("fn main() { let a = 1; let b = 2; let c = 3; let x = (a + b) * c; }");
assert!(
out.contains("$(("),
"Expected arithmetic expansion in:\n{out}"
);
}
#[test]
fn test_IR_EXPR_034_multiple_binary_ops() {
let out = transpile_full(
r#"
fn main() {
let x = 10;
let y = 5;
let a = x + y;
let p = 20;
let q = 3;
let b = p - q;
let c = a * b;
}
"#,
);
assert!(
out.contains("$(("),
"Expected arithmetic expansion in:\n{out}"
);
}
#[test]
fn test_IR_EXPR_035_exec_effects_curl() {
let out = transpile_main(r#"exec("curl http://example.com");"#);
assert!(out.contains("eval"), "Expected eval for exec() in:\n{out}");
}
#[test]
fn test_IR_EXPR_036_method_call_expr() {
let result = crate::transpile(
r#"
fn main() {
let s = "hello";
let t = s.len();
}
"#,
&Config::default(),
);
assert!(
result.is_ok(),
"Method call should not cause transpile failure"
);
}
#[test]
fn test_IR_EXPR_037_div_by_zero_literal() {
let result = crate::transpile(
"fn main() { let a = 10; let b = 0; let x = a / b; }",
&Config::default(),
);
assert!(result.is_ok(), "Division by zero should still transpile");
}
#[test]
fn test_IR_EXPR_038_chained_shift() {
let out = transpile_full(
"fn main() { let a = 1; let b = 2; let c = 3; let x = a << b; let y = x << c; }",
);
assert!(out.contains("<<"), "Expected << operator in:\n{out}");
}
#[test]
fn test_IR_EXPR_039_comparison_in_while() {
let out = transpile_full(
r#"
fn main() {
let mut i = 0;
while i < 10 {
i = i + 1;
}
}
"#,
);
assert!(out.contains("while"), "Expected while in:\n{out}");
assert!(
out.contains("-lt"),
"Expected -lt in while condition:\n{out}"
);
}
#[test]
fn test_IR_EXPR_040_literal_bool_false() {
let out = transpile_main("let flag = false;");
assert!(
out.contains("0") || out.contains("false"),
"Expected boolean false representation in:\n{out}"
);
}