opal 0.3.16 → 0.3.17

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 (251) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +8 -7
  4. data/README.md +21 -13
  5. data/Rakefile +64 -78
  6. data/bin/opal +18 -29
  7. data/core/alpha.rb +2 -9
  8. data/core/array.rb +106 -50
  9. data/core/basic_object.rb +10 -8
  10. data/core/boolean.rb +2 -0
  11. data/core/class.rb +25 -13
  12. data/core/comparable.rb +6 -6
  13. data/core/enumerable.rb +90 -94
  14. data/core/enumerator.rb +3 -3
  15. data/core/hash.rb +86 -46
  16. data/core/kernel.rb +55 -39
  17. data/core/load_order +2 -5
  18. data/core/match_data.rb +1 -1
  19. data/core/module.rb +45 -20
  20. data/core/nil_class.rb +6 -2
  21. data/core/numeric.rb +20 -10
  22. data/core/proc.rb +2 -2
  23. data/core/range.rb +72 -13
  24. data/core/regexp.rb +5 -3
  25. data/core/runtime.js +228 -287
  26. data/core/string.rb +345 -37
  27. data/core/top_self.rb +1 -1
  28. data/lib/opal.rb +13 -91
  29. data/lib/opal/builder.rb +47 -120
  30. data/lib/opal/builder_task.rb +74 -0
  31. data/lib/opal/{parser/grammar.rb → grammar.rb} +1094 -1083
  32. data/lib/opal/{parser/grammar.y → grammar.y} +7 -0
  33. data/lib/opal/{parser/lexer.rb → lexer.rb} +32 -11
  34. data/lib/opal/{parser/parser.rb → parser.rb} +232 -238
  35. data/lib/opal/{parser/scope.rb → scope.rb} +72 -9
  36. data/lib/opal/version.rb +2 -3
  37. data/opal.gemspec +1 -2
  38. data/{core_spec → spec}/core/array/allocate_spec.rb +1 -3
  39. data/{core_spec → spec}/core/array/append_spec.rb +1 -4
  40. data/{core_spec → spec}/core/array/assoc_spec.rb +1 -4
  41. data/{core_spec → spec}/core/array/at_spec.rb +1 -3
  42. data/{core_spec → spec}/core/array/clear_spec.rb +1 -3
  43. data/spec/core/array/clone_spec.rb +15 -0
  44. data/{core_spec/core/array/shared/collect.rb → spec/core/array/collect_spec.rb} +1 -1
  45. data/{core_spec → spec}/core/array/compact_spec.rb +1 -3
  46. data/{core_spec → spec}/core/array/concat_spec.rb +1 -3
  47. data/{core_spec → spec}/core/array/constructor_spec.rb +9 -3
  48. data/{core_spec → spec}/core/array/count_spec.rb +1 -3
  49. data/{core_spec → spec}/core/array/delete_at_spec.rb +1 -4
  50. data/{core_spec → spec}/core/array/delete_if_spec.rb +1 -4
  51. data/{core_spec → spec}/core/array/delete_spec.rb +1 -4
  52. data/{core_spec → spec}/core/array/each_index_spec.rb +1 -4
  53. data/{core_spec → spec}/core/array/each_spec.rb +1 -4
  54. data/{core_spec → spec}/core/array/element_reference_spec.rb +74 -4
  55. data/{core_spec → spec}/core/array/empty_spec.rb +1 -4
  56. data/{core_spec/core/array/shared/eql.rb → spec/core/array/eql_spec.rb} +1 -1
  57. data/{core_spec → spec}/core/array/fetch_spec.rb +1 -4
  58. data/{core_spec → spec}/core/array/first_spec.rb +1 -3
  59. data/{core_spec → spec}/core/array/flatten_spec.rb +1 -3
  60. data/{core_spec → spec}/core/array/include_spec.rb +1 -3
  61. data/{core_spec → spec}/core/array/insert_spec.rb +1 -4
  62. data/{core_spec → spec}/core/array/last_spec.rb +1 -4
  63. data/{core_spec/core/array/shared/length.rb → spec/core/array/length_spec.rb} +1 -1
  64. data/spec/core/array/map_spec.rb +53 -0
  65. data/{core_spec → spec}/core/array/plus_spec.rb +1 -4
  66. data/{core_spec → spec}/core/array/pop_spec.rb +1 -4
  67. data/{core_spec → spec}/core/array/push_spec.rb +1 -4
  68. data/{core_spec → spec}/core/array/rassoc_spec.rb +1 -4
  69. data/{core_spec → spec}/core/array/reject_spec.rb +1 -4
  70. data/{core_spec/core/array/shared/replace.rb → spec/core/array/replace_spec.rb} +1 -1
  71. data/{core_spec → spec}/core/array/reverse_each_spec.rb +1 -4
  72. data/{core_spec → spec}/core/array/reverse_spec.rb +1 -4
  73. data/spec/core/array/size_spec.rb +6 -0
  74. data/spec/core/array/to_ary_spec.rb +6 -0
  75. data/spec/core/array/uniq_spec.rb +22 -0
  76. data/spec/core/array/zip_spec.rb +20 -0
  77. data/{core_spec → spec}/core/class/new_spec.rb +1 -4
  78. data/{core_spec → spec}/core/enumerable/all_spec.rb +1 -4
  79. data/{core_spec → spec}/core/enumerable/any_spec.rb +1 -4
  80. data/{core_spec/core/enumerable/shared/collect.rb → spec/core/enumerable/collect_spec.rb} +1 -1
  81. data/{core_spec → spec}/core/enumerable/count_spec.rb +2 -5
  82. data/{core_spec → spec}/core/enumerable/fixtures/classes.rb +1 -2
  83. data/{core_spec → spec}/core/false/and_spec.rb +1 -3
  84. data/{core_spec → spec}/core/false/inspect_spec.rb +1 -3
  85. data/{core_spec → spec}/core/false/or_spec.rb +1 -3
  86. data/{core_spec → spec}/core/false/to_s_spec.rb +1 -3
  87. data/{core_spec → spec}/core/false/xor_spec.rb +1 -3
  88. data/{core_spec → spec}/core/hash/allocate_spec.rb +1 -3
  89. data/spec/core/hash/assoc_spec.rb +25 -0
  90. data/{core_spec → spec}/core/hash/clear_spec.rb +1 -3
  91. data/{core_spec → spec}/core/hash/clone_spec.rb +1 -3
  92. data/{core_spec → spec}/core/hash/default_spec.rb +1 -3
  93. data/{core_spec → spec}/core/hash/delete_if_spec.rb +1 -3
  94. data/{core_spec → spec}/core/hash/element_reference_spec.rb +1 -3
  95. data/{core_spec → spec}/core/hash/element_set_spec.rb +1 -3
  96. data/spec/core/hash/merge_spec.rb +37 -0
  97. data/{core_spec → spec}/core/hash/new_spec.rb +1 -3
  98. data/{core_spec → spec}/core/matchdata/to_a_spec.rb +1 -3
  99. data/{core_spec → spec}/core/nil/and_spec.rb +1 -4
  100. data/{core_spec → spec}/core/nil/inspect_spec.rb +1 -4
  101. data/{core_spec → spec}/core/nil/nil_spec.rb +1 -4
  102. data/{core_spec → spec}/core/nil/or_spec.rb +1 -4
  103. data/{core_spec → spec}/core/nil/to_a_spec.rb +1 -4
  104. data/{core_spec → spec}/core/nil/to_f_spec.rb +1 -4
  105. data/{core_spec → spec}/core/nil/to_i_spec.rb +1 -4
  106. data/{core_spec → spec}/core/nil/to_s_spec.rb +1 -4
  107. data/{core_spec → spec}/core/nil/xor_spec.rb +1 -4
  108. data/{core_spec → spec}/core/numeric/equal_value_spec.rb +1 -3
  109. data/{core_spec → spec}/core/regexp/match_spec.rb +10 -3
  110. data/{core_spec → spec}/core/symbol/to_proc_spec.rb +1 -3
  111. data/{core_spec → spec}/core/true/and_spec.rb +1 -3
  112. data/{core_spec → spec}/core/true/inspect_spec.rb +1 -3
  113. data/{core_spec → spec}/core/true/or_spec.rb +1 -3
  114. data/{core_spec → spec}/core/true/to_s_spec.rb +1 -3
  115. data/{core_spec → spec}/core/true/xor_spec.rb +1 -3
  116. data/spec/index.html +11 -0
  117. data/{core_spec → spec}/language/alias_spec.rb +1 -3
  118. data/{core_spec → spec}/language/and_spec.rb +1 -4
  119. data/{core_spec → spec}/language/array_spec.rb +1 -4
  120. data/{core_spec → spec}/language/block_spec.rb +20 -3
  121. data/{core_spec → spec}/language/break_spec.rb +40 -3
  122. data/{core_spec → spec}/language/case_spec.rb +1 -4
  123. data/{core_spec → spec}/language/defined_spec.rb +9 -3
  124. data/{core_spec → spec}/language/ensure_spec.rb +38 -3
  125. data/{core_spec → spec}/language/hash_spec.rb +1 -3
  126. data/{core_spec → spec}/language/if_spec.rb +1 -4
  127. data/{core_spec → spec}/language/loop_spec.rb +1 -3
  128. data/spec/language/metaclass_spec.rb +13 -0
  129. data/{core_spec → spec}/language/next_spec.rb +47 -3
  130. data/{core_spec → spec}/language/or_spec.rb +1 -4
  131. data/{core_spec → spec}/language/predefined_spec.rb +1 -3
  132. data/{core_spec/language/regexp/interpolation_spec.rb → spec/language/regexp_spec.rb} +6 -3
  133. data/{core_spec → spec}/language/send_spec.rb +38 -4
  134. data/spec/language/singleton_class_spec.rb +31 -0
  135. data/spec/language/super_spec.rb +188 -0
  136. data/{core_spec → spec}/language/symbol_spec.rb +1 -3
  137. data/{core_spec → spec}/language/undef_spec.rb +1 -3
  138. data/{core_spec → spec}/language/unless_spec.rb +1 -4
  139. data/{core_spec → spec}/language/until_spec.rb +1 -3
  140. data/{core_spec → spec}/language/variables_spec.rb +1 -3
  141. data/{core_spec → spec}/language/while_spec.rb +1 -3
  142. data/{spec → test}/builder/build_source_spec.rb +0 -0
  143. data/{spec → test}/builder/fixtures/build_source/adam.rb +0 -0
  144. data/{spec → test}/builder/fixtures/build_source/bar/a.rb +0 -0
  145. data/{spec → test}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
  146. data/{spec → test}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
  147. data/{spec → test}/builder/fixtures/build_source/beynon.rb +0 -0
  148. data/{spec → test}/builder/fixtures/build_source/charles.js +0 -0
  149. data/{spec → test}/builder/fixtures/build_source/foo/a.rb +0 -0
  150. data/{spec → test}/builder/fixtures/build_source/foo/b.rb +0 -0
  151. data/{spec → test}/builder/fixtures/build_source/foo/x.js +0 -0
  152. data/{spec → test}/builder/fixtures/build_source/foo/y.js +0 -0
  153. data/{spec → test}/grammar/alias_spec.rb +0 -0
  154. data/{spec → test}/grammar/and_spec.rb +0 -0
  155. data/{spec → test}/grammar/array_spec.rb +0 -0
  156. data/{spec → test}/grammar/attrasgn_spec.rb +0 -0
  157. data/{spec → test}/grammar/begin_spec.rb +0 -0
  158. data/{spec → test}/grammar/block_spec.rb +0 -0
  159. data/{spec → test}/grammar/break_spec.rb +0 -0
  160. data/{spec → test}/grammar/call_spec.rb +0 -0
  161. data/{spec → test}/grammar/class_spec.rb +0 -0
  162. data/{spec → test}/grammar/const_spec.rb +0 -0
  163. data/{spec → test}/grammar/cvar_spec.rb +0 -0
  164. data/{spec → test}/grammar/def_spec.rb +0 -0
  165. data/{spec → test}/grammar/false_spec.rb +0 -0
  166. data/{spec → test}/grammar/file_spec.rb +0 -0
  167. data/{spec → test}/grammar/gvar_spec.rb +0 -0
  168. data/{spec → test}/grammar/hash_spec.rb +0 -0
  169. data/{spec → test}/grammar/iasgn_spec.rb +0 -0
  170. data/{spec → test}/grammar/if_spec.rb +0 -0
  171. data/{spec → test}/grammar/iter_spec.rb +0 -0
  172. data/{spec → test}/grammar/ivar_spec.rb +0 -0
  173. data/{spec → test}/grammar/lasgn_spec.rb +0 -0
  174. data/{spec → test}/grammar/line_spec.rb +0 -0
  175. data/{spec → test}/grammar/lvar_spec.rb +0 -0
  176. data/{spec → test}/grammar/masgn_spec.rb +0 -0
  177. data/{spec → test}/grammar/module_spec.rb +0 -0
  178. data/{spec → test}/grammar/nil_spec.rb +0 -0
  179. data/{spec → test}/grammar/not_spec.rb +0 -0
  180. data/{spec → test}/grammar/op_asgn1_spec.rb +0 -0
  181. data/{spec → test}/grammar/op_asgn2_spec.rb +0 -0
  182. data/{spec → test}/grammar/or_spec.rb +0 -0
  183. data/{spec → test}/grammar/return_spec.rb +0 -0
  184. data/{spec → test}/grammar/sclass_spec.rb +0 -0
  185. data/{spec → test}/grammar/self_spec.rb +0 -0
  186. data/{spec → test}/grammar/str_spec.rb +0 -0
  187. data/{spec → test}/grammar/super_spec.rb +0 -0
  188. data/{spec → test}/grammar/true_spec.rb +0 -0
  189. data/{spec → test}/grammar/undef_spec.rb +0 -0
  190. data/{spec → test}/grammar/unless_spec.rb +0 -0
  191. data/{spec → test}/grammar/while_spec.rb +0 -0
  192. data/{spec → test}/grammar/xstr_spec.rb +0 -0
  193. data/{spec → test}/grammar/yield_spec.rb +0 -0
  194. data/{spec → test}/spec_helper.rb +0 -0
  195. metadata +330 -264
  196. data/core/debug.js +0 -59
  197. data/core/debug.rb +0 -35
  198. data/core/dir.rb +0 -90
  199. data/core/file.rb +0 -83
  200. data/core/gemlib.rb +0 -30
  201. data/core/io.rb +0 -44
  202. data/core_spec/README.md +0 -34
  203. data/core_spec/core/array/collect_spec.rb +0 -3
  204. data/core_spec/core/array/element_set_spec.rb +0 -7
  205. data/core_spec/core/array/eql_spec.rb +0 -3
  206. data/core_spec/core/array/equal_value_spec.rb +0 -3
  207. data/core_spec/core/array/fixtures/classes.rb +0 -8
  208. data/core_spec/core/array/length_spec.rb +0 -3
  209. data/core_spec/core/array/map_spec.rb +0 -3
  210. data/core_spec/core/array/replace_spec.rb +0 -3
  211. data/core_spec/core/enumerable/collect_spec.rb +0 -3
  212. data/core_spec/core/enumerable/detect_spec.rb +0 -3
  213. data/core_spec/core/enumerable/find_spec.rb +0 -3
  214. data/core_spec/core/enumerable/first_spec.rb +0 -3
  215. data/core_spec/core/enumerable/shared/entries.rb +0 -7
  216. data/core_spec/core/enumerable/shared/find.rb +0 -49
  217. data/core_spec/core/enumerable/shared/take.rb +0 -31
  218. data/core_spec/core/enumerable/to_a_spec.rb +0 -7
  219. data/core_spec/core/hash/assoc_spec.rb +0 -29
  220. data/core_spec/core/object/is_a_spec.rb +0 -2
  221. data/core_spec/core/object/shared/kind_of.rb +0 -0
  222. data/core_spec/core/regexp/shared/match.rb +0 -11
  223. data/core_spec/language/fixtures/block.rb +0 -19
  224. data/core_spec/language/fixtures/break.rb +0 -39
  225. data/core_spec/language/fixtures/defined.rb +0 -9
  226. data/core_spec/language/fixtures/ensure.rb +0 -37
  227. data/core_spec/language/fixtures/next.rb +0 -46
  228. data/core_spec/language/fixtures/send.rb +0 -36
  229. data/core_spec/language/fixtures/super.rb +0 -43
  230. data/core_spec/language/regexp_spec.rb +0 -7
  231. data/core_spec/language/string_spec.rb +0 -4
  232. data/core_spec/language/super_spec.rb +0 -18
  233. data/core_spec/language/versions/hash_1.9.rb +0 -20
  234. data/core_spec/opal/opal/defined_spec.rb +0 -15
  235. data/core_spec/opal/opal/function_spec.rb +0 -11
  236. data/core_spec/opal/opal/native_spec.rb +0 -16
  237. data/core_spec/opal/opal/null_spec.rb +0 -10
  238. data/core_spec/opal/opal/number_spec.rb +0 -11
  239. data/core_spec/opal/opal/object_spec.rb +0 -16
  240. data/core_spec/opal/opal/string_spec.rb +0 -11
  241. data/core_spec/opal/opal/typeof_spec.rb +0 -9
  242. data/core_spec/opal/opal/undefined_spec.rb +0 -10
  243. data/core_spec/opal/true/case_compare_spec.rb +0 -12
  244. data/core_spec/opal/true/class_spec.rb +0 -10
  245. data/core_spec/release_runner.html +0 -17
  246. data/core_spec/runner.html +0 -16
  247. data/core_spec/spec_helper.rb +0 -23
  248. data/lib/opal/context.rb +0 -269
  249. data/lib/opal/dependency_builder.rb +0 -133
  250. data/lib/opal/environment.rb +0 -87
  251. data/lib/opal/parser/sexp.rb +0 -17
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "FalseClass#^" do
4
2
  it "returns false if other is nil or false, otherwise true" do
