diff options
Diffstat (limited to 'spec/inputs/class.moon')
-rw-r--r-- | spec/inputs/class.moon | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/spec/inputs/class.moon b/spec/inputs/class.moon index 60361ca..83f3760 100644 --- a/spec/inputs/class.moon +++ b/spec/inputs/class.moon | |||
@@ -1,10 +1,10 @@ | |||
1 | 1 | ||
2 | class Hello | 2 | class Hello |
3 | new: (@test, @world) => | 3 | new: (@test, @world) => |
4 | print "creating object.." | 4 | print "creating object.." |
5 | hello: => | 5 | hello: => |
6 | print @test, @world | 6 | print @test, @world |
7 | __tostring: => "hello world" | 7 | __tostring: => "hello world" |
8 | 8 | ||
9 | x = Hello 1,2 | 9 | x = Hello 1,2 |
10 | x\hello() | 10 | x\hello() |
@@ -12,26 +12,26 @@ x\hello() | |||
12 | print x | 12 | print x |
13 | 13 | ||
14 | class Simple | 14 | class Simple |
15 | cool: => print "cool" | 15 | cool: => print "cool" |
16 | 16 | ||
17 | class Yikes extends Simple | 17 | class Yikes extends Simple |
18 | new: => print "created hello" | 18 | new: => print "created hello" |
19 | 19 | ||
20 | x = Yikes() | 20 | x = Yikes() |
21 | x\cool() | 21 | x\cool() |
22 | 22 | ||
23 | 23 | ||
24 | class Hi | 24 | class Hi |
25 | new: (arg) => | 25 | new: (arg) => |
26 | print "init arg", arg | 26 | print "init arg", arg |
27 | 27 | ||
28 | cool: (num) => | 28 | cool: (num) => |
29 | print "num", num | 29 | print "num", num |
30 | 30 | ||
31 | 31 | ||
32 | class Simple extends Hi | 32 | class Simple extends Hi |
33 | new: => super "man" | 33 | new: => super "man" |
34 | cool: => super 120302 | 34 | cool: => super 120302 |
35 | 35 | ||
36 | x = Simple() | 36 | x = Simple() |
37 | x\cool() | 37 | x\cool() |
@@ -40,45 +40,45 @@ print x.__class == Simple | |||
40 | 40 | ||
41 | 41 | ||
42 | class Okay | 42 | class Okay |
43 | -- what is going on | 43 | -- what is going on |
44 | something: 20323 | 44 | something: 20323 |
45 | -- yeaha | 45 | -- yeaha |
46 | 46 | ||
47 | 47 | ||
48 | class Biggie extends Okay | 48 | class Biggie extends Okay |
49 | something: => | 49 | something: => |
50 | super 1,2,3,4 | 50 | super 1,2,3,4 |
51 | super.something another_self, 1,2,3,4 | 51 | super.something another_self, 1,2,3,4 |
52 | assert super == Okay | 52 | assert super == Okay |
53 | 53 | ||
54 | 54 | ||
55 | class Yeah | 55 | class Yeah |
56 | okay: => | 56 | okay: => |
57 | super\something 1,2,3,4 | 57 | super\something 1,2,3,4 |
58 | 58 | ||
59 | 59 | ||
60 | class What | 60 | class What |
61 | something: => print "val:", @val | 61 | something: => print "val:", @val |
62 | 62 | ||
63 | class Hello extends What | 63 | class Hello extends What |
64 | val: 2323 | 64 | val: 2323 |
65 | something: => super\something | 65 | something: => super\something |
66 | 66 | ||
67 | with Hello! | 67 | with Hello! |
68 | x = \something! | 68 | x = \something! |
69 | print x | 69 | print x |
70 | x! | 70 | x! |
71 | 71 | ||
72 | class CoolSuper | 72 | class CoolSuper |
73 | hi: => | 73 | hi: => |
74 | super(1,2,3,4) 1,2,3,4 | 74 | super(1,2,3,4) 1,2,3,4 |
75 | super.something 1,2,3,4 | 75 | super.something 1,2,3,4 |
76 | _ = super.something(1,2,3,4).world | 76 | _ = super.something(1,2,3,4).world |
77 | super\yeah"world".okay hi, hi, hi | 77 | super\yeah"world".okay hi, hi, hi |
78 | _ = something.super | 78 | _ = something.super |
79 | _ = super.super.super.super | 79 | _ = super.super.super.super |
80 | _ = super\hello | 80 | _ = super\hello |
81 | nil | 81 | nil |
82 | 82 | ||
83 | 83 | ||
84 | -- selfing | 84 | -- selfing |
@@ -95,11 +95,11 @@ xx = (@hello, @@world, cool) -> | |||
95 | 95 | ||
96 | -- class properties | 96 | -- class properties |
97 | class ClassMan | 97 | class ClassMan |
98 | @yeah: 343 | 98 | @yeah: 343 |
99 | blue: => | 99 | blue: => |
100 | @hello: 3434, @world: 23423 | 100 | @hello: 3434, @world: 23423 |
101 | green: => | 101 | green: => |
102 | @red: => | 102 | @red: => |
103 | 103 | ||
104 | 104 | ||
105 | x = @ | 105 | x = @ |
@@ -118,34 +118,34 @@ _ = hello[@].world | |||
118 | 118 | ||
119 | 119 | ||
120 | class Whacko | 120 | class Whacko |
121 | _ = @hello | 121 | _ = @hello |
122 | if something | 122 | if something |
123 | print "hello world" | 123 | print "hello world" |
124 | 124 | ||
125 | hello = "world" | 125 | hello = "world" |
126 | @another = "day" | 126 | @another = "day" |
127 | 127 | ||
128 | print "yeah" if something -- this is briken | 128 | print "yeah" if something -- this is briken |
129 | 129 | ||
130 | 130 | ||
131 | print "hello" | 131 | print "hello" |
132 | 132 | ||
133 | yyy = -> | 133 | yyy = -> |
134 | class Cool | 134 | class Cool |
135 | _ = nil | 135 | _ = nil |
136 | 136 | ||
137 | 137 | ||
138 | -- | 138 | -- |
139 | 139 | ||
140 | class a.b.c.D | 140 | class a.b.c.D |
141 | _ = nil | 141 | _ = nil |
142 | 142 | ||
143 | 143 | ||
144 | class a.b["hello"] | 144 | class a.b["hello"] |
145 | _ = nil | 145 | _ = nil |
146 | 146 | ||
147 | class (-> require "moon")!.Something extends Hello.World | 147 | class (-> require "moon")!.Something extends Hello.World |
148 | _ = nil | 148 | _ = nil |
149 | 149 | ||
150 | -- | 150 | -- |
151 | 151 | ||
@@ -160,54 +160,54 @@ print (class WhatsUp).__name | |||
160 | 160 | ||
161 | export ^ | 161 | export ^ |
162 | class Something | 162 | class Something |
163 | _ = nil | 163 | _ = nil |
164 | 164 | ||
165 | 165 | ||
166 | -- | 166 | -- |
167 | 167 | ||
168 | -- hoisting | 168 | -- hoisting |
169 | class Something | 169 | class Something |
170 | val = 23 | 170 | val = 23 |
171 | {:insert} = table | 171 | {:insert} = table |
172 | new: => print insert, val -- prints nil 23 | 172 | new: => print insert, val -- prints nil 23 |
173 | 173 | ||
174 | -- | 174 | -- |
175 | 175 | ||
176 | class X | 176 | class X |
177 | new: hi | 177 | new: hi |
178 | 178 | ||
179 | 179 | ||
180 | -- | 180 | -- |
181 | 181 | ||
182 | class Cool extends Thing | 182 | class Cool extends Thing |
183 | dang: => | 183 | dang: => |
184 | { | 184 | { |
185 | hello: -> super! | 185 | hello: -> super! |
186 | world: -> super.one | 186 | world: -> super.one |
187 | } | 187 | } |
188 | 188 | ||
189 | -- | 189 | -- |
190 | 190 | ||
191 | class Whack extends Thing | 191 | class Whack extends Thing |
192 | dang: do_something => | 192 | dang: do_something => |
193 | super! | 193 | super! |
194 | 194 | ||
195 | --- | 195 | --- |
196 | 196 | ||
197 | class Wowha extends Thing | 197 | class Wowha extends Thing |
198 | @butt: -> | 198 | @butt: -> |
199 | super! | 199 | super! |
200 | _ = super.hello | 200 | _ = super.hello |
201 | super\hello! | 201 | super\hello! |
202 | super\hello | 202 | super\hello |
203 | 203 | ||
204 | 204 | ||
205 | @zone: cool { | 205 | @zone: cool { |
206 | -> | 206 | -> |
207 | super! | 207 | super! |
208 | _ = super.hello | 208 | _ = super.hello |
209 | super\hello! | 209 | super\hello! |
210 | super\hello | 210 | super\hello |
211 | } | 211 | } |
212 | 212 | ||
213 | nil | 213 | nil |