Skip to content

Commit 0d1f25c

Browse files
committed
tests for do
1 parent c783eff commit 0d1f25c

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

tests/inputs/do.moon

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
do
3+
print "hello"
4+
print "world"
5+
6+
x = do
7+
print "hello"
8+
print "world"
9+
10+
y = do
11+
things = "shhh"
12+
-> "hello: " .. things
13+
14+
-> if something then do "yeah"
15+
16+
t = {
17+
y: do
18+
number = 100
19+
(x) -> x + number
20+
}
21+
22+
(y=(do
23+
x = 10 + 2
24+
x), k=do
25+
"nothing") -> do
26+
"uhhh"
27+

tests/outputs/do.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
do
2+
print("hello")
3+
print("world")
4+
end
5+
local x
6+
do
7+
print("hello")
8+
x = print("world")
9+
end
10+
local y
11+
do
12+
local things = "shhh"
13+
y = function()
14+
return "hello: " .. things
15+
end
16+
end
17+
local _
18+
_ = function()
19+
if something then
20+
do
21+
return "yeah"
22+
end
23+
end
24+
end
25+
local t = {
26+
y = (function()
27+
local number = 100
28+
return function(x)
29+
return x + number
30+
end
31+
end)()
32+
}
33+
return function(y, k)
34+
if y == nil then
35+
y = ((function()
36+
x = 10 + 2
37+
return x
38+
end)())
39+
end
40+
if k == nil then
41+
do
42+
k = "nothing"
43+
end
44+
end
45+
do
46+
return "uhhh"
47+
end
48+
end

0 commit comments

Comments
 (0)