5
3
  (false ^ false).should == false
@@ -8,4 +6,4 @@ describe "FalseClass#^" do
8
6
  (false ^ "").should == true
9
7
  (false ^ mock('x')).should == true
10
8
  end
11
- end
9
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash.allocate" do
4
2
  it "returns an instance of Hash" do
5
3
  hsh = Hash.allocate
@@ -12,4 +10,4 @@ describe "Hash.allocate" do
12
10
  hsh[:a] = 1
13
11
  hsh.should == { :a => 1 }
14
12
  end
15
- end
13
+ end
@@ -0,0 +1,25 @@
1
+ describe "Hash#assoc" do
2
+ before(:each) do
3
+ @h = {:apple => :green, :orange => :orange, :grape => :green, :banana => :yellow}
4
+ end
5
+
6
+ it "returns an Array is the argument is == to a key of the Hash" do
7
+ @h.assoc(:apple).should be_kind_of(Array)
8
+ end
9
+
10
+ it "returns a 2-element Array if the argument is == to a key of the Hash" do
11
+ @h.assoc(:grape).size.should == 2
12
+ end
13
+
14
+ it "sets the first element of the Array to the located key" do
15
+ @h.assoc(:banana).first.should == :banana
16
+ end
17
+
18
+ it "sets the last element of the Array to the value of the located key" do
19
+ @h.assoc(:banana).last.should == :yellow
20
+ end
21
+
22
+ it "returns nil if the argument if not a key of the Hash" do
23
+ @h.assoc(:green).should be_nil
24
+ end
25
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#clear" do
4
2
  it "removes all key, value pairs" do
