While statements.
This commit is contained in:
@@ -28,3 +28,11 @@ io.write(c) // expect: good
|
||||
|
||||
// Assignment in if condition.
|
||||
if (a = true) io.write(a) // expect: true
|
||||
|
||||
// Newline after "if".
|
||||
if
|
||||
(true) io.write("good") // expect: good
|
||||
|
||||
// Newline after "else".
|
||||
if (false) io.write("bad") else
|
||||
io.write("good") // expect: good
|
||||
@@ -0,0 +1,31 @@
|
||||
// Single-expression body.
|
||||
var c = 0
|
||||
while (c < 3) io.write(c = c + 1)
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
|
||||
// Block body.
|
||||
var a = 0
|
||||
while (a < 3) {
|
||||
io.write(a)
|
||||
a = a + 1
|
||||
}
|
||||
// expect: 0
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
|
||||
// Newline after "while".
|
||||
var d = 0
|
||||
while
|
||||
(d < 3) io.write(d = d + 1)
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
|
||||
// Result is null.
|
||||
var e = 0
|
||||
var f = while (e < 3) {
|
||||
e = e + 1
|
||||
}
|
||||
io.write(f) // expect: null
|
||||
Reference in New Issue
Block a user