fastruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +2 -0
- data/LICENSE +674 -0
- data/README +142 -0
- data/Rakefile +47 -0
- data/TODO +31 -0
- data/benchmarks/benchmark.rb +68 -0
- data/benchmarks/benchmark2.rb +70 -0
- data/benchmarks/benchmark3.rb +70 -0
- data/benchmarks/benchmark4.rb +94 -0
- data/benchmarks/benchmark5.rb +80 -0
- data/benchmarks/benchmark6.rb +64 -0
- data/examples/example1.rb +12 -0
- data/examples/example2.rb +14 -0
- data/examples/example3.rb +12 -0
- data/examples/example4.rb +17 -0
- data/lib/fastruby/builder.rb +97 -0
- data/lib/fastruby/exceptions.rb +24 -0
- data/lib/fastruby/getlocals.rb +47 -0
- data/lib/fastruby/inline_extension.rb +87 -0
- data/lib/fastruby/logging.rb +37 -0
- data/lib/fastruby/object.rb +168 -0
- data/lib/fastruby/translator.rb +903 -0
- data/lib/fastruby.rb +24 -0
- data/spec/base_spec.rb +357 -0
- data/spec/block_spec.rb +418 -0
- data/spec/control_spec.rb +71 -0
- data/spec/expression_spec.rb +59 -0
- data/spec/integrity_spec.rb +74 -0
- data/spec/literal_spec.rb +95 -0
- data/spec/variable_spec.rb +63 -0
- metadata +127 -0
data/spec/block_spec.rb
ADDED
@@ -0,0 +1,418 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "fastruby" do
|
4
|
+
class ::X6
|
5
|
+
fastruby "
|
6
|
+
def foo(ary)
|
7
|
+
ary.each do |a|
|
8
|
+
end
|
9
|
+
0
|
10
|
+
end
|
11
|
+
"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should compile blocks" do
|
15
|
+
::X6.new.foo([1,2,3]).should be == 0
|
16
|
+
end
|
17
|
+
|
18
|
+
class ::X7
|
19
|
+
fastruby "
|
20
|
+
def foo(ary)
|
21
|
+
ary.map do |a|
|
22
|
+
0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should compile blocks with code inside" do
|
29
|
+
::X7.new.foo([1,2,3]).should be == [0,0,0]
|
30
|
+
end
|
31
|
+
|
32
|
+
class ::X8
|
33
|
+
fastruby "
|
34
|
+
def foo(ary)
|
35
|
+
ary.map do |a|
|
36
|
+
a
|
37
|
+
end
|
38
|
+
end
|
39
|
+
"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should compile blocks with code inside refering block arguments" do
|
43
|
+
::X8.new.foo([1,2,3]).should be == [1,2,3]
|
44
|
+
end
|
45
|
+
|
46
|
+
class ::X9
|
47
|
+
fastruby "
|
48
|
+
def foo(hash)
|
49
|
+
hash.map do |k,v|
|
50
|
+
k+v
|
51
|
+
end
|
52
|
+
end
|
53
|
+
"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should compile blocks with code inside refering multiple block arguments" do
|
57
|
+
::X9.new.foo({1 => 2, 3 => 4}).sort.should be == [3,7]
|
58
|
+
end
|
59
|
+
|
60
|
+
class ::Y10
|
61
|
+
def bar(arg1)
|
62
|
+
yield
|
63
|
+
arg1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class ::X10
|
68
|
+
fastruby "
|
69
|
+
def foo(obj, arg1)
|
70
|
+
obj.bar(arg1) do |a|
|
71
|
+
end
|
72
|
+
end
|
73
|
+
"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should compile iter calls with arguments" do
|
77
|
+
::X10.new.foo(::Y10.new, 10).should be == 10
|
78
|
+
end
|
79
|
+
|
80
|
+
class ::Y11
|
81
|
+
def bar(arg1, arg2)
|
82
|
+
yield
|
83
|
+
arg1+arg2
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class ::X11
|
88
|
+
fastruby "
|
89
|
+
def foo(obj, arg1, arg2)
|
90
|
+
obj.bar(arg1, arg2) do |a|
|
91
|
+
end
|
92
|
+
end
|
93
|
+
"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should compile iter calls with multiple arguments" do
|
97
|
+
::X11.new.foo(::Y11.new, 10, 9).should be == 19
|
98
|
+
end
|
99
|
+
|
100
|
+
class ::X12
|
101
|
+
fastruby "
|
102
|
+
def foo(ary)
|
103
|
+
a = 1
|
104
|
+
ary.map do |x|
|
105
|
+
a
|
106
|
+
end
|
107
|
+
end
|
108
|
+
"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should allow accessing local variables from block" do
|
112
|
+
::X12.new.foo([1,2,3,4]).should be == [1,1,1,1]
|
113
|
+
end
|
114
|
+
|
115
|
+
class ::X13
|
116
|
+
fastruby "
|
117
|
+
def foo(ary)
|
118
|
+
a = 1
|
119
|
+
ary.map do |x|
|
120
|
+
a+x
|
121
|
+
end
|
122
|
+
end
|
123
|
+
"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should allow accessing local variables and block parameters from block" do
|
127
|
+
::X13.new.foo([1,2,3,4]).should be == [2,3,4,5]
|
128
|
+
end
|
129
|
+
|
130
|
+
class ::Y14
|
131
|
+
fastruby "
|
132
|
+
def bar
|
133
|
+
block_given?
|
134
|
+
end
|
135
|
+
"
|
136
|
+
end
|
137
|
+
|
138
|
+
class ::X14
|
139
|
+
fastruby "
|
140
|
+
def foo(y)
|
141
|
+
y.bar
|
142
|
+
end
|
143
|
+
"
|
144
|
+
end
|
145
|
+
|
146
|
+
it "method calls should not repass blocks" do
|
147
|
+
::X14.new.foo(::Y14.new){ }.should be == false
|
148
|
+
end
|
149
|
+
|
150
|
+
class ::X15
|
151
|
+
fastruby "
|
152
|
+
def foo
|
153
|
+
bar
|
154
|
+
end
|
155
|
+
"
|
156
|
+
|
157
|
+
private
|
158
|
+
def bar
|
159
|
+
true
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should allow calls to private methods" do
|
164
|
+
::X15.new.foo.should be == true
|
165
|
+
end
|
166
|
+
|
167
|
+
class ::X16
|
168
|
+
fastruby "
|
169
|
+
def foo
|
170
|
+
bar do
|
171
|
+
12
|
172
|
+
end
|
173
|
+
end
|
174
|
+
"
|
175
|
+
|
176
|
+
def bar
|
177
|
+
yield
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should allow calls with block to self methods" do
|
182
|
+
::X16.new.foo.should be == 12
|
183
|
+
end
|
184
|
+
|
185
|
+
class ::X17
|
186
|
+
fastruby "
|
187
|
+
def foo(z)
|
188
|
+
i = 9
|
189
|
+
z.each do |x|
|
190
|
+
i = x
|
191
|
+
0
|
192
|
+
end
|
193
|
+
i
|
194
|
+
end
|
195
|
+
"
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should allow assignment of locals from blocks" do
|
199
|
+
::X17.new.foo([1,2,3]).should be == 3
|
200
|
+
end
|
201
|
+
|
202
|
+
class ::X18
|
203
|
+
fastruby "
|
204
|
+
def foo
|
205
|
+
yield
|
206
|
+
end
|
207
|
+
"
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should allow block calls" do
|
211
|
+
::X18.new.foo{ 9 }.should be == 9
|
212
|
+
end
|
213
|
+
|
214
|
+
class ::Y19
|
215
|
+
fastruby "
|
216
|
+
def bar
|
217
|
+
yield
|
218
|
+
end
|
219
|
+
"
|
220
|
+
end
|
221
|
+
|
222
|
+
class ::X19
|
223
|
+
fastruby "
|
224
|
+
def foo(y)
|
225
|
+
y.bar {
|
226
|
+
9
|
227
|
+
}
|
228
|
+
end
|
229
|
+
"
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should execute block class between fastruby methods when no block is passed" do
|
233
|
+
::X19.new.foo(::Y19.new).should be == 9
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should execute block class between fastruby methods when block is passed" do
|
237
|
+
::X19.new.foo(::Y19.new){}.should be == 9
|
238
|
+
end
|
239
|
+
|
240
|
+
class ::X20
|
241
|
+
fastruby "
|
242
|
+
def foo
|
243
|
+
yield(1)
|
244
|
+
end
|
245
|
+
"
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should execute block from fastruby methods with one argument" do
|
249
|
+
::X20.new.foo do |n1|
|
250
|
+
n1.should be == 1
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class ::X21
|
255
|
+
fastruby "
|
256
|
+
def foo
|
257
|
+
yield(1,2)
|
258
|
+
end
|
259
|
+
"
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should execute block from fastruby methods with two arguments" do
|
263
|
+
::X21.new.foo do |n1,n2|
|
264
|
+
n1.should be == 1
|
265
|
+
n2.should be == 2
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
class ::Y22
|
270
|
+
fastruby "
|
271
|
+
def foo
|
272
|
+
yield
|
273
|
+
end
|
274
|
+
"
|
275
|
+
|
276
|
+
fastruby "
|
277
|
+
def bar(x)
|
278
|
+
i = 10
|
279
|
+
lvar_type(i,Fixnum)
|
280
|
+
x.foo do
|
281
|
+
i = i - 1
|
282
|
+
end
|
283
|
+
i
|
284
|
+
end
|
285
|
+
"
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should execute block calls after lvar_type directive" do
|
289
|
+
y22 = ::Y22.new
|
290
|
+
y22.bar(y22).should be == 9
|
291
|
+
end
|
292
|
+
|
293
|
+
class ::Y23
|
294
|
+
def foo
|
295
|
+
yield
|
296
|
+
end
|
297
|
+
|
298
|
+
def foo2
|
299
|
+
77
|
300
|
+
end
|
301
|
+
|
302
|
+
fastruby "
|
303
|
+
def bar(x)
|
304
|
+
i = 0
|
305
|
+
x.foo do
|
306
|
+
i = foo2
|
307
|
+
end
|
308
|
+
i
|
309
|
+
end
|
310
|
+
"
|
311
|
+
end
|
312
|
+
|
313
|
+
it "should call self methods from inside a block" do
|
314
|
+
y23 = ::Y23.new
|
315
|
+
y23.bar(y23).should be == 77
|
316
|
+
end
|
317
|
+
|
318
|
+
class ::Y24
|
319
|
+
def foo
|
320
|
+
yield
|
321
|
+
end
|
322
|
+
|
323
|
+
fastruby "
|
324
|
+
def bar(x)
|
325
|
+
i = 0
|
326
|
+
x.foo do
|
327
|
+
i = block_given?
|
328
|
+
end
|
329
|
+
i
|
330
|
+
end
|
331
|
+
"
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should call block_given? from inside a block when a block is not passed should return false" do
|
335
|
+
y24 = ::Y24.new
|
336
|
+
y24.bar(y24).should be == false
|
337
|
+
end
|
338
|
+
|
339
|
+
it "should call block_given? from inside a block when a block is not passed should return true" do
|
340
|
+
y24 = ::Y24.new
|
341
|
+
y24.bar(y24){}.should be == true
|
342
|
+
end
|
343
|
+
|
344
|
+
class ::Y25
|
345
|
+
def foo
|
346
|
+
yield
|
347
|
+
end
|
348
|
+
|
349
|
+
fastruby "
|
350
|
+
def bar(x)
|
351
|
+
i = 0
|
352
|
+
x.foo do
|
353
|
+
i = block_given? do
|
354
|
+
end
|
355
|
+
end
|
356
|
+
i
|
357
|
+
end
|
358
|
+
"
|
359
|
+
end
|
360
|
+
|
361
|
+
it "should call block_given? with block from inside a block when a block is not passed should return false " do
|
362
|
+
y25 = ::Y25.new
|
363
|
+
y25.bar(y25).should be == false
|
364
|
+
end
|
365
|
+
|
366
|
+
it "should call block_given? with block from inside a block when a block is not passed should return true" do
|
367
|
+
y25 = ::Y25.new
|
368
|
+
y25.bar(y25){}.should be == true
|
369
|
+
end
|
370
|
+
|
371
|
+
class ::Y26
|
372
|
+
def bar
|
373
|
+
yield
|
374
|
+
end
|
375
|
+
|
376
|
+
fastruby "
|
377
|
+
def foo
|
378
|
+
bar do
|
379
|
+
yield
|
380
|
+
end
|
381
|
+
end
|
382
|
+
"
|
383
|
+
end
|
384
|
+
|
385
|
+
it "should call yield from inside a block" do
|
386
|
+
y26 = ::Y26.new
|
387
|
+
|
388
|
+
block_num_calls = 0
|
389
|
+
|
390
|
+
y26.foo do
|
391
|
+
block_num_calls = block_num_calls + 1
|
392
|
+
end
|
393
|
+
|
394
|
+
block_num_calls.should be == 1
|
395
|
+
end
|
396
|
+
|
397
|
+
class ::Y27
|
398
|
+
fastruby "
|
399
|
+
def foo(x)
|
400
|
+
x
|
401
|
+
end
|
402
|
+
"
|
403
|
+
end
|
404
|
+
|
405
|
+
class ::Y28
|
406
|
+
fastruby "
|
407
|
+
def foo(y27, a)
|
408
|
+
y27.foo(a) do
|
409
|
+
end
|
410
|
+
end
|
411
|
+
"
|
412
|
+
end
|
413
|
+
|
414
|
+
it "should pass arguments when call with block" do
|
415
|
+
y28 = ::Y28.new
|
416
|
+
y28.foo(::Y27.new, 713).should be == 713
|
417
|
+
end
|
418
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "fastruby" do
|
4
|
+
|
5
|
+
class ::C1
|
6
|
+
fastruby '
|
7
|
+
def foo
|
8
|
+
ret = 0
|
9
|
+
if true
|
10
|
+
ret = 32
|
11
|
+
end
|
12
|
+
ret
|
13
|
+
end
|
14
|
+
'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should execute if when the condition is true" do
|
18
|
+
::C1.new.foo.should be == 32
|
19
|
+
end
|
20
|
+
|
21
|
+
class ::C2
|
22
|
+
fastruby '
|
23
|
+
def foo
|
24
|
+
ret = 0
|
25
|
+
if false
|
26
|
+
ret = 32
|
27
|
+
end
|
28
|
+
ret
|
29
|
+
end
|
30
|
+
'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should execute if when the condition is false" do
|
34
|
+
::C2.new.foo.should be == 0
|
35
|
+
end
|
36
|
+
|
37
|
+
class ::C3
|
38
|
+
fastruby '
|
39
|
+
def foo
|
40
|
+
ret = 0
|
41
|
+
if false
|
42
|
+
ret = 32
|
43
|
+
else
|
44
|
+
ret = 16
|
45
|
+
end
|
46
|
+
ret
|
47
|
+
end
|
48
|
+
'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should execute if with else when the condition is false" do
|
52
|
+
::C3.new.foo.should be == 16
|
53
|
+
end
|
54
|
+
|
55
|
+
class ::C4
|
56
|
+
fastruby '
|
57
|
+
def foo
|
58
|
+
ret = 0
|
59
|
+
unless false
|
60
|
+
ret = 32
|
61
|
+
end
|
62
|
+
ret
|
63
|
+
end
|
64
|
+
'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should execute unless when the condition is false" do
|
68
|
+
# tip: unless is only a reverse if
|
69
|
+
::C4.new.foo.should be == 32
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "fastruby" do
|
4
|
+
class ::D5
|
5
|
+
fastruby '
|
6
|
+
def foo(a,b)
|
7
|
+
a == b
|
8
|
+
end
|
9
|
+
'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should execute unless when the condition is false" do
|
13
|
+
::D5.new.foo(1,1).should be == true
|
14
|
+
::D5.new.foo(1,2).should be == false
|
15
|
+
end
|
16
|
+
|
17
|
+
class ::D6
|
18
|
+
fastruby '
|
19
|
+
def foo(a,b)
|
20
|
+
a and b
|
21
|
+
end
|
22
|
+
'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should execute unless when the condition is false" do
|
26
|
+
::D6.new.foo(false,false).should be == false
|
27
|
+
::D6.new.foo(true,false).should be == false
|
28
|
+
::D6.new.foo(false,true).should be == false
|
29
|
+
::D6.new.foo(true,true).should be == true
|
30
|
+
end
|
31
|
+
|
32
|
+
class ::D7
|
33
|
+
fastruby '
|
34
|
+
def foo(a,b)
|
35
|
+
a or b
|
36
|
+
end
|
37
|
+
'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should execute unless when the condition is false" do
|
41
|
+
::D7.new.foo(false,false).should be == false
|
42
|
+
::D7.new.foo(true,false).should be == true
|
43
|
+
::D7.new.foo(false,true).should be == true
|
44
|
+
::D7.new.foo(true,true).should be == true
|
45
|
+
end
|
46
|
+
|
47
|
+
class ::D8
|
48
|
+
fastruby '
|
49
|
+
def foo(a)
|
50
|
+
not a
|
51
|
+
end
|
52
|
+
'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should execute unless when the condition is false" do
|
56
|
+
::D8.new.foo(false).should be == true
|
57
|
+
::D8.new.foo(true).should be == false
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "fastruby" do
|
4
|
+
|
5
|
+
class ::Y1
|
6
|
+
fastruby "
|
7
|
+
def foo(x)
|
8
|
+
i = 0
|
9
|
+
lvar_type(i,Fixnum)
|
10
|
+
i = x
|
11
|
+
0
|
12
|
+
end
|
13
|
+
"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should deny wrong type assignments at runtime by default" do
|
17
|
+
lambda {
|
18
|
+
::Y1.new.foo("test string")
|
19
|
+
}.should raise_error(FastRuby::TypeMismatchAssignmentException)
|
20
|
+
end
|
21
|
+
|
22
|
+
class ::Y2
|
23
|
+
fastruby "
|
24
|
+
def foo(x)
|
25
|
+
i = 0
|
26
|
+
lvar_type(i,Fixnum)
|
27
|
+
i = x
|
28
|
+
0
|
29
|
+
end
|
30
|
+
", :validate_lvar_types => true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should deny wrong type assignments at runtime when validate_lvar_types is true" do
|
34
|
+
lambda {
|
35
|
+
::Y2.new.foo("test string")
|
36
|
+
}.should raise_error(FastRuby::TypeMismatchAssignmentException)
|
37
|
+
end
|
38
|
+
|
39
|
+
class ::Y3
|
40
|
+
fastruby "
|
41
|
+
def foo(x)
|
42
|
+
i = 0
|
43
|
+
lvar_type(i,Fixnum)
|
44
|
+
i = x
|
45
|
+
0
|
46
|
+
end
|
47
|
+
", :validate_lvar_types => false
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should NOT deny wrong type assignments at runtime when validate_lvar_types is false" do
|
51
|
+
lambda {
|
52
|
+
::Y3.new.foo("test string")
|
53
|
+
}.should_not raise_error
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
class ::Y4
|
58
|
+
fastruby "
|
59
|
+
def foo(x)
|
60
|
+
x+1
|
61
|
+
end
|
62
|
+
"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should builds be re-entrants, multiple calls should not produce any error if the first call works" do
|
66
|
+
lambda {
|
67
|
+
::Y4.build([Y4,Fixnum],:foo)
|
68
|
+
::Y4.build([Y4,Fixnum],:foo)
|
69
|
+
::Y4.build([Y4,Fixnum],:foo)
|
70
|
+
|
71
|
+
::Y4.new.foo(1).should be ==2
|
72
|
+
}.should_not raise_error
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "fastruby" do
|
4
|
+
class ::Z1
|
5
|
+
fastruby "
|
6
|
+
def foo
|
7
|
+
0
|
8
|
+
end
|
9
|
+
"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should compile Fixnum literals" do
|
13
|
+
::Z1.new.foo.should be == 0
|
14
|
+
end
|
15
|
+
|
16
|
+
class ::Z2
|
17
|
+
fastruby "
|
18
|
+
def foo
|
19
|
+
'test string'
|
20
|
+
end
|
21
|
+
"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should compile string literals" do
|
25
|
+
::Z2.new.foo.should be == 'test string'
|
26
|
+
end
|
27
|
+
|
28
|
+
class ::Z3
|
29
|
+
fastruby "
|
30
|
+
def foo
|
31
|
+
[1,2,3]
|
32
|
+
end
|
33
|
+
"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should compile array literals" do
|
37
|
+
::Z3.new.foo.should be == [1,2,3]
|
38
|
+
end
|
39
|
+
|
40
|
+
class ::Z4
|
41
|
+
fastruby "
|
42
|
+
def foo
|
43
|
+
/aaa/
|
44
|
+
end
|
45
|
+
"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should compile regexp literals" do
|
49
|
+
::Z4.new.foo.should be == /aaa/
|
50
|
+
end
|
51
|
+
|
52
|
+
class ::Z5
|
53
|
+
fastruby "
|
54
|
+
def foo
|
55
|
+
{ 1 => 2, 3 => 4}
|
56
|
+
end
|
57
|
+
"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should compile hash literals" do
|
61
|
+
::Z5.new.foo.should be == { 1 => 2, 3 => 4}
|
62
|
+
end
|
63
|
+
|
64
|
+
class ::Z6
|
65
|
+
fastruby "
|
66
|
+
def foo
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should compile nil" do
|
73
|
+
::Z6.new.foo.should be == nil
|
74
|
+
end
|
75
|
+
|
76
|
+
class ::Z7
|
77
|
+
fastruby "
|
78
|
+
def foo(a,b)
|
79
|
+
(a..b)
|
80
|
+
end
|
81
|
+
"
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.test_range(a,b)
|
85
|
+
it "should compile range (#{a}..#{b})" do
|
86
|
+
::Z7.new.foo(a,b).should be == (a..b)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
test_range 0,0
|
91
|
+
test_range 3,54
|
92
|
+
test_range 'a', 'f'
|
93
|
+
test_range 0.54,066
|
94
|
+
|
95
|
+
end
|