5
3
  h = {1 => 2, 3 => 4}
@@ -18,4 +16,4 @@ describe "Hash#clear" do
18
16
  h.clear
19
17
  h["z"].should == "Go fish"
20
18
  end
21
- end
19
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#clone" do
4
2
  it "copies instance variable but not the objects they refer to" do
5
3
  hash = {'key' => 'value'}
@@ -9,4 +7,4 @@ describe "Hash#clone" do
9
7
  clone.should == hash
10
8
  clone.object_id.should_not == hash.object_id
11
9
  end
12
- end
10
+ end
@@ -1,6 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#default" do
4
2
  it "returns the default value" do
5
3
  end
6
- end
4
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#delete_if" do
4
2
  it "yields two arguments: key and value" do
5
3
  all_args = []
@@ -12,4 +10,4 @@ describe "Hash#delete_if" do
12
10
  h.delete_if { |k,v| v % 2 == 1 }.should equal(h)
13
11
  h.should == {:b => 2, :d => 4}
14
12
  end
15
- end
13
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#[]" do
4
2
  it "returns the value for the key" do
5
3
  obj = Object.new
@@ -13,4 +11,4 @@ describe "Hash#[]" do
13
11
  it "returns nil as default default value" do
14
12
  {0 => 0}[5].should == nil
