VenusParser/test.venus

129 lines
1.4 KiB
Plaintext

print("venus test")
local testt = {
venus = "awesome",
"lots of test",1,2,
test2 = "hi"
}
local a = 0
for i = 0,5 do
a = a + i
end
assert(a == 15)
for i,el in pairs(testt) do
print(i.." = "..el)
end
foreach el in testt do
print(el)
end
// comment
## comment
//comment
assert("//"=="/".."/")
-- comment
assert([[
##]]=="#".."#","comment within [[string]] falsely detected")
fn a()
return "function"
end
assert(a()=="function")
assert([[
fn]]=="f".."n")
do
(fn(...)
local a = {...}
foreach a in a do
print(a)
end
end)("a","still a","also a")
end
{
local a = 12
print(a)
}
a()
function t() {
return "hi"
}
assert(t()=="hi")
fn t2() {
return "also hi"
}
assert(t2()=="also hi")
if (true) {
print("weewoo")
}
for i = 0, 10 {
print(i)
}
foreach el in {"lot's of test",2,"3",1} {
print(el)
}
{
local i = 0
while i < 10 {
i = i + 1
if i%3 == 0 {
print(i)
} elseif i%4 == 0 {
print(i/4)
}
}
}
function callit(fun,t1,t2)
return fun(t1,t2)
end
assert(
callit(() => {
return "testing"
})
== "testing")
assert(
callit((k,v) => {
return k.." = "..v
}, "this test", "more test")
== "this test = more test"
)
assert(
callit((a , b) => {
return (a-b)*4
}, 10, 6) == 16
)
print("test end")
--[[ coming soon
local i = 0
local j = 0
i = i + 1
j = j + 2
i++
j += 2
function dec(n)
n--
return n-- not a decrement, only returns n, this is a comment
end
--]]