use super::harness::*;
#[test]
fn test_if_else_has_lexical_block_scope() {
let out = run_output(
r#"pipeline t(task) {
const x = "outer"
if true {
const x = "inner"
log(x)
} else {
const x = "other"
log(x)
}
log(x)
}"#,
);
assert_eq!(out, "[harn] inner\n[harn] outer");
}
#[test]
fn test_loop_and_catch_bindings_are_block_scoped() {
let out = run_output(
r#"pipeline t(task) {
const label = "outer"
for item in [1, 2] {
const label = "loop ${item}"
log(label)
}
try {
throw("boom")
} catch (label) {
log(label)
}
log(label)
}"#,
);
assert_eq!(
out,
"[harn] loop 1\n[harn] loop 2\n[harn] boom\n[harn] outer"
);
}