fastruby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/README +1 -2
- data/Rakefile +2 -2
- data/TODO +0 -2
- data/lib/fastruby/builder.rb +19 -1
- data/lib/fastruby/custom_require.rb +48 -0
- data/lib/fastruby/object.rb +73 -10
- data/lib/fastruby/translator.rb +637 -131
- data/lib/fastruby.rb +4 -0
- data/spec/base_spec.rb +37 -0
- data/spec/block/break_spec.rb +190 -0
- data/spec/block/next_spec.rb +85 -0
- data/spec/exception_spec.rb +440 -0
- data/spec/module_spec.rb +36 -0
- data/spec/return_spec.rb +99 -0
- data/spec/singleton_spec.rb +76 -0
- data/spec/sugar_spec.rb +2 -2
- data/spec/variable_spec.rb +64 -0
- metadata +12 -4
data/spec/variable_spec.rb
CHANGED
@@ -169,4 +169,68 @@ describe FastRuby, "fastruby" do
|
|
169
169
|
::U12::U12C.should be == 51
|
170
170
|
end
|
171
171
|
|
172
|
+
it "should call defined? to undefined local variable and return nil" do
|
173
|
+
class ::U13
|
174
|
+
fastruby "
|
175
|
+
def foo
|
176
|
+
defined? wowowowo
|
177
|
+
end
|
178
|
+
"
|
179
|
+
end
|
180
|
+
::U13.new.foo.should be == nil
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should call defined? to undefined constant and return nil" do
|
184
|
+
class ::U16
|
185
|
+
fastruby "
|
186
|
+
def foo
|
187
|
+
defined? Wowowowow
|
188
|
+
end
|
189
|
+
"
|
190
|
+
end
|
191
|
+
::U16.new.foo.should be == nil
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.test_defined(code,title,defined_name)
|
195
|
+
it "should call defined? to defined #{title} and return '#{defined_name}" do
|
196
|
+
classname = "::U"+rand(1000000).to_s
|
197
|
+
|
198
|
+
code = "def foo; #{code}; end"
|
199
|
+
eval("class #{classname}
|
200
|
+
fastruby #{code.inspect}
|
201
|
+
end")
|
202
|
+
eval(classname).new.foo.should be == defined_name
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.test_defined_block(code,title,defined_name)
|
207
|
+
it "should call defined? to defined #{title} and return '#{defined_name}'" do
|
208
|
+
classname = "::U"+rand(1000000).to_s
|
209
|
+
|
210
|
+
code = "def foo; #{code}; end"
|
211
|
+
eval("class #{classname}
|
212
|
+
fastruby #{code.inspect}
|
213
|
+
end")
|
214
|
+
eval(classname).new.foo{}.should be == defined_name
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
test_defined "@a =17; defined? @a", "instance variable", "instance-variable"
|
219
|
+
|
220
|
+
$a = 9
|
221
|
+
test_defined "defined? $a", "global variable", "global-variable"
|
222
|
+
test_defined "a = 17; defined? a", "local variable", "local-variable"
|
223
|
+
test_defined "defined? Fixnum", "constant", "constant"
|
224
|
+
test_defined_block "defined? yield", "yield", "yield"
|
225
|
+
test_defined "defined? true", "true", "true"
|
226
|
+
test_defined "defined? false", "false", "false"
|
227
|
+
test_defined "defined? nil", "nil", "nil"
|
228
|
+
test_defined "defined? self", "self", "self"
|
229
|
+
test_defined "defined? print", "method", "method"
|
230
|
+
test_defined "defined?(if 0; 4; end)", "expression", "expression"
|
231
|
+
|
232
|
+
["a", "$a", "@a", "@@a", "A"].each do |var|
|
233
|
+
test_defined "defined? #{var}=0", "#{var} assignment", "assignment"
|
234
|
+
end
|
235
|
+
|
172
236
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dario Seminara
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-14 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- examples/example2.rb
|
72
72
|
- lib/fastruby/inline_extension.rb
|
73
73
|
- lib/fastruby/builder.rb
|
74
|
+
- lib/fastruby/custom_require.rb
|
74
75
|
- lib/fastruby/logging.rb
|
75
76
|
- lib/fastruby/exceptions.rb
|
76
77
|
- lib/fastruby/getlocals.rb
|
@@ -80,17 +81,24 @@ files:
|
|
80
81
|
- lib/fastruby.rb
|
81
82
|
- spec/variable_spec.rb
|
82
83
|
- spec/control_spec.rb
|
84
|
+
- spec/return_spec.rb
|
83
85
|
- spec/expression_spec.rb
|
86
|
+
- spec/module_spec.rb
|
87
|
+
- spec/exception_spec.rb
|
84
88
|
- spec/base_spec.rb
|
89
|
+
- spec/block/next_spec.rb
|
90
|
+
- spec/block/break_spec.rb
|
85
91
|
- spec/block_spec.rb
|
86
92
|
- spec/sugar_spec.rb
|
87
93
|
- spec/literal_spec.rb
|
94
|
+
- spec/singleton_spec.rb
|
88
95
|
- spec/integrity_spec.rb
|
89
96
|
- LICENSE
|
90
97
|
- AUTHORS
|
91
98
|
- README
|
92
99
|
- Rakefile
|
93
100
|
- TODO
|
101
|
+
- CHANGELOG
|
94
102
|
has_rdoc: true
|
95
103
|
homepage: http://github.com/tario/fastruby
|
96
104
|
licenses: []
|