15
13
  end
16
- end
14
+ end
@@ -1,8 +1,6 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash#[]=" do
4
2
  it "associates the key with the value and return the value" do
5
3
  h = {:a => 1}
6
4
  (h[:b] = 2).should == 2
7
5
  end
8
- end
6
+ end
@@ -0,0 +1,37 @@
1
+ describe "Hash#merge" do
2
+ it "returns a new hash by combining self with the contents of other" do
3
+ h = {1 => :a, 2 => :b, 3 => :c}.merge(:a => 1, :c => 2)
4
+ h.should == {:c => 2, 1 => :a, 2 => :b, :a => 1, 3 => :c}
5
+ end
6
+
7
+ it "sets any duplicate key to the value of the block if passed a block" do
8
+ h1 = {:a => 2, :b => 1, :d => 5}
9
+ h2 = {:a => -2, :b => 4, :c => -3}
10
+ r = h1.merge(h2) { |k,x,y| nil }
11
+ r.should == {:a => nil, :b => nil, :c => -3, :d => 5}
12
+
13
+ r = h1.merge(h2) { |k,x,y| "#{k}:#{x+2*y}" }
14
+ r.should == {:a => "a:-2", :b => "b:9", :c => -3, :d => 5}
15
+
16
+ r = h1.merge(h1) { |k,x,y| :x }
17
+ r.should == {:a => :x, :b => :x, :d => :x}
18
+ end
19
+ end
20
+
21
+ describe "Hash#merge" do
22
+ it "adds the entries from other, overwriting duplicate keys. Returns self" do
23
+ h = {:_1 => 'a', :_2 => '3'}
24
+ h.merge(:_1 => '9', :_9 => 2).should equal(h)
25
+ h.should == {:_1 => "9", :_2 => "3", :_9 => 2}
26
+ end
27
+
28
+ it "sets any duplicate key to the value of block if passed a block" do
29
+ h1 = {:a => 2, :b => -1}
30
+ h2 = {:a => -2, :c => 1}
31
+ h1.merge(h2) { |k,x,y| 3.14 }.should equal(h1)
32
+ h1.should == {:c => 1, :b => -1, :a => 3.14}
33
+
34
+ h1.merge(h1) { nil }
35
+ h1.should == {:a => nil, :b => nil, :c => nil}
36
+ end
37
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Hash.new" do
4
2
  it "creates an empty Hash if passed no arguments" do
