Continue keyword

This commit is contained in:
2024-05-04 20:37:47 -05:00
parent cd53a21e8f
commit f19736cb8a
13 changed files with 147 additions and 23 deletions
+34
View File
@@ -159,6 +159,40 @@ fn peekpoke_test() {
)
}
#[test]
fn break_test() {
// Loop 0..10? Not quite!
assert_eq!(
main_return(
"fn main() {
var n = 0;
while(n < 10) {
n = n + 1;
if (n == 4) { break; }
}
return n;
}"),
4
)
}
#[test]
fn continue_test() {
// Loop 0..4, but skip 3
assert_eq!(
main_return(
"fn main() {
var n = 0;
repeat(5) i {
if (i == 3) { continue; }
n = n + i;
}
return n;
}"),
7
)
}
#[test]
fn static_test() {
// Because the static(1) returns the same address each time, a[0] is the same variable