opal 0.3.2 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. data/README.md +85 -127
  2. data/bin/opal +3 -3
  3. data/lib/core.rb +114 -0
  4. data/{gems/core/lib → lib}/core/array.rb +68 -187
  5. data/{gems/core/lib → lib}/core/basic_object.rb +22 -5
  6. data/lib/core/class.rb +38 -0
  7. data/{gems/core/lib → lib}/core/dir.rb +1 -1
  8. data/lib/core/enumerable.rb +33 -0
  9. data/{gems/core/lib → lib}/core/error.rb +1 -4
  10. data/{gems/core/lib → lib}/core/false_class.rb +0 -0
  11. data/{gems/core/lib → lib}/core/file.rb +11 -3
  12. data/{gems/core/lib → lib}/core/hash.rb +12 -0
  13. data/{gems/core/lib → lib}/core/kernel.rb +114 -86
  14. data/lib/core/match_data.rb +33 -0
  15. data/lib/core/module.rb +97 -0
  16. data/{gems/core/lib → lib}/core/nil_class.rb +0 -0
  17. data/{gems/core/lib → lib}/core/numeric.rb +5 -0
  18. data/{gems/core/lib → lib}/core/object.rb +0 -0
  19. data/{gems/core/lib → lib}/core/proc.rb +13 -3
  20. data/{gems/core/lib → lib}/core/range.rb +10 -0
  21. data/{gems/core/lib → lib}/core/regexp.rb +33 -1
  22. data/{gems/core/lib → lib}/core/string.rb +25 -10
  23. data/{gems/core/lib → lib}/core/symbol.rb +3 -3
  24. data/{gems/core/lib → lib}/core/top_self.rb +0 -0
  25. data/{gems/core/lib → lib}/core/true_class.rb +0 -0
  26. data/lib/dev.rb +169 -0
  27. data/{gems/ospec/lib → lib}/ospec.rb +1 -0
  28. data/lib/ospec/autorun.rb +8 -0
  29. data/{gems/ospec/lib → lib}/ospec/dsl.rb +2 -2
  30. data/{gems/ospec/lib → lib}/ospec/example.rb +0 -0
  31. data/{gems/ospec/lib → lib}/ospec/example/before_and_after_hooks.rb +0 -0
  32. data/{gems/ospec/lib → lib}/ospec/example/errors.rb +0 -0
  33. data/{gems/ospec/lib → lib}/ospec/example/example_group.rb +0 -0
  34. data/{gems/ospec/lib → lib}/ospec/example/example_group_factory.rb +0 -3
  35. data/{gems/ospec/lib → lib}/ospec/example/example_group_hierarchy.rb +4 -3
  36. data/{gems/ospec/lib → lib}/ospec/example/example_group_methods.rb +1 -1
  37. data/{gems/ospec/lib → lib}/ospec/example/example_group_proxy.rb +3 -2
  38. data/{gems/ospec/lib → lib}/ospec/example/example_methods.rb +1 -1
  39. data/{gems/ospec/lib → lib}/ospec/example/example_proxy.rb +7 -7
  40. data/{gems/ospec/lib → lib}/ospec/expectations.rb +0 -0
  41. data/{gems/ospec/lib → lib}/ospec/expectations/errors.rb +0 -0
  42. data/{gems/ospec/lib → lib}/ospec/expectations/fail_with.rb +4 -3
  43. data/{gems/ospec/lib → lib}/ospec/expectations/handler.rb +6 -0
  44. data/lib/ospec/helpers/scratch.rb +18 -0
  45. data/{gems/ospec/lib → lib}/ospec/matchers.rb +2 -2
  46. data/{gems/ospec/lib → lib}/ospec/matchers/be.rb +0 -0
  47. data/{gems/ospec/lib → lib}/ospec/matchers/generated_descriptions.rb +0 -0
  48. data/{gems/ospec/lib → lib}/ospec/matchers/operator_matcher.rb +2 -0
  49. data/lib/ospec/matchers/raise_error.rb +38 -0
  50. data/lib/ospec/runner.rb +90 -0
  51. data/{gems/ospec/lib → lib}/ospec/runner/example_group_runner.rb +10 -13
  52. data/lib/ospec/runner/formatter/html_formatter.rb +139 -0
  53. data/{gems/ospec/lib → lib}/ospec/runner/formatter/terminal_formatter.rb +0 -0
  54. data/{gems/ospec/lib → lib}/ospec/runner/options.rb +1 -3
  55. data/{gems/ospec/lib → lib}/ospec/runner/reporter.rb +0 -9
  56. data/lib/racc/parser.rb +165 -0
  57. data/lib/strscan.rb +52 -0
  58. data/{lib → opal_lib}/opal.rb +2 -0
  59. data/opal_lib/opal/build_methods.rb +51 -0
  60. data/opal_lib/opal/builder.rb +164 -0
  61. data/opal_lib/opal/bundle.rb +70 -0
  62. data/opal_lib/opal/command.rb +68 -0
  63. data/{lib → opal_lib}/opal/context.rb +21 -9
  64. data/{lib → opal_lib}/opal/context/console.rb +0 -2
  65. data/opal_lib/opal/context/file_system.rb +34 -0
  66. data/{lib → opal_lib}/opal/context/loader.rb +26 -8
  67. data/opal_lib/opal/gem.rb +84 -0
  68. data/{lib → opal_lib}/opal/rake/builder_task.rb +2 -2
  69. data/opal_lib/opal/rake/spec_task.rb +32 -0
  70. data/{lib → opal_lib}/opal/ruby/nodes.rb +730 -109
  71. data/{lib → opal_lib}/opal/ruby/parser.rb +90 -23
  72. data/opal_lib/opal/ruby/ruby_parser.rb +4862 -0
  73. data/opal_lib/opal/ruby/ruby_parser.y +1454 -0
  74. data/opal_lib/opal/version.rb +4 -0
  75. data/runtime/class.js +359 -0
  76. data/runtime/debug.js +84 -0
  77. data/runtime/fs.js +199 -0
  78. data/runtime/init.js +558 -0
  79. data/runtime/loader.js +351 -0
  80. data/runtime/module.js +109 -0
  81. data/runtime/post.js +10 -0
  82. data/runtime/pre.js +7 -0
  83. data/runtime/runtime.js +351 -0
  84. metadata +88 -175
  85. data/.gitignore +0 -7
  86. data/Changelog +0 -31
  87. data/LICENSE +0 -75
  88. data/Rakefile +0 -86
  89. data/gems/core/README.md +0 -14
  90. data/gems/core/Rakefile +0 -8
  91. data/gems/core/core.gemspec +0 -13
  92. data/gems/core/lib/core.rb +0 -34
  93. data/gems/core/lib/core/class.rb +0 -31
  94. data/gems/core/lib/core/module.rb +0 -100
  95. data/gems/core/lib/core/vm.rb +0 -16
  96. data/gems/core/spec/core/array/append_spec.rb +0 -30
  97. data/gems/core/spec/core/array/assoc_spec.rb +0 -29
  98. data/gems/core/spec/core/array/at_spec.rb +0 -37
  99. data/gems/core/spec/core/array/clear_spec.rb +0 -22
  100. data/gems/core/spec/core/array/collect_bang_spec.rb +0 -27
  101. data/gems/core/spec/core/array/collect_spec.rb +0 -27
  102. data/gems/core/spec/core/array/compact_spec.rb +0 -41
  103. data/gems/core/spec/core/array/concat_spec.rb +0 -15
  104. data/gems/core/spec/core/array/constructor_spec.rb +0 -14
  105. data/gems/core/spec/core/array/each_spec.rb +0 -9
  106. data/gems/core/spec/core/array/element_reference_spec.rb +0 -4
  107. data/gems/core/spec/core/array/first_spec.rb +0 -35
  108. data/gems/core/spec/core/array/include_spec.rb +0 -9
  109. data/gems/core/spec/core/array/join_spec.rb +0 -6
  110. data/gems/core/spec/core/array/last_spec.rb +0 -51
  111. data/gems/core/spec/core/array/length_spec.rb +0 -6
  112. data/gems/core/spec/core/array/map_spec.rb +0 -33
  113. data/gems/core/spec/core/array/reverse_spec.rb +0 -6
  114. data/gems/core/spec/core/builtin_constants/builtin_constants_spec.rb +0 -7
  115. data/gems/core/spec/core/false/and_spec.rb +0 -10
  116. data/gems/core/spec/core/false/inspect_spec.rb +0 -6
  117. data/gems/core/spec/core/false/or_spec.rb +0 -10
  118. data/gems/core/spec/core/false/to_s_spec.rb +0 -6
  119. data/gems/core/spec/core/false/xor_spec.rb +0 -10
  120. data/gems/core/spec/core/file/join_spec.rb +0 -19
  121. data/gems/core/spec/core/hash/assoc_spec.rb +0 -32
  122. data/gems/core/spec/core/kernel/instance_eval_spec.rb +0 -0
  123. data/gems/core/spec/core/kernel/loop_spec.rb +0 -24
  124. data/gems/core/spec/core/kernel/raise_spec.rb +0 -0
  125. data/gems/core/spec/core/module/attr_accessor_spec.rb +0 -28
  126. data/gems/core/spec/core/number/lt_spec.rb +0 -12
  127. data/gems/core/spec/core/string/sub_spec.rb +0 -24
  128. data/gems/core/spec/core/true/and_spec.rb +0 -10
  129. data/gems/core/spec/core/true/inspect_spec.rb +0 -6
  130. data/gems/core/spec/core/true/or_spec.rb +0 -10
  131. data/gems/core/spec/core/true/to_s_spec.rb +0 -6
  132. data/gems/core/spec/core/true/xor_spec.rb +0 -10
  133. data/gems/core/spec/language/and_spec.rb +0 -61
  134. data/gems/core/spec/language/array_spec.rb +0 -68
  135. data/gems/core/spec/language/block_spec.rb +0 -38
  136. data/gems/core/spec/language/break_spec.rb +0 -36
  137. data/gems/core/spec/language/case_spec.rb +0 -103
  138. data/gems/core/spec/language/def_spec.rb +0 -21
  139. data/gems/core/spec/language/eigenclass_spec.rb +0 -60
  140. data/gems/core/spec/language/file_spec.rb +0 -13
  141. data/gems/core/spec/language/fixtures/block.rb +0 -21
  142. data/gems/core/spec/language/fixtures/super.rb +0 -293
  143. data/gems/core/spec/language/hash_spec.rb +0 -29
  144. data/gems/core/spec/language/if_spec.rb +0 -54
  145. data/gems/core/spec/language/loop_spec.rb +0 -11
  146. data/gems/core/spec/language/metaclass_spec.rb +0 -21
  147. data/gems/core/spec/language/method_spec.rb +0 -124
  148. data/gems/core/spec/language/next_spec.rb +0 -25
  149. data/gems/core/spec/language/or_spec.rb +0 -34
  150. data/gems/core/spec/language/redo_spec.rb +0 -24
  151. data/gems/core/spec/language/regexp_spec.rb +0 -26
  152. data/gems/core/spec/language/rescue_spec.rb +0 -20
  153. data/gems/core/spec/language/return_spec.rb +0 -47
  154. data/gems/core/spec/language/string_spec.rb +0 -25
  155. data/gems/core/spec/language/super_spec.rb +0 -32
  156. data/gems/core/spec/language/until_spec.rb +0 -157
  157. data/gems/core/spec/language/variables_spec.rb +0 -155
  158. data/gems/core/spec/language/while_spec.rb +0 -163
  159. data/gems/core/spec/spec_helper.rb +0 -5
  160. data/gems/core_fs/README.md +0 -19
  161. data/gems/dev/Rakefile +0 -5
  162. data/gems/dev/lib/dev.js +0 -99
  163. data/gems/dev/lib/dev/generator.js +0 -1264
  164. data/gems/dev/lib/dev/parser.js +0 -979
  165. data/gems/dev/lib/dev/ruby_parser.js +0 -1088
  166. data/gems/dev/lib/dev/ruby_parser.y +0 -1267
  167. data/gems/dev/lib/dev/string_scanner.js +0 -38
  168. data/gems/dev/tools/racc2js/README.md +0 -39
  169. data/gems/dev/tools/racc2js/math_parser.js +0 -222
  170. data/gems/dev/tools/racc2js/math_parser.rb +0 -133
  171. data/gems/dev/tools/racc2js/math_parser.y +0 -28
  172. data/gems/dev/tools/racc2js/parser.js +0 -218
  173. data/gems/dev/tools/racc2js/racc2js.rb +0 -153
  174. data/gems/json/README.md +0 -4
  175. data/gems/json/json.gemspec +0 -14
  176. data/gems/json/lib/json.rb +0 -64
  177. data/gems/json/lib/json/ext.rb +0 -51
  178. data/gems/json/lib/json/json2.js +0 -481
  179. data/gems/ospec/README.md +0 -0
  180. data/gems/ospec/lib/ospec/autorun.rb +0 -3
  181. data/gems/ospec/lib/ospec/runner.rb +0 -40
  182. data/gems/ospec/lib/ospec/runner/formatter/html_formatter.rb +0 -91
  183. data/gems/ospec/ospec.gemspec +0 -0
  184. data/gems/rquery/README.md +0 -9
  185. data/gems/rquery/lib/rquery.rb +0 -10
  186. data/gems/rquery/lib/rquery/ajax.rb +0 -4
  187. data/gems/rquery/lib/rquery/css.rb +0 -96
  188. data/gems/rquery/lib/rquery/document.rb +0 -25
  189. data/gems/rquery/lib/rquery/element.rb +0 -292
  190. data/gems/rquery/lib/rquery/event.rb +0 -108
  191. data/gems/rquery/lib/rquery/jquery.js +0 -8177
  192. data/gems/rquery/lib/rquery/request.rb +0 -138
  193. data/gems/rquery/lib/rquery/response.rb +0 -49
  194. data/gems/rquery/rquery.gemspec +0 -16
  195. data/lib/opal.js +0 -1597
  196. data/lib/opal/builder.rb +0 -117
  197. data/lib/opal/bundle.rb +0 -131
  198. data/lib/opal/command.rb +0 -11
  199. data/lib/opal/context/file_system.rb +0 -19
  200. data/lib/opal/gem.rb +0 -153
  201. data/lib/opal/ruby/ruby_parser.rb +0 -5170
  202. data/lib/opal/ruby/ruby_parser.y +0 -1298
  203. data/opal.gemspec +0 -15
