1
0

Write tests

This commit is contained in:
Jeff 2024-01-30 00:24:13 -05:00
parent 8a5efa054b
commit ce0ca17beb

View File

@ -26,3 +26,48 @@ fn modify_value() {
result result
); );
} }
#[test]
fn modify_iteration_values() {
let result = interpret(
"
list = [1 2 3]
for i in list { i += i }
list
",
);
assert_eq!(
Ok(Value::List(List::with_items(vec![
Value::Integer(2),
Value::Integer(3),
Value::Integer(4),
]))),
result
);
}
#[test]
fn r#break() {
let result = interpret(
"
list = []
for i in [1 2 3] {
if i > 2 {
break
} else {
list += i
}
}
list
",
);
assert_eq!(
Ok(Value::List(List::with_items(vec![
Value::Integer(1),
Value::Integer(2),
]))),
result
);
}