conditionals

This commit is contained in:
Chuck Smith
2024-02-07 15:46:45 -05:00
parent cff4375649
commit 77401260a2
5 changed files with 198 additions and 15 deletions

View File

@@ -142,3 +142,17 @@ func TestBooleanExpressions(t *testing.T) {
runVmTests(t, tests)
}
func TestConditionals(t *testing.T) {
tests := []vmTestCase{
{"if (true) { 10 }", 10},
{"if (true) { 10 } else { 20 }", 10},
{"if (false) { 10 } else { 20 } ", 20},
{"if (1) { 10 }", 10},
{"if (1 < 2) { 10 }", 10},
{"if (1 < 2) { 10 } else { 20 }", 10},
{"if (1 > 2) { 10 } else { 20 }", 20},
}
runVmTests(t, tests)
}