fastruby 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/{README → README.rdoc} +6 -1
- data/Rakefile +7 -7
- data/benchmarks/benchmark.rb~ +14 -2
- data/ext/fastruby_base/fastruby_base.inl +8 -4
- data/lib/fastruby/builder/inference_updater.rb +76 -0
- data/lib/fastruby/builder/inference_updater.rb~ +76 -0
- data/lib/fastruby/builder/inferencer.rb +38 -0
- data/lib/fastruby/{inliner → builder}/inliner.rb +16 -27
- data/lib/fastruby/builder/inliner.rb~ +60 -0
- data/lib/fastruby/builder/locals_inference.rb +53 -0
- data/lib/fastruby/builder/lvar_type.rb +43 -0
- data/lib/fastruby/builder/lvar_type.rb~ +44 -0
- data/lib/fastruby/builder/pipeline.rb +43 -0
- data/lib/fastruby/builder/pipeline.rb~ +43 -0
- data/lib/fastruby/{reductor → builder}/reductor.rb +6 -3
- data/lib/fastruby/builder/reductor.rb~ +42 -0
- data/lib/fastruby/builder.rb +73 -25
- data/lib/fastruby/builder.rb~ +311 -0
- data/lib/fastruby/corelib/fixnum.rb +75 -0
- data/lib/fastruby/corelib/fixnum.rb~ +146 -0
- data/lib/fastruby/corelib/integer.rb +96 -0
- data/lib/fastruby/corelib/integer.rb~ +96 -0
- data/lib/fastruby/corelib.rb +23 -0
- data/lib/fastruby/corelib.rb~ +23 -0
- data/lib/fastruby/getlocals.rb +3 -1
- data/lib/fastruby/logging.rb +2 -2
- data/lib/fastruby/modules/inferencer/infer.rb +31 -0
- data/lib/fastruby/modules/inferencer/literal.rb +42 -0
- data/lib/fastruby/modules/inliner/call.rb +327 -0
- data/lib/fastruby/{inliner/modules/call.rb → modules/inliner/call.rb~} +14 -24
- data/lib/fastruby/modules/inliner/defn.rb +41 -0
- data/lib/fastruby/modules/inliner/defn.rb~ +29 -0
- data/lib/fastruby/modules/inliner/recursive.rb +40 -0
- data/lib/fastruby/{inliner/modules/recursive.rb → modules/inliner/recursive.rb~} +1 -1
- data/lib/fastruby/modules/lvar_type/call.rb +36 -0
- data/lib/fastruby/modules/lvar_type/call.rb~ +36 -0
- data/lib/fastruby/modules/lvar_type/defn.rb +42 -0
- data/lib/fastruby/modules/lvar_type/defn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb +41 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb +33 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb~ +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/case.rb +0 -0
- data/lib/fastruby/modules/reductor/fastruby_flag.rb +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/for.rb +0 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/nontree.rb +0 -0
- data/lib/fastruby/modules/reductor/nontree.rb~ +32 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/recursive.rb +1 -1
- data/lib/fastruby/modules/reductor/recursive.rb~ +31 -0
- data/lib/fastruby/{translator/modules → modules/translator}/block.rb +0 -0
- data/lib/fastruby/modules/translator/call.rb +344 -0
- data/lib/fastruby/{translator/modules/call.rb → modules/translator/call.rb~} +24 -3
- data/lib/fastruby/{translator/modules → modules/translator}/defn.rb +10 -9
- data/lib/fastruby/modules/translator/defn.rb~ +267 -0
- data/lib/fastruby/{translator/modules → modules/translator}/directive.rb +3 -1
- data/lib/fastruby/modules/translator/directive.rb~ +44 -0
- data/lib/fastruby/{translator/modules → modules/translator}/exceptions.rb +3 -1
- data/lib/fastruby/modules/translator/exceptions.rb~ +120 -0
- data/lib/fastruby/{translator/modules → modules/translator}/flow.rb +0 -0
- data/lib/fastruby/modules/translator/iter.rb +745 -0
- data/lib/fastruby/{translator/modules/iter.rb → modules/translator/iter.rb~} +103 -48
- data/lib/fastruby/modules/translator/literal.rb +150 -0
- data/lib/fastruby/{translator/modules/literal.rb → modules/translator/literal.rb~} +3 -3
- data/lib/fastruby/{translator/modules → modules/translator}/logical.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/method_group.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/nonlocal.rb +18 -6
- data/lib/fastruby/modules/translator/nonlocal.rb~ +298 -0
- data/lib/fastruby/modules/translator/static.rb +290 -0
- data/lib/fastruby/{translator/modules/static.rb → modules/translator/static.rb~} +66 -17
- data/lib/fastruby/modules/translator/variable.rb +280 -0
- data/lib/fastruby/{translator/modules/variable.rb → modules/translator/variable.rb~} +14 -44
- data/lib/fastruby/modules.rb +30 -0
- data/lib/fastruby/object.rb +42 -6
- data/lib/fastruby/object.rb~ +159 -0
- data/lib/fastruby/set_tree.rb +7 -11
- data/lib/fastruby/set_tree.rb~ +71 -0
- data/lib/fastruby/sexp_extension.rb +29 -7
- data/lib/fastruby/sexp_extension.rb~ +262 -0
- data/lib/fastruby/translator/scope_mode_helper.rb~ +138 -0
- data/lib/fastruby/translator/translator.rb +87 -92
- data/lib/fastruby/translator/translator.rb~ +1600 -0
- data/lib/fastruby/translator/translator_modules.rb +3 -1
- data/lib/fastruby/translator/translator_modules.rb~ +53 -0
- data/lib/fastruby.rb +3 -1
- data/lib/fastruby.rb~ +3 -1
- data/lib/fastruby_only/base.rb +1 -0
- data/spec/corelib/numeric/fixnum_spec.rb +110 -0
- data/spec/corelib/numeric/fixnum_spec.rb~ +104 -0
- data/spec/corelib/numeric/integer_spec.rb +173 -0
- data/spec/corelib/numeric/integer_spec.rb~ +173 -0
- data/spec/fastruby_only/base_spec.rb +74 -0
- data/spec/graph/base_spec.rb +2 -1
- data/spec/graph/base_spec.rb~ +35 -0
- data/spec/graph/path_spec.rb +2 -2
- data/spec/graph/path_spec.rb~ +48 -0
- data/spec/graph/vertex_spec.rb +2 -1
- data/spec/graph/vertex_spec.rb~ +58 -0
- data/spec/reductor/base_spec.rb +1 -1
- data/spec/ruby/block/lambda_spec.rb~ +163 -0
- data/spec/ruby/block/proc_as_block_spec.rb~ +69 -1
- data/spec/ruby/block_spec.rb~ +2 -494
- data/spec/ruby/call/base_call_spec.rb +1 -1
- data/spec/ruby/call/base_call_spec.rb~ +2 -60
- data/spec/ruby/defn/replacement_spec.rb +26 -14
- data/spec/ruby/defn/replacement_spec.rb~ +13 -3
- data/spec/ruby/exception/internal_ex_spec.rb~ +86 -0
- data/spec/ruby/integrity_spec.rb~ +35 -1
- data/spec/ruby/variable_spec.rb~ +31 -0
- data/spec/scope_mode/flow_spec.rb +1 -1
- data/spec/scope_mode/flow_spec.rb~ +109 -0
- data/spec/sugar/base_spec.rb +29 -0
- data/spec/sugar/base_spec.rb~ +16 -0
- metadata +100 -43
- data/spec/fastruby/inliner/modules/call_spec.rb +0 -0
- data/spec/fastruby/translator/modules/nonlocal_spec.rb +0 -0
- data/spec/fastruby/translator/translator_spec.rb +0 -0
- data/spec/ruby/block/arguments_spec.rb~ +0 -214
- data/spec/ruby/block/break_spec.rb~ +0 -236
- data/spec/ruby/block/next_spec.rb~ +0 -85
- data/spec/ruby/block/retry_spec.rb~ +0 -43
@@ -0,0 +1,74 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby, "FastRuby" do
|
4
|
+
it "should accept fastruby_only option" do
|
5
|
+
fastruby "
|
6
|
+
class FRONLY1
|
7
|
+
def foo
|
8
|
+
100
|
9
|
+
end
|
10
|
+
end
|
11
|
+
", :fastruby_only => true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should accept fastruby_only option, methods defined with that option should not be callable from normal ruby" do
|
15
|
+
fastruby "
|
16
|
+
class FRONLY2
|
17
|
+
def fronly2_foo
|
18
|
+
100
|
19
|
+
end
|
20
|
+
end
|
21
|
+
", :fastruby_only => true
|
22
|
+
|
23
|
+
lambda {
|
24
|
+
FRONLY2.new.fronly2_foo
|
25
|
+
}.should raise_error(NoMethodError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should accept fastruby_only option, methods defined with that option should be callable from fastruby" do
|
29
|
+
fastruby "
|
30
|
+
class FRONLY3
|
31
|
+
def foo
|
32
|
+
100
|
33
|
+
end
|
34
|
+
end
|
35
|
+
", :fastruby_only => true
|
36
|
+
|
37
|
+
fastruby "
|
38
|
+
class FRONLY3
|
39
|
+
def bar
|
40
|
+
foo
|
41
|
+
end
|
42
|
+
end
|
43
|
+
"
|
44
|
+
|
45
|
+
FRONLY3.new.bar.should be == 100
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should accept fastruby_only option, and two versions of the same method" do
|
49
|
+
class FRONLY4
|
50
|
+
def foo
|
51
|
+
200
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
fastruby "
|
56
|
+
class FRONLY4
|
57
|
+
def foo
|
58
|
+
100
|
59
|
+
end
|
60
|
+
end
|
61
|
+
", :fastruby_only => true
|
62
|
+
|
63
|
+
fastruby "
|
64
|
+
class FRONLY4
|
65
|
+
def bar
|
66
|
+
foo
|
67
|
+
end
|
68
|
+
end
|
69
|
+
"
|
70
|
+
|
71
|
+
FRONLY4.new.bar.should be == 100
|
72
|
+
FRONLY4.new.foo.should be == 200
|
73
|
+
end
|
74
|
+
end
|
data/spec/graph/base_spec.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
require "fastruby/sexp_extension"
|
3
|
+
|
4
|
+
describe FastRuby::Graph, "fastruby sexp graph" do
|
5
|
+
include FastRuby
|
6
|
+
it "should allow create empty graph" do
|
7
|
+
graph = Graph.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should allow add edges with add_edge" do
|
11
|
+
graph = Graph.new
|
12
|
+
graph.add_edge(1,2)
|
13
|
+
graph.edges.count.should be == 1
|
14
|
+
graph.edges.first.should be == [1,2]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return 0 edges for an empty graph" do
|
18
|
+
graph = Graph.new
|
19
|
+
graph.edges.count.should be == 0
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow creation of graphs using hashes" do
|
23
|
+
graph = Graph.new 3 => [4]
|
24
|
+
graph.edges.count.should be == 1
|
25
|
+
graph.edges.should include([3,4])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should allow creation of graphs using hashes with multiple nodes" do
|
29
|
+
graph = Graph.new 3 => [4,5,6]
|
30
|
+
graph.edges.count.should be == 3
|
31
|
+
graph.edges.should include([3,4])
|
32
|
+
graph.edges.should include([3,5])
|
33
|
+
graph.edges.should include([3,6])
|
34
|
+
end
|
35
|
+
end
|
data/spec/graph/path_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "fastruby"
|
2
2
|
require "fastruby/sexp_extension"
|
3
3
|
|
4
|
-
|
5
|
-
include FastRuby
|
4
|
+
include FastRuby
|
6
5
|
|
6
|
+
describe FastRuby::Graph, "fastruby sexp graph" do
|
7
7
|
def self.assert_graph_paths(origin, paths, graph_hash)
|
8
8
|
it "should read paths #{paths.inspect} for graph #{graph_hash} from #{origin}" do
|
9
9
|
graph = Graph.new graph_hash
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
require "fastruby/sexp_extension"
|
3
|
+
|
4
|
+
describe FastRuby::Graph, "fastruby sexp graph" do
|
5
|
+
include FastRuby
|
6
|
+
|
7
|
+
def self.assert_graph_paths(origin, paths, graph_hash)
|
8
|
+
it "should read paths #{paths.inspect} for graph #{graph_hash} from #{origin}" do
|
9
|
+
graph = Graph.new graph_hash
|
10
|
+
|
11
|
+
array = []
|
12
|
+
graph.each_path_from(origin) do |path|
|
13
|
+
path_array = []
|
14
|
+
path.each(&path_array.method(:<<))
|
15
|
+
array << path_array
|
16
|
+
end
|
17
|
+
|
18
|
+
paths.each do |path|
|
19
|
+
array.should include(path)
|
20
|
+
end
|
21
|
+
array.count.should be == paths.count
|
22
|
+
|
23
|
+
array
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_graph_paths(1, [[1,2]], 1 => [2] )
|
28
|
+
assert_graph_paths(1, [[1,3]], 1 => [3] )
|
29
|
+
assert_graph_paths(1, [[1,4]], 1 => [4] )
|
30
|
+
assert_graph_paths(3, [[3,2]], 3 => [2] )
|
31
|
+
assert_graph_paths(4, [[4,2]], 4 => [2] )
|
32
|
+
|
33
|
+
assert_graph_paths(1, [[1,2],[1,3]], 1 => [2,3] )
|
34
|
+
|
35
|
+
assert_graph_paths(1, [[1,2,3]], 1 => [2], 2 => [3] )
|
36
|
+
assert_graph_paths(1, [[1,2,3],[1,2,4]], 1 => [2], 2 => [3,4] )
|
37
|
+
assert_graph_paths(1, [[1,2,4],[1,3,4]], 1 => [2,3], 2 => [4],3 => [4] )
|
38
|
+
assert_graph_paths(1, [[1,2,3,4,5],[1,2,3,5],[1,3,5],[1,3,4,5]], 1 => [2,3], 2 => [3],3 => [4,5],4 => [5] )
|
39
|
+
|
40
|
+
# cyclic paths
|
41
|
+
assert_graph_paths(1, [[1]], 1 => [1] )
|
42
|
+
assert_graph_paths(1, [[1,2,1]], 1 => [2], 2 => [1] )
|
43
|
+
assert_graph_paths(2, [[2,1,2]], 1 => [2], 2 => [1] )
|
44
|
+
|
45
|
+
# cyclyc paths with repeated vertexes
|
46
|
+
assert_graph_paths(1, [[1,2,4],[1,2,3,2,4]], 1 => [2], 2 => [3,4], 3 => [2])
|
47
|
+
end
|
48
|
+
|
data/spec/graph/vertex_spec.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
require "fastruby/sexp_extension"
|
3
|
+
|
4
|
+
describe FastRuby::Graph, "fastruby sexp graph" do
|
5
|
+
include FastRuby
|
6
|
+
it "should allow read vertex from empty graph" do
|
7
|
+
graph = Graph.new
|
8
|
+
graph.vertexes
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should allow read vertex from empty graph and it must be empty" do
|
12
|
+
graph = Graph.new
|
13
|
+
graph.vertexes.count.should be == 0
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow read vertex from graph with one vertex" do
|
17
|
+
graph = Graph.new 1 => [1]
|
18
|
+
graph.vertexes.count.should be == 1
|
19
|
+
graph.vertexes.should include(1)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow read vertex from graph with two vertexes" do
|
23
|
+
graph = Graph.new 1 => [1,2]
|
24
|
+
graph.vertexes.count.should be == 2
|
25
|
+
graph.vertexes.should include(1)
|
26
|
+
graph.vertexes.should include(2)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should allow allow read vertex outputs" do
|
30
|
+
graph = Graph.new 1 => [1]
|
31
|
+
|
32
|
+
array = []
|
33
|
+
graph.each_vertex_output(1, &array.method(:<<))
|
34
|
+
|
35
|
+
array.should include(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should allow read vertex outputs" do
|
39
|
+
graph = Graph.new 1 => [2]
|
40
|
+
|
41
|
+
array = []
|
42
|
+
graph.each_vertex_output(1, &array.method(:<<))
|
43
|
+
|
44
|
+
array.should include(2)
|
45
|
+
|
46
|
+
array = []
|
47
|
+
graph.each_vertex_output(2, &array.method(:<<))
|
48
|
+
|
49
|
+
array.should be == []
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it "should allow read vertex outputs with no blocks (returning sets)" do
|
54
|
+
graph = Graph.new 1 => [2]
|
55
|
+
graph.each_vertex_output(1).should include(2)
|
56
|
+
graph.each_vertex_output(2).count.should == 0
|
57
|
+
end
|
58
|
+
end
|
data/spec/reductor/base_spec.rb
CHANGED
@@ -1,6 +1,62 @@
|
|
1
1
|
require "fastruby"
|
2
2
|
|
3
3
|
describe FastRuby, "fastruby" do
|
4
|
+
class ::LL1
|
5
|
+
fastruby "
|
6
|
+
def foo
|
7
|
+
a = 16
|
8
|
+
lambda {|x|
|
9
|
+
a+x
|
10
|
+
}
|
11
|
+
end
|
12
|
+
"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "lambda must be able to access local variables" do
|
16
|
+
::LL1.new.foo.call(16).should be == 32
|
17
|
+
end
|
18
|
+
|
19
|
+
fastruby "
|
20
|
+
class ::LL2
|
21
|
+
def foo
|
22
|
+
a = 16
|
23
|
+
lambda {|x|
|
24
|
+
a+x
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def bar
|
29
|
+
end
|
30
|
+
end
|
31
|
+
"
|
32
|
+
|
33
|
+
it "lambda must be able to access local variables, after another unrelated method is called" do
|
34
|
+
ll2 = ::LL2.new
|
35
|
+
lambda_object = ll2.foo
|
36
|
+
::LL2.new.bar
|
37
|
+
lambda_object.call(16).should be == 32
|
38
|
+
end
|
39
|
+
|
40
|
+
fastruby "
|
41
|
+
class ::LL3
|
42
|
+
def foo(a)
|
43
|
+
lambda {|x|
|
44
|
+
a+x
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def bar(y)
|
49
|
+
lambda_object = foo(16)
|
50
|
+
foo(160)
|
51
|
+
lambda_object.call(y)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
"
|
55
|
+
|
56
|
+
it "lambda must be able to access local variables, after another unrelated method is called (from fastruby)" do
|
57
|
+
ll3 = ::LL3.new
|
58
|
+
ll3.bar(1).should be == 17
|
59
|
+
end
|
4
60
|
|
5
61
|
fastruby "
|
6
62
|
class ::LL4
|
@@ -35,4 +91,111 @@ describe FastRuby, "fastruby" do
|
|
35
91
|
lambda_object.call(1).should be == 100
|
36
92
|
end
|
37
93
|
|
94
|
+
it "lambda must be able to access local variables of parent scopes through yield on ruby" do
|
95
|
+
ll4 = ::LL4.new
|
96
|
+
|
97
|
+
a = 99
|
98
|
+
|
99
|
+
lambda_object = ll4.foo do |x|
|
100
|
+
x+a
|
101
|
+
end
|
102
|
+
lambda_object.call(1).should be == 100
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.next_sentence(sname)
|
106
|
+
fastruby "
|
107
|
+
class ::LL5#{sname}
|
108
|
+
def foo
|
109
|
+
lambda {
|
110
|
+
#{sname} 100
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
"
|
115
|
+
|
116
|
+
it "lambda #{sname}'s must act as block next" do
|
117
|
+
eval("LL5"+sname).new.foo.call.should be == 100
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
next_sentence("next")
|
122
|
+
next_sentence("break")
|
123
|
+
next_sentence("return")
|
124
|
+
|
125
|
+
def self.illegal_jump(sname)
|
126
|
+
eval "
|
127
|
+
class ::LL6#{sname}
|
128
|
+
def foo
|
129
|
+
lambda {
|
130
|
+
yield
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def bar
|
135
|
+
foo do
|
136
|
+
#{sname} 9
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
"
|
141
|
+
|
142
|
+
it "#{sname} inside block should raise LocalJumpError" do
|
143
|
+
ll6 = eval("::LL6"+sname).new
|
144
|
+
lambda {
|
145
|
+
ll6.bar.call
|
146
|
+
}.should raise_error(LocalJumpError)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# illegal_jump("return")
|
151
|
+
illegal_jump("break")
|
152
|
+
|
153
|
+
|
154
|
+
fastruby "
|
155
|
+
class ::LL7
|
156
|
+
|
157
|
+
def bar(l)
|
158
|
+
l.call
|
159
|
+
yield
|
160
|
+
end
|
161
|
+
|
162
|
+
def foo
|
163
|
+
lambda_obj = lambda {
|
164
|
+
}
|
165
|
+
|
166
|
+
bar(lambda_obj) do
|
167
|
+
break 0
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
"
|
172
|
+
|
173
|
+
it "should break from block after calling lambda" do
|
174
|
+
ll7 = ::LL7.new
|
175
|
+
lambda {
|
176
|
+
ll7.foo.should be == 0
|
177
|
+
}.should_not raise_error
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
class ::LL8
|
182
|
+
|
183
|
+
alias alt_lambda lambda
|
184
|
+
|
185
|
+
fastruby "
|
186
|
+
def foo
|
187
|
+
lambda_obj = alt_lambda {
|
188
|
+
return 9
|
189
|
+
}
|
190
|
+
|
191
|
+
lambda_obj.call
|
192
|
+
end
|
193
|
+
"
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should close lambda with return when renamed with alias" do
|
197
|
+
ll8 = ::LL8.new
|
198
|
+
ll8.foo.should be == 9
|
199
|
+
end
|
200
|
+
|
38
201
|
end
|
@@ -1,6 +1,27 @@
|
|
1
1
|
require "fastruby"
|
2
2
|
|
3
3
|
describe FastRuby, "fastruby" do
|
4
|
+
|
5
|
+
|
6
|
+
class ::VY6
|
7
|
+
fastruby "
|
8
|
+
def foo(a)
|
9
|
+
yield(a)
|
10
|
+
end
|
11
|
+
|
12
|
+
def bar(x,block)
|
13
|
+
foo(x,&block)
|
14
|
+
end
|
15
|
+
"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should allow single arguments with block" do
|
19
|
+
vy6 = ::VY6.new
|
20
|
+
|
21
|
+
block = proc do |a| "44" end
|
22
|
+
vy6.bar(44,block).should be == "44"
|
23
|
+
end
|
24
|
+
|
4
25
|
class ::VY7
|
5
26
|
def foo(a)
|
6
27
|
yield(a)
|
@@ -9,7 +30,7 @@ describe FastRuby, "fastruby" do
|
|
9
30
|
|
10
31
|
fastruby "
|
11
32
|
def bar(x,block)
|
12
|
-
foo(x
|
33
|
+
foo(x,&block)
|
13
34
|
end
|
14
35
|
"
|
15
36
|
end
|
@@ -20,4 +41,51 @@ describe FastRuby, "fastruby" do
|
|
20
41
|
block = proc do |a| "44" end
|
21
42
|
vy7.bar(44,block).should be == "44"
|
22
43
|
end
|
44
|
+
|
45
|
+
|
46
|
+
class ::VY8
|
47
|
+
def foo(a)
|
48
|
+
yield(a)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
fastruby "
|
53
|
+
def bar(x,block)
|
54
|
+
foo(x,&block)
|
55
|
+
end
|
56
|
+
"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should allow single arguments with block calling ruby methods and read block arguments" do
|
60
|
+
vy8 = ::VY8.new
|
61
|
+
|
62
|
+
block = proc do |a| a.to_s end
|
63
|
+
vy8.bar(555,block).should be == "555"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow single arguments with block calling ruby methods and read array block arguments" do
|
67
|
+
vy8 = ::VY8.new
|
68
|
+
|
69
|
+
block = proc do |a| a end
|
70
|
+
vy8.bar([555],block).should be == [555]
|
71
|
+
end
|
72
|
+
|
73
|
+
class ::VY9
|
74
|
+
def foo(a)
|
75
|
+
yield(a)
|
76
|
+
end
|
77
|
+
|
78
|
+
fastruby "
|
79
|
+
def bar(vy9,x,block)
|
80
|
+
vy9.first.foo(x,&block)
|
81
|
+
end
|
82
|
+
"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should allow block as proc with no type inference of the receiver" do
|
86
|
+
vy9 = ::VY9.new
|
87
|
+
|
88
|
+
block = proc do |a| a end
|
89
|
+
vy9.bar([vy9],555,block).should be == 555
|
90
|
+
end
|
23
91
|
end
|