aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/with.moon
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/with.moon')
-rw-r--r--spec/inputs/with.moon118
1 files changed, 118 insertions, 0 deletions
diff --git a/spec/inputs/with.moon b/spec/inputs/with.moon
new file mode 100644
index 0000000..ae3c8c0
--- /dev/null
+++ b/spec/inputs/with.moon
@@ -0,0 +1,118 @@
1
2do
3 a = ->
4 with something
5 print .hello
6 print hi
7 print "world"
8
9do
10 with leaf
11 .world!
12 .world 1,2,3
13
14 g = .what.is.this
15
16 .hi 1,2,3
17
18 \hi(1,2).world 2323
19
20 \hi "yeah", "man"
21 .world = 200
22
23do
24 zyzyzy = with something
25 .set_state "hello world"
26
27do
28 x = 5 + with Something!
29 \write "hello world"
30
31
32do
33 x = {
34 hello: with yeah
35 \okay!
36 }
37
38do
39 with foo
40 \prop"something".hello
41 .prop\send(one)
42 .prop\send one
43
44
45--
46
47do
48 with a, b -- b is lost
49 print .world
50
51 mod = with _M = {}
52 .Thing = "hi"
53
54 -- operate on a only
55 with a, b = something, pooh
56 print .world
57
58 x = with a, b = 1, 2
59 print a + b
60
61 print with a, b = 1, 2
62 print a + b
63
64 -- assignment lhs must be evaluated in the order they appear
65 p = with hello!.x, world!.y = 1, 2
66 print a + b
67
68--
69
70do
71 x = "hello"
72 with x
73 x\upper!
74
75do
76 with k = "jo"
77 print \upper!
78
79do
80 with a,b,c = "", "", ""
81 print \upper!
82
83do
84 a = "bunk"
85 with a,b,c = "", "", ""
86 print \upper!
87
88do
89 with j
90 print \upper!
91
92do
93 with k.j = "jo"
94 print \upper!
95
96do
97 with a
98 print .b
99 -- nested `with`s should change the scope correctly
100 with .c
101 print .d
102
103do
104 with a
105 -- nested `with`s with assignments should change the scope correctly
106 with .b = 2
107 print .c
108
109do
110 ->
111 with hi
112 return .a, .b
113
114
115do
116 with dad
117 .if "yes"
118 y = .end.of.function