Add continue statement.
This commit is contained in:
@@ -12,8 +12,9 @@ fn test_loop() -> Result<(), EvalAltResult> {
|
||||
|
||||
loop {
|
||||
if i < 10 {
|
||||
i += 1;
|
||||
if x > 20 { continue; }
|
||||
x = x + i;
|
||||
i = i + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -22,7 +23,7 @@ fn test_loop() -> Result<(), EvalAltResult> {
|
||||
return x;
|
||||
"
|
||||
)?,
|
||||
45
|
||||
21
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
@@ -6,8 +6,18 @@ fn test_while() -> Result<(), EvalAltResult> {
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"let x = 0; while x < 10 { x = x + 1; if x > 5 { \
|
||||
break } } x",
|
||||
r"
|
||||
let x = 0;
|
||||
|
||||
while x < 10 {
|
||||
x = x + 1;
|
||||
if x > 5 { break; }
|
||||
if x > 3 { continue; }
|
||||
x = x + 3;
|
||||
}
|
||||
|
||||
x
|
||||
",
|
||||
)?,
|
||||
6
|
||||
);
|
||||
|
Reference in New Issue
Block a user