This commit is contained in:
nora 2022-01-04 21:35:45 +01:00
parent a4dfbb5cd3
commit 48f2bee7f0
8 changed files with 85 additions and 16 deletions

View file

@ -78,3 +78,45 @@ if string == "no" {
}
"#
);
run_test!(
while_single_loop,
r#"
let x = true;
while x {
x = false;
print "iter";
}
print "done";
"#
);
run_test!(
while_count_to_100,
r#"
let i = 0;
while i < 100 {
print i;
i = i + 1;
}
print "done";
"#
);
run_test!(
while_run_never,
r#"
let not_run = true;
while false {
print "WRONG";
not_run = false;
}
if not_run {
print "good.";
}
"#
);

View file

@ -0,0 +1,7 @@
---
source: tests/control_flow.rs
assertion_line: 94
expression: output
---
"0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\ndone\n"

View file

@ -0,0 +1,7 @@
---
source: tests/control_flow.rs
assertion_line: 108
expression: output
---
"good.\n"

View file

@ -0,0 +1,7 @@
---
source: tests/control_flow.rs
assertion_line: 82
expression: output
---
"iter\ndone\n"