@@ -1,21 +0,0 @@
1
-
2
- describe "Redefining a method" do
3
-
4
- it "replaces the original method" do
5
- def barFoo; 100; end
6
- barFoo.should == 100
7
-
8
- def barFoo; 200; end
9
- barFoo.should == 200
10
- end
11
- end
12
-
13
- describe "A singleton method definition" do
14
- it "can be declared for a local variable" do
15
- a = Object.new
16
- def a.foo
17
- 5
18
- end
19
- a.foo.should == 5
20
- end
21
- end
@@ -1,60 +0,0 @@
1
-
2
- # describe "self in an eigenclass body (class << obj)" do
3
- # it "is TrueClass for true" do
4
- # class << true; self; end.should == TrueClass
5
- # end
6
- #
7
- # it "is FalseClass for false" do
8
- # class << false; self; end.should == FalseClass
9
- # end
10
- #
11
- # it "is NilClass for nil" do
12
- # class << nil; self; end.should == NilClass
13
- # end
14
- #
15
- # it "is a singleton Class instance" do
16
- # mock = Object.new
17
- # cls = class << mock; self; end
18
- # cls.is_a?(Class).should == true
19
- # # puts cls
20
- # # `console.log(#{cls});`
21
- # end
22
- #
23
- # it "is a Class for classes"
24
- #
25
- # it "inherits from Class for classes" do
26
- # temp = []
27
- # cls = class << Object; self; end
28
- # sc = cls
29
- # until sc.nil? || sc.superclass == sc
30
- # temp << sc
31
- # sc = sc.superclass
32
- # end
33
- # temp.should include(Class)
34
- # end
35
- # end
36
-
37
-
38
- # puts "testing eigenclass etc"
39
- #
40
- # class EigenclassSpecTest
41
- #
42
- # def something=(something)
43
- # puts "setting something to #{something}"
44
- # end
45
- # end
46
- #
47
- # a = EigenclassSpecTest.new
48
- # a.something = 100
49
- #
50
- # a_class = class << a; self; end
51
- #
52
- # a_class.define_method(:something=) do |value|
53
- # puts "setting something.."
54
- # super value
55
- # puts "did set something"
56
- # end
57
- #
58
- # # `console.log(#{a}['$something=']);`
59
- #
60
- # a.something = 200
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- # specs for __FILE__
4
-
5
- describe "The __FILE__ constant" do
6
- it "equals the current filename" do
7
- File.basename(__FILE__).should == "file_spec.rb"
8
- end
9
-
10
- it "equals (eval) inside an eval" do
11
- # eval("__FILE__").should == "(eval)"
12
- end
13
- end
@@ -1,21 +0,0 @@
1
- puts "in block fixtures"
2
-
3
- module BlockSpecs
4
- class Yield
5
- def splat(*args)
6
- yield *args
7
- end
8
-
9
- def two_args
10
- yield 1, 2
11
- end
12
-
13
- def two_arg_array
14
- yield [1, 2]
15
- end
16
-
17
- def yield_splat_inside_block
18
- [1, 2].send(:each_with_index) { |*args| yield(*args) }
19
- end
20
- end
21
- end
@@ -1,293 +0,0 @@
1
- module Super
2
- module S1
3
- class A
4
- def foo(a)
5
- a << "A#foo"
6
- bar(a)
7
- end
8
- def bar(a)
9
- a << "A#bar"
10
- end
11
- end
12
- class B < A
13
- def foo(a)
14
- a << "B#foo"
15
- super(a)
16
- end
17
- def bar(a)
18
- a << "B#bar"
19
- super(a)
20
- end
21
- end
22
- end
23
-
24
- module S2
25
- class A
26
- def baz(a)
27
- a << "A#baz"
28
- end
29
- end
30
- class B < A
31
- def foo(a)
32
- a << "B#foo"
33
- baz(a)
34
- end
35
- end
36
- class C < B
37
- def baz(a)
38
- a << "C#baz"
39
- super(a)
40
- end
41
- end
42
- end
43
-
44
- module S3
45
- class A
46
- def foo(a)
47
- a << "A#foo"
48
- end
49
- def self.foo(a)
50
- a << "A::foo"
51
- end
52
- def self.bar(a)
53
- a << "A::bar"
54
- foo(a)
55
- end
56
- end
57
- class B < A
58
- def self.foo(a)
59
- a << "B::foo"
60
- super(a)
61
- end
62
- def self.bar(a)
63
- a << "B::bar"
64
- super(a)
65
- end
66
- end
67
- end
68
-
69
- module S4
70
- class A
71
- def foo(a)
72
- a << "A#foo"
73
- end
74
- end
75
- class B < A
76
- def foo(a, b)
77
- a << "B#foo(a,#{b})"
78
- super(a)
79
- end
80
- end
81
- end
82
-
83
- class S5
84
- def here
85
- :good
86
- end
87
- end
88
-
89
- class S6 < S5
90
- def under
91
- yield
92
- end
93
-
94
- def here
95
- under {
96
- super
97
- }
98
- end
99
- end
100
-
101
- class S7 < S5
102
- define_method(:here) { super() }
103
- end
104
-
105
- module MS1
106
- module ModA
107
- def foo(a)
108
- a << "ModA#foo"
109
- bar(a)
110
- end
111
- def bar(a)
112
- a << "ModA#bar"
113
- end
114
- end
115
- class A
116
- include ModA
117
- end
118
- module ModB
119
- def bar(a)
120
- a << "ModB#bar"
121
- super(a)
122
- end
123
- end
124
- class B < A
125
- def foo(a)
126
- a << "B#foo"
127
- super(a)
128
- end
129
- include ModB
130
- end
131
- end
132
- #
133
- # module MS2
134
- # class A
135
- # def baz(a)
136
- # a << "A#baz"
137
- # end
138
- # end
139
- # module ModB
140
- # def foo(a)
141
- # a << "ModB#foo"
142
- # baz(a)
143
- # end
144
- # end
145
- # class B < A
146
- # include ModB
147
- # end
148
- # class C < B
149
- # def baz(a)
150
- # a << "C#baz"
151
- # super(a)
152
- # end
153
- # end
154
- # end
155
- #
156
- # module MS3
157
- # module ModA
158
- # def foo(a)
159
- # a << "ModA#foo"
160
- # end
161
- # def bar(a)
162
- # a << "ModA#bar"
163
- # foo(a)
164
- # end
165
- # end
166
- # class A
167
- # def foo(a)
168
- # a << "A#foo"
169
- # end
170
- # class << self
171
- # include ModA
172
- # end
173
- # end
174
- # class B < A
175
- # def self.foo(a)
176
- # a << "B::foo"
177
- # super(a)
178
- # end
179
- # def self.bar(a)
180
- # a << "B::bar"
181
- # super(a)
182
- # end
183
- # end
184
- # end
185
- #
186
- # module MS4
187
- # module Layer1
188
- # def example
189
- # 5
190
- # end
191
- # end
192
- #
193
- # module Layer2
194
- # include Layer1
195
- # def example
196
- # super
197
- # end
198
- # end
199
- #
200
- # class A
201
- # include Layer2
202
- # public :example
203
- # end
204
- # end
205
-
206
- # class MM_A
207
- # undef_method :is_a?
208
- # end
209
- #
210
- # class MM_B < MM_A
211
- # def is_a?(blah)
212
- # # should fire the method_missing below
213
- # super
214
- # end
215
- #
216
- # def method_missing(*)
217
- # false
218
- # end
219
- # end
220
- #
221
- # class Alias1
222
- # def name
223
- # [:alias1]
224
- # end
225
- # end
226
- #
227
- # class Alias2 < Alias1
228
- # def initialize
229
- # @times = 0
230
- # end
231
- #
232
- # def name
233
- # if @times >= 10
234
- # raise "runaway super"
235
- # end
236
- #
237
- # @times += 1
238
- #
239
- # # Use this so that we can see collect all supers that we see.
240
- # # One bug that arises is that we call Alias2#name from Alias2#name
241
- # # as it's superclass. In that case, either we get a runaway recursion
242
- # # super OR we get the return value being [:alias2, :alias2, :alias1]
243
- # # rather than [:alias2, :alias1].
244
- # #
245
- # # Which one depends on caches and how super is implemented.
246
- # [:alias2] + super
247
- # end
248
- # end
249
- #
250
- # class Alias3 < Alias2
251
- # alias_method :name3, :name
252
- # # In the method table for Alias3 now should be a special alias entry
253
- # # that references Alias2 and Alias2#name (probably as an object).
254
- # #
255
- # # When name3 is called then, Alias2 (NOT Alias3) is presented as the
256
- # # current module to Alias2#name, so that when super is called,
257
- # # Alias2->superclass is next.
258
- # #
259
- # # Otherwise, Alias2 is next, which is where name was to begin with,
260
- # # causing the wrong #name method to be called.
261
- # end
262
- #
263
- # module AliasWithSuper
264
- # module AS1
265
- # def foo
266
- # :a
267
- # end
268
- # end
269
- #
270
- # module BS1
271
- # def foo
272
- # [:b, super]
273
- # end
274
- # end
275
- #
276
- # class Base
277
- # extend AS1
278
- # extend BS1
279
- # end
280
- #
281
- # class Trigger < Base
282
- # class << self
283
- # def foo_quux
284
- # foo_baz
285
- # end
286
- #
287
- # alias_method :foo_baz, :foo
288
- # alias_method :foo, :foo_quux
289
- # end
290
- # end
291
- # end
292
-
293
- end
@@ -1,29 +0,0 @@
1
-
2
- describe "Hash literal" do
3
- it "{} should return an empty hash" do
4
- {}.size.should == 0
5
- {}.should == {}
6
- end
7
-
8
- it "{} should return a new hash populated with the given elements" do
9
- h = { :a => 'a', 'b' => 3, 44 => 2.3 }
10
- h.size.should == 3
11
- h.should == { :a => 'a', 'b' => 3, 44 => 2.3 }
12
- end
13
-
14
- it "treats empty expressions as nils" do
15
- h = {() => ()}
16
- h.keys.should == [nil]
17
- h.values.should == [nil]
18
-
19
- h = {() => :value}
20
- h.keys.should == [nil]
21
- h.values.should == [:value]
22
- h[nil].should == :value
23
-
24
- h = {:key => ()}
25
- h.keys.should == [:key]
26
- h.values.should == [nil]
27
- h[:key].should == nil
28
- end
29
- end
@@ -1,54 +0,0 @@
1
- #
2
- # describe "The if expression" do
3
- # it "evaluates body if expression is true" do
4
- # a = []
5
- # if true
6
- # a << 123
7
- # end
8
- # a.should == [123]
9
- # end
10
- #
11
- # it "does not evaluate body if expression is false" do
12
- # a = []
13
- # if false
14
- # a << 123
15
- # end
16
- # a.should == []
17
- # end
18
- #
19
- # it "does not evaluate body if expression is empty" do
20
- # a = []
21
- # if ()
22
- # a << 123
23
- # end
24
- # a.should == []
25
- # end
26
- #
27
- # it "does not evaluate else body if expression is true" do
28
- # a = []
29
- # if true
30
- # a << 123
31
- # else
32
- # a << 456
33
- # end
34
- # a.should == [123]
35
- # end
36
- #
37
- # it "evaluates only else-body if expression is false" do
38
- # a = []
39
- # if false
40
- # a << 123
41
- # else
42
- # a << 456
43
- # end
44
- # a.should == [456]
45
- # end
46
- #
47
- # it "returns result of then-body evaluation if expression is true" do
48
- # # raise "this causes error: return is injected before if = javascript error"
49
- # # if true
50
- # # 123
51
- # # end.should == 456
52
- # end
53
- # end
54
-