roza/tests/acceptances/if.roza

113 lines
1.1 KiB
Plaintext

# SIMPLE IF
# =========
let count = 0
if true then
count = 1
end
if false then
count = 0
end
assert count == 1
# ELSE
# ====
count = 0
if true then
count = count + 1
else
end
if false then
else
count = count + 1
end
assert count == 2
# ELSE IF
# =======
count = 0
if true then
count = 1
else if true then
count = 0
else if true then
count = 0
else
count = 0
end
assert count == 1
count = 0
if false then
count = 0
else if true then
count = 1
else if true then
count = 0
else
count = 0
end
assert count == 1
count = 0
if false then
count = 0
else if false then
count = 0
else if true then
count = 1
else
count = 0
end
assert count == 1
count = 0
if false then
count = 0
else if false then
count = 0
else if false then
count = 0
else
count = 1
end
assert count == 1
# IF AS EXPR
# ==========
let a = if true then 5 else 6 end
let b = if false then 5 else 6 end
assert a == 5
assert b == 6
# IF BLOCKS
# =========
let c = 34
if true then
let c = 9
assert c == 9
end
assert c == 34
let d = "bim"
if false then
else
let d = "bam"
assert d == "bam"
end
assert d == "bim"