Browse Source

test 'if' too

master
Martin Dørum 7 months ago
parent
commit
c3c562ea63
2 changed files with 17 additions and 2 deletions
  1. 10
    2
      test/examples/control-flow.l2
  2. 7
    0
      test/examples/control-flow.l2.expected

+ 10
- 2
test/examples/control-flow.l2 View File

@@ -1,4 +1,12 @@
print "Run loop 10 times"
print "If"
if 'true {print "true is true"} {print "true is not true"}
if 'false {print "false is true"} {print "false is not true"}
if 'true {print "true is true"}
if 'false {print "false is true"} # This should output nothing
print (if 'true {"If returns it true value"})
print (if 'false {0} {"If returns its false value"})

print "\nRun loop 10 times"
i := 0
loop {
print "Hello World"
@@ -20,7 +28,7 @@ iter := {
i = i + 1
if j < 10 {j} {'stop}
}
for iter { print "Hello with" $ }
for iter {print "Hello with" $}

print "\nArray iterator"
array-iter := {

+ 7
- 0
test/examples/control-flow.l2.expected View File

@@ -1,3 +1,10 @@
If
true is true
false is not true
true is true
If returns it true value
If returns its false value

Run loop 10 times
Hello World
Hello World

Loading…
Cancel
Save