Fix while, add to test.lua
This commit is contained in:
parent
50e826061b
commit
11f4e4e8a3
@ -1,3 +1,72 @@
|
||||
global b = 5
|
||||
|
||||
function add(x)
|
||||
return function (y)
|
||||
x = x + 1
|
||||
b = b + 1
|
||||
return x + y, 1, 2, b
|
||||
end
|
||||
end
|
||||
|
||||
function min(x, y)
|
||||
local m = x
|
||||
if y < x then
|
||||
m = y
|
||||
end
|
||||
return m
|
||||
end
|
||||
|
||||
|
||||
function f(x, ...)
|
||||
local b = {10, ..., add(10)(15)}
|
||||
return x + 5, b
|
||||
end
|
||||
|
||||
global sometable = {}
|
||||
sometable["hello"] = { 100, 150, add(10)(15) }
|
||||
print(#sometable["hello"])
|
||||
sometable["hello"].there = "my dude"
|
||||
print(sometable.hello.there)
|
||||
|
||||
print(max(11.12345, 9))
|
||||
print(add(10)(15))
|
||||
print(add(10)(15))
|
||||
print(b)
|
||||
print(min(11, 9))
|
||||
print(10 - 15)
|
||||
print("hello there!")
|
||||
print(true or 0)
|
||||
|
||||
global value, table = f(10, 11, 12)
|
||||
|
||||
print("hello")
|
||||
for i=1,#table do
|
||||
print(table[i])
|
||||
if i > 2 then
|
||||
goto test
|
||||
end
|
||||
end
|
||||
::test::
|
||||
|
||||
local test = table[1]
|
||||
if test == 10 then
|
||||
print("first")
|
||||
elseif test == 11 then
|
||||
print("second")
|
||||
else
|
||||
print("third")
|
||||
end
|
||||
print("after if/elseif/else")
|
||||
|
||||
|
||||
local i = 0
|
||||
print("before")
|
||||
while i < 10 do
|
||||
i = i + 1
|
||||
print(i)
|
||||
end
|
||||
print("after while")
|
||||
|
||||
|
||||
local i = 0
|
||||
print("before")
|
||||
@ -5,4 +74,4 @@ repeat
|
||||
i = i + 1
|
||||
print(i)
|
||||
until i >= 10
|
||||
print("after")
|
||||
print("after repeat")
|
||||
@ -500,7 +500,7 @@ impl Statement {
|
||||
instructions.extend(block_instructions);
|
||||
|
||||
instructions.push(PreInstr::Instr(Instruction::Jmp(
|
||||
-(block_instr_len + expr_instr_len + 2),
|
||||
-(block_instr_len + expr_instr_len + 3),
|
||||
)));
|
||||
}
|
||||
Statement::Repeat(block, expr) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user