5
3
  Hash.new.should == {}
@@ -10,4 +8,4 @@ describe "Hash.new" do
10
8
  Hash.new(5).default.should == 5
11
9
  Hash.new({}).default.should == {}
12
10
  end
13
- end
11
+ end
@@ -1,7 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "MatchData#to_a" do
4
2
  it "returns an array of matches" do
5
3
  /(.)(.)(\d+)(\d)/.match("THX1138").to_a.should == ["HX1138", "H", "X", "113", "8"]
6
4
  end
7
- end
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#&" do
4
2
  it "returns false" do
5
3
  (nil & nil).should == false
@@ -8,5 +6,4 @@ describe "NilClass#&" do
8
6
  (nil & "").should == false
9
7
  (nil & mock('x')).should == false
10
8
  end
11
- end
12
-
9
+ end
@@ -1,8 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#inspect" do
4
2
  it "returns the string 'nil'" do
5
3
  nil.inspect.should == "nil"
6
4
  end
7
- end
8
-
5
+ end
@@ -1,8 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#nil?" do
4
2
  it "returns true" do
5
3
  nil.nil?.should == true
6
4
  end
7
- end
8
-
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#|" do
4
2
  it "returns false if other is nil or false, otherwise true" do
5
3
  (nil | nil).should == false
