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