fix: lazy select_with_default

This commit is contained in:
2026-01-11 16:08:02 +08:00
parent 5b1750b1ba
commit 158784cbe8
6 changed files with 56 additions and 10 deletions

View File

@@ -99,3 +99,21 @@ fn logical_not() {
assert_eq!(eval("!true"), Value::Bool(false));
assert_eq!(eval("!false"), Value::Bool(true));
}
#[test]
fn select_with_default_lazy_evaluation() {
assert_eq!(eval("{ a = 1; }.a or (1 / 0)"), Value::Int(1));
}
#[test]
fn select_with_default_nested_lazy() {
assert_eq!(
eval("{ a.b = 42; }.a.b or (builtins.abort \"should not evaluate\")"),
Value::Int(42)
);
}
#[test]
fn select_with_default_fallback() {
assert_eq!(eval("{ a = 1; }.b or 999"), Value::Int(999));
}