@@ -8,5 +6,4 @@ describe "NilClass#|" do
8
6
  (nil | "").should == true
9
7
  (nil | 'x').should == true
10
8
  end
11
- end
12
-
9
+ end
@@ -1,8 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#to_a" do
4
2
  it "returns an empty array" do
5
3
  nil.to_a.should == []
6
4
  end
7
- end
8
-
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#to_f" do
4
2
  it "returns 0.0" do
5
3
  nil.to_f.should == 0.0
@@ -8,5 +6,4 @@ describe "NilClass#to_f" do
8
6
  it "does not cause NilClass to be coerced to Float" do
9
7
  (0.0 == nil).should == false
10
8
  end
11
- end
12
-
9
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#to_i" do
4
2
  it "returns 0" do
5
3
  nil.to_i.should == 0
@@ -8,5 +6,4 @@ describe "NilClass#to_i" do
8
6
  it "does not cause NilClass to be coerced to Fixnum" do
9
7
  (0 == nil).should == false
10
8
  end
11
- end
12
-
9
+ end
@@ -1,8 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#to_s" do
4
2
  it "returns the string ''" do
5
3
  nil.to_s.should == ""
6
4
  end
7
- end
8
-
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "NilClass#^" do
4
2
  it "returns false if other is nil or false, otherwise true" do
5
3
  (nil ^ nil).should == false
@@ -8,5 +6,4 @@ describe "NilClass#^" do
8
6
  (nil ^ "").should == true
9
7
  (nil ^ 'x').should == true
10
8
  end
11
- end
12
-
9
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Numeric#==" do
4
2
  it "returns true if self has the same value as other" do
5
3
  (1 == 1).should == true
@@ -8,4 +6,4 @@ describe "Numeric#==" do
8
6
  (9 == 9.0).should == true
9
7
  (9 == 9.01).should == false
10
8
  end
11
- end
9
+ end
@@ -1,6 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../shared/match', __FILE__)
3
-
4
1
  describe "Regexp#=~ on a successful match" do
5
2
  it "returns the index of the first character of the matching region" do
6
3
  (/(.)(.)(.)/ =~ "abc").should == 0
@@ -21,3 +18,13 @@ describe "Regexp#match on a successful match" do
21
18
  $~.should be_nil
22
19
  end
23
20
  end
21
+
22
+ describe :regexp_match do
23
+ it "returns nil if there is no match" do
24
+ /xyz/.match("abxyc").should be_nil
25
+ end
26
+
27
+ it "returns nil if the object is nil" do
28
+ /xyz/.match(nil).should be_nil
29
+ end
30
+ end
@@ -1,8 +1,6 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "Symbol#to_proc" do
4
2
  it "returns a new Proc" do
5
3
  proc = :to_s.to_proc
6
4
  proc.should be_kind_of(Proc)
7
5
  end
8
- end
6
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "TrueClass#&" do
4
2
  it "returns false if other is nil or false, otherwise true" do
5
3
  (true & true).should == true
@@ -8,4 +6,4 @@ describe "TrueClass#&" do
8
6
  (true & "").should == true
9
7
  (true & mock('x')).should == true
10
8
  end
11
- end
9
+ end
@@ -1,7 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "TrueClass#inspect" do
4
2
  it "returns the string 'true'" do
5
3
  true.inspect.should == "true"
6
4
  end
7
- end
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "TrueClass#|" do
4
2
  it "returns true" do
5
3
  (true | true).should == true
@@ -8,4 +6,4 @@ describe "TrueClass#|" do
8
6
  (true | "").should == true
9
7
  (true | mock('x')).should == true
10
8
  end
11
- end
9
+ end
@@ -1,7 +1,5 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "TrueClass#to_s" do
4
2
  it "returns the string 'true'" do
5
3
  true.to_s.should == "true"
6
4
  end
7
- end
5
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
1
  describe "TrueClass#^" do
4
2
  it "returns true if other is nil or false, otherwise false" do
5
3
  (true ^ true).should == false
@@ -8,4 +6,4 @@ describe "TrueClass#^" do
8
6
  (true ^ "").should == false
9
7
  (true ^ mock('x')).should == false
10
8
  end
11
- end
9
+ end
data/spec/index.html ADDED
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ </head>
6
+ <body>
7
+ <script type="text/javascript" src="../build/opal.js"></script>
8
+ <script type="text/javascript" src="../build/opal-spec.js"></script>
9
+ <script type="text/javascript" src="../build/opal.specs.js"></script>
10
+ </body>
11
+ </html>
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
1
  class AliasObject
4
2
  attr :foo
5
3
  attr_reader :baz
@@ -22,4 +20,4 @@ describe "The alias keyword" do
22
20
  end
23
21
  @obj.__value.should == 5
24
22
  end
25
- end
23
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
1
  describe "The '&&' statement" do
4
2
  it "short-circuits evaluation at the first condition to be false" do
5
3
  x = nil
@@ -58,5 +56,4 @@ describe "The 'and' statement" do
58
56
  (true and ()).should be_nil
59
57
  (() and ()).should be_nil
60
58
  end
61
- end
62
-
59
+ end
@@ -1,5 +1,3 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
1
  describe "Array literals" do
4
2
  it "[] should return a new array populated with the given elements" do
5
3
  array = [1, 'a', nil]
@@ -64,5 +62,4 @@ describe "The unpacking splat operator (*)" do
64
62
  splatted_array = [3, 4, 5]
65
63
  [1, 2, *splatted_array].should == [1, 2, 3, 4, 5]
66
64
  end
67
- end
68
-
65
+ end