opal 0.4.3 → 0.4.4

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 (303) hide show
  1. data/.rspec +3 -0
  2. data/.travis.yml +0 -4
  3. data/README.md +6 -0
  4. data/Rakefile +30 -6
  5. data/bin/opal +6 -82
  6. data/corelib/{opal/array.rb → array.rb} +40 -56
  7. data/corelib/{opal/basic_object.rb → basic_object.rb} +2 -2
  8. data/corelib/{opal/boolean.rb → boolean.rb} +0 -8
  9. data/corelib/class.rb +47 -0
  10. data/corelib/{opal/comparable.rb → comparable.rb} +0 -0
  11. data/corelib/{opal/enumerable.rb → enumerable.rb} +208 -141
  12. data/corelib/{opal/enumerator.rb → enumerator.rb} +3 -3
  13. data/corelib/{opal/error.rb → error.rb} +1 -0
  14. data/corelib/{opal/hash.rb → hash.rb} +67 -56
  15. data/corelib/io.rb +39 -0
  16. data/corelib/{opal/kernel.rb → kernel.rb} +35 -31
  17. data/corelib/{opal/class.rb → module.rb} +29 -57
  18. data/corelib/native.rb +148 -0
  19. data/corelib/{opal/nil_class.rb → nil_class.rb} +2 -10
  20. data/corelib/{opal/numeric.rb → numeric.rb} +39 -14
  21. data/corelib/opal.rb +42 -25
  22. data/corelib/{opal/proc.rb → proc.rb} +3 -3
  23. data/corelib/{opal/range.rb → range.rb} +5 -1
  24. data/corelib/{opal/regexp.rb → regexp.rb} +0 -0
  25. data/corelib/{opal/runtime.js → runtime.js} +96 -188
  26. data/corelib/{opal/string.rb → string.rb} +20 -15
  27. data/corelib/struct.rb +139 -0
  28. data/corelib/{opal/time.rb → time.rb} +0 -0
  29. data/lib/opal.rb +4 -0
  30. data/lib/opal/cli.rb +79 -32
  31. data/lib/opal/cli_options.rb +91 -0
  32. data/lib/opal/erb.rb +41 -8
  33. data/lib/opal/grammar.rb +24 -10
  34. data/lib/opal/grammar.y +15 -4
  35. data/lib/opal/grammar_helpers.rb +4 -0
  36. data/lib/opal/lexer.rb +214 -143
  37. data/lib/opal/parser.rb +596 -562
  38. data/lib/opal/require_parser.rb +1 -1
  39. data/lib/opal/source_map.rb +15 -30
  40. data/lib/opal/target_scope.rb +24 -5
  41. data/lib/opal/version.rb +1 -1
  42. data/mri_spec/cli_spec.rb +18 -0
  43. data/mri_spec/fixtures/opal_file.rb +2 -0
  44. data/mri_spec/spec_helper.rb +17 -0
  45. data/opal.gemspec +5 -2
  46. data/spec/{rubyspec/filters → filters}/bugs/alias.rb +0 -0
  47. data/spec/{rubyspec/filters → filters}/bugs/ancestors.rb +0 -0
  48. data/spec/{rubyspec/filters → filters}/bugs/array.rb +0 -0
  49. data/spec/filters/bugs/array/combination.rb +11 -0
  50. data/spec/filters/bugs/array/count.rb +3 -0
  51. data/spec/filters/bugs/array/delete_if.rb +3 -0
  52. data/spec/filters/bugs/array/drop.rb +3 -0
  53. data/spec/filters/bugs/array/drop_while.rb +5 -0
  54. data/spec/filters/bugs/array/eql.rb +3 -0
  55. data/spec/filters/bugs/array/flatten.rb +9 -0
  56. data/spec/filters/bugs/array/minus.rb +5 -0
  57. data/spec/filters/bugs/array/multipliy.rb +9 -0
  58. data/spec/filters/bugs/array/new.rb +3 -0
  59. data/spec/filters/bugs/array/pop.rb +6 -0
  60. data/spec/filters/bugs/array/rassoc.rb +4 -0
  61. data/spec/filters/bugs/array/rindex.rb +6 -0
  62. data/spec/filters/bugs/array/select.rb +3 -0
  63. data/spec/filters/bugs/array/shift.rb +7 -0
  64. data/spec/filters/bugs/array/shuffle.rb +11 -0
  65. data/spec/filters/bugs/array/slice.rb +7 -0
  66. data/spec/filters/bugs/array/take.rb +3 -0
  67. data/spec/filters/bugs/array/to_a.rb +3 -0
  68. data/spec/filters/bugs/array/try_convert.rb +7 -0
  69. data/spec/filters/bugs/array/uniq.rb +10 -0
  70. data/spec/filters/bugs/array/zip.rb +4 -0
  71. data/spec/{rubyspec/filters → filters}/bugs/array_delete.rb +1 -0
  72. data/spec/{rubyspec/filters → filters}/bugs/array_fetch.rb +0 -0
  73. data/spec/{rubyspec/filters → filters}/bugs/array_first.rb +0 -0
  74. data/spec/{rubyspec/filters → filters}/bugs/array_flatten.rb +0 -0
  75. data/spec/{rubyspec/filters → filters}/bugs/array_intersection.rb +0 -0
  76. data/spec/{rubyspec/filters → filters}/bugs/array_join.rb +0 -0
  77. data/spec/{rubyspec/filters → filters}/bugs/break.rb +0 -0
  78. data/spec/filters/bugs/case.rb +4 -0
  79. data/spec/{rubyspec/filters → filters}/bugs/coerce_integer.rb +0 -0
  80. data/spec/filters/bugs/enumerable_sort_by.rb +3 -0
  81. data/spec/{rubyspec/filters → filters}/bugs/kernel/instance_variables.rb +0 -0
  82. data/spec/filters/bugs/kernel/rand.rb +4 -0
  83. data/spec/filters/bugs/language/array.rb +3 -0
  84. data/spec/filters/bugs/language/block.rb +6 -0
  85. data/spec/filters/bugs/language/break.rb +3 -0
  86. data/spec/{rubyspec/filters → filters}/bugs/language/class.rb +3 -0
  87. data/spec/{rubyspec/filters → filters}/bugs/language/class_variables.rb +0 -0
  88. data/spec/filters/bugs/language/def.rb +27 -0
  89. data/spec/filters/bugs/language/defined.rb +3 -0
  90. data/spec/filters/bugs/language/ensure.rb +4 -0
  91. data/spec/filters/bugs/language/execution.rb +4 -0
  92. data/spec/filters/bugs/language/for.rb +18 -0
  93. data/spec/filters/bugs/language/if.rb +13 -0
  94. data/spec/filters/bugs/language/loop.rb +4 -0
  95. data/spec/filters/bugs/language/metaclass.rb +14 -0
  96. data/spec/filters/bugs/language/module.rb +6 -0
  97. data/spec/filters/bugs/language/next.rb +3 -0
  98. data/spec/filters/bugs/language/or.rb +3 -0
  99. data/spec/filters/bugs/language/order.rb +4 -0
  100. data/spec/filters/bugs/language/precedence.rb +10 -0
  101. data/spec/filters/bugs/language/proc.rb +24 -0
  102. data/spec/filters/bugs/language/redo.rb +5 -0
  103. data/spec/filters/bugs/language/rescue.rb +9 -0
  104. data/spec/filters/bugs/language/retry.rb +5 -0
  105. data/spec/filters/bugs/language/send.rb +10 -0
  106. data/spec/filters/bugs/language/super.rb +9 -0
  107. data/spec/filters/bugs/language/until.rb +8 -0
  108. data/spec/filters/bugs/language/variables.rb +37 -0
  109. data/spec/filters/bugs/language/while.rb +6 -0
  110. data/spec/filters/bugs/language/yield.rb +5 -0
  111. data/spec/{rubyspec/filters → filters}/bugs/module/class_variables.rb +0 -0
  112. data/spec/filters/bugs/module/method_defined.rb +6 -0
  113. data/spec/filters/bugs/parser.rb +10 -0
  114. data/spec/{rubyspec/filters → filters}/bugs/public_methods.rb +1 -0
  115. data/spec/filters/bugs/return.rb +7 -0
  116. data/spec/filters/bugs/singleton/instance.rb +4 -0
  117. data/spec/filters/bugs/source_map.rb +3 -0
  118. data/spec/filters/bugs/string/center.rb +4 -0
  119. data/spec/filters/bugs/string/lines.rb +3 -0
  120. data/spec/{rubyspec/filters → filters}/mspec/mocks.rb +0 -0
  121. data/spec/{rubyspec/filters → filters}/mspec/ruby_exe.rb +0 -0
  122. data/spec/{rubyspec/filters → filters}/mspec/should_receive.rb +0 -0
  123. data/spec/{rubyspec/filters → filters}/parser/block_args.rb +0 -0
  124. data/spec/{rubyspec/filters → filters}/unsupported/array_subclasses.rb +1 -0
  125. data/spec/filters/unsupported/frozen.rb +32 -0
  126. data/spec/filters/unsupported/immutable_strings.rb +3 -0
  127. data/spec/filters/unsupported/tainted.rb +17 -0
  128. data/spec/filters/unsupported/trusted.rb +15 -0
  129. data/spec/opal/class/constants_spec.rb +7 -0
  130. data/spec/opal/erb/erb_spec.rb +7 -1
  131. data/spec/opal/erb/inline_block.opalerb +3 -0
  132. data/spec/opal/hash/allocate_spec.rb +16 -0
  133. data/spec/opal/hash/new_spec.rb +10 -0
  134. data/spec/opal/hash/to_s_spec.rb +9 -0
  135. data/spec/opal/kernel/instance_variable_defined_spec.rb +15 -0
  136. data/spec/opal/kernel/rand_spec.rb +5 -5
  137. data/spec/opal/kernel/respond_to_spec.rb +14 -1
  138. data/spec/opal/language/block_spec.rb +13 -0
  139. data/spec/opal/language/rescue_spec.rb +27 -0
  140. data/spec/opal/language/return_spec.rb +38 -0
  141. data/spec/opal/language/singleton_class_spec.rb +13 -0
  142. data/spec/opal/language/super_spec.rb +99 -0
  143. data/spec/opal/language/variables_spec.rb +20 -0
  144. data/spec/opal/module/attr_accessor_spec.rb +8 -0
  145. data/spec/opal/module/constants_spec.rb +2 -2
  146. data/spec/opal/native/alias_native_spec.rb +18 -0
  147. data/spec/opal/native/each_spec.rb +14 -0
  148. data/spec/opal/native/element_reference_spec.rb +14 -0
  149. data/spec/opal/native/method_missing_spec.rb +39 -0
  150. data/spec/opal/native/new_spec.rb +19 -0
  151. data/spec/opal/native/nil_spec.rb +14 -0
  152. data/spec/opal/runtime2/class_hierarchy_spec.rb +2 -2
  153. data/spec/opal/source_map_spec.rb +3 -7
  154. data/spec/ospec/main.rb.erb +2 -5
  155. data/spec/parser/alias_spec.rb +4 -4
  156. data/spec/parser/and_spec.rb +2 -2
  157. data/spec/parser/array_spec.rb +6 -6
  158. data/spec/parser/attrasgn_spec.rb +8 -8
  159. data/spec/parser/begin_spec.rb +11 -11
  160. data/spec/parser/block_spec.rb +3 -3
  161. data/spec/parser/break_spec.rb +4 -4
  162. data/spec/parser/call_spec.rb +50 -48
  163. data/spec/parser/class_spec.rb +2 -2
  164. data/spec/parser/const_spec.rb +1 -1
  165. data/spec/parser/cvar_spec.rb +1 -1
  166. data/spec/parser/def_spec.rb +5 -5
  167. data/spec/parser/gvar_spec.rb +2 -2
  168. data/spec/parser/hash_spec.rb +4 -4
  169. data/spec/parser/iasgn_spec.rb +3 -3
  170. data/spec/parser/if_spec.rb +6 -6
  171. data/spec/parser/iter_spec.rb +6 -6
  172. data/spec/parser/lambda_spec.rb +5 -5
  173. data/spec/parser/lasgn_spec.rb +2 -2
  174. data/spec/parser/line_spec.rb +2 -2
  175. data/spec/parser/lvar_spec.rb +5 -5
  176. data/spec/parser/masgn_spec.rb +1 -1
  177. data/spec/parser/module_spec.rb +2 -2
  178. data/spec/parser/not_spec.rb +4 -4
  179. data/spec/parser/op_asgn1_spec.rb +2 -2
  180. data/spec/parser/op_asgn2_spec.rb +2 -2
  181. data/spec/parser/or_spec.rb +2 -2
  182. data/spec/parser/parse_spec.rb +66 -0
  183. data/spec/parser/parser_spec.rb +32 -38
  184. data/spec/parser/regexp_spec.rb +4 -4
  185. data/spec/parser/return_spec.rb +4 -4
  186. data/spec/parser/sclass_spec.rb +4 -4
  187. data/spec/parser/str_spec.rb +3 -3
  188. data/spec/parser/super_spec.rb +6 -6
  189. data/spec/parser/undef_spec.rb +3 -3
  190. data/spec/parser/unless_spec.rb +4 -4
  191. data/spec/parser/while_spec.rb +3 -3
  192. data/spec/parser/xstr_spec.rb +3 -3
  193. data/spec/parser/yield_spec.rb +6 -6
  194. data/spec/rubyspec/core/array/drop_spec.rb +1 -1
  195. data/spec/rubyspec/core/array/keep_if_spec.rb +1 -3
  196. data/spec/rubyspec/core/array/length_spec.rb +1 -3
  197. data/spec/rubyspec/core/array/map_spec.rb +2 -6
  198. data/spec/rubyspec/core/array/minus_spec.rb +3 -3
  199. data/spec/rubyspec/core/array/multiply_spec.rb +14 -16
  200. data/spec/rubyspec/core/array/new_spec.rb +3 -5
  201. data/spec/rubyspec/core/array/plus_spec.rb +2 -2
  202. data/spec/rubyspec/core/array/pop_spec.rb +4 -4
  203. data/spec/rubyspec/core/array/rassoc_spec.rb +2 -2
  204. data/spec/rubyspec/core/array/reject_spec.rb +2 -6
  205. data/spec/rubyspec/core/array/replace_spec.rb +1 -3
  206. data/spec/rubyspec/core/array/reverse_each_spec.rb +1 -3
  207. data/spec/rubyspec/core/array/reverse_spec.rb +4 -4
  208. data/spec/rubyspec/core/array/rindex_spec.rb +1 -1
  209. data/spec/rubyspec/core/array/select_spec.rb +3 -7
  210. data/spec/rubyspec/core/array/shared/collect.rb +7 -0
  211. data/spec/rubyspec/core/array/shared/index.rb +1 -1
  212. data/spec/rubyspec/core/array/shared/keep_if.rb +3 -0
  213. data/spec/rubyspec/core/array/shared/length.rb +3 -0
  214. data/spec/rubyspec/core/array/shared/replace.rb +3 -0
  215. data/spec/rubyspec/core/array/shared/slice.rb +3 -0
  216. data/spec/rubyspec/core/array/shuffle_spec.rb +1 -1
  217. data/spec/rubyspec/core/array/size_spec.rb +1 -3
  218. data/spec/rubyspec/core/array/slice_spec.rb +4 -6
  219. data/spec/rubyspec/core/array/sort_spec.rb +2 -2
  220. data/spec/rubyspec/core/array/to_a_spec.rb +1 -1
  221. data/spec/rubyspec/core/array/try_convert_spec.rb +7 -7
  222. data/spec/rubyspec/core/array/uniq_spec.rb +7 -7
  223. data/spec/rubyspec/core/array/zip_spec.rb +1 -1
  224. data/spec/rubyspec/core/enumerable/collect_spec.rb +24 -0
  225. data/spec/rubyspec/core/enumerable/count_spec.rb +35 -19
  226. data/spec/rubyspec/core/enumerable/find_spec.rb +5 -0
  227. data/spec/rubyspec/core/hash/each_pair_spec.rb +7 -7
  228. data/spec/rubyspec/core/hash/each_spec.rb +13 -7
  229. data/spec/rubyspec/core/module/method_defined_spec.rb +4 -4
  230. data/spec/rubyspec/core/module/public_method_defined_spec.rb +19 -0
  231. data/spec/rubyspec/core/module/remove_const_spec.rb +23 -0
  232. data/spec/rubyspec/core/numeric/step_spec.rb +14 -0
  233. data/spec/rubyspec/core/string/center_spec.rb +43 -65
  234. data/spec/rubyspec/core/string/lines_spec.rb +1 -1
  235. data/spec/rubyspec/core/string/ljust_spec.rb +25 -9
  236. data/spec/rubyspec/core/string/rjust_spec.rb +26 -10
  237. data/spec/rubyspec/core/struct/fixtures/classes.rb +26 -0
  238. data/spec/rubyspec/core/struct/initialize_spec.rb +11 -0
  239. data/spec/rubyspec/core/struct/new_spec.rb +24 -0
  240. data/spec/rubyspec/fixtures/constants.rb +7 -0
  241. data/spec/rubyspec/language/break_spec.rb +1 -1
  242. data/spec/rubyspec/language/case_spec.rb +30 -30
  243. data/spec/rubyspec/language/def_spec.rb +34 -34
  244. data/spec/rubyspec/language/defined_spec.rb +2 -2
  245. data/spec/rubyspec/language/ensure_spec.rb +2 -2
  246. data/spec/rubyspec/language/execution_spec.rb +2 -2
  247. data/spec/rubyspec/language/for_spec.rb +17 -17
  248. data/spec/rubyspec/language/hash_spec.rb +3 -3
  249. data/spec/rubyspec/language/if_spec.rb +11 -11
  250. data/spec/rubyspec/language/loop_spec.rb +3 -3
  251. data/spec/rubyspec/language/metaclass_spec.rb +14 -14
  252. data/spec/rubyspec/language/module_spec.rb +6 -6
  253. data/spec/rubyspec/language/next_spec.rb +5 -5
  254. data/spec/rubyspec/language/not_spec.rb +1 -1
  255. data/spec/rubyspec/language/or_spec.rb +1 -1
  256. data/spec/rubyspec/language/order_spec.rb +3 -5
  257. data/spec/rubyspec/language/precedence_spec.rb +19 -19
  258. data/spec/rubyspec/language/proc_spec.rb +29 -29
  259. data/spec/rubyspec/language/redo_spec.rb +3 -5
  260. data/spec/rubyspec/language/rescue_spec.rb +7 -7
  261. data/spec/rubyspec/language/retry_spec.rb +2 -2
  262. data/spec/rubyspec/language/return_spec.rb +12 -12
  263. data/spec/rubyspec/language/send_spec.rb +9 -9
  264. data/spec/rubyspec/language/singleton_class_spec.rb +3 -4
  265. data/spec/rubyspec/language/super_spec.rb +7 -11
  266. data/spec/rubyspec/language/until_spec.rb +10 -10
  267. data/spec/rubyspec/language/variables_spec.rb +59 -67
  268. data/spec/rubyspec/language/versions/array_1.9.rb +1 -1
  269. data/spec/rubyspec/language/versions/block_1.9.rb +0 -0
  270. data/spec/rubyspec/language/versions/break_1.9.rb +0 -0
  271. data/spec/rubyspec/language/versions/literal_lambda_1.9.rb +12 -12
  272. data/spec/rubyspec/language/versions/send_1.9.rb +23 -23
  273. data/spec/rubyspec/language/versions/symbol_1.9.rb +2 -2
  274. data/spec/rubyspec/language/versions/variables_1.9.rb +1 -1
  275. data/spec/rubyspec/language/while_spec.rb +4 -4
  276. data/spec/rubyspec/language/yield_spec.rb +3 -3
  277. data/spec/rubyspec/library/erb/util/html_escape_spec.rb +10 -0
  278. data/spec/rubyspec/library/singleton/clone_spec.rb +8 -0
  279. data/spec/rubyspec/library/singleton/dup_spec.rb +8 -0
  280. data/spec/rubyspec/library/singleton/fixtures/classes.rb +18 -0
  281. data/spec/rubyspec/library/singleton/instance_spec.rb +30 -0
  282. data/spec/spec_helper.rb +214 -0
  283. data/stdlib/buffer.rb +40 -0
  284. data/stdlib/buffer/array.rb +66 -0
  285. data/stdlib/buffer/view.rb +70 -0
  286. data/stdlib/erb.rb +11 -20
  287. data/stdlib/forwardable.rb +71 -0
  288. data/stdlib/json.rb +78 -0
  289. data/stdlib/ostruct.rb +69 -0
  290. data/stdlib/rbconfig.rb +1 -0
  291. data/stdlib/singleton.rb +40 -0
  292. data/stdlib/stringio.rb +173 -0
  293. data/stdlib/template.rb +44 -0
  294. metadata +285 -79
  295. data/corelib/opal/native.rb +0 -31
  296. data/spec/opal/class/bridge_class_spec.rb +0 -39
  297. data/spec/opal/native_spec.rb +0 -209
  298. data/spec/ospec/runner.rb +0 -223
  299. data/spec/rubyspec/filters/bugs/block_args.rb +0 -3
  300. data/spec/rubyspec/filters/bugs/case.rb +0 -8
  301. data/spec/rubyspec/filters/bugs/language/module.rb +0 -3
  302. data/spec/rubyspec/filters/unsupported/frozen.rb +0 -4
  303. data/spec/rubyspec/filters/unsupported/tainted.rb +0 -7
@@ -46,7 +46,7 @@ describe "Array#+" do
46
46
  ([5, 6] + ArraySpecs::ToAryArray[1, 2]).should == [5, 6, 1, 2]
47
47
  end
48
48
 
49
- pending "does not get infected even if an original array is tainted" do
49
+ it "does not get infected even if an original array is tainted" do
50
50
  ([1, 2] + [3, 4]).tainted?.should be_false
51
51
  ([1, 2].taint + [3, 4]).tainted?.should be_false
52
52
  ([1, 2] + [3, 4].taint).tainted?.should be_false
@@ -54,7 +54,7 @@ describe "Array#+" do
54
54
  end
55
55
 
56
56
  ruby_version_is '1.9' do
57
- pending "does not infected even if an original array is untrusted" do
57
+ it "does not infected even if an original array is untrusted" do
58
58
  ([1, 2] + [3, 4]).untrusted?.should be_false
59
59
  ([1, 2].untrust + [3, 4]).untrusted?.should be_false
60
60
  ([1, 2] + [3, 4].untrust).untrusted?.should be_false
@@ -30,7 +30,7 @@ describe "Array#pop" do
30
30
  array.pop.should == [1, 'two', 3.0, array, array, array, array]
31
31
  end
32
32
 
33
- pending "keeps taint status" do
33
+ it "keeps taint status" do
34
34
  a = [1, 2].taint
35
35
  a.pop
36
36
  a.tainted?.should be_true
@@ -56,7 +56,7 @@ describe "Array#pop" do
56
56
  lambda { ArraySpecs.empty_frozen_array.pop }.should raise_error(RuntimeError)
57
57
  end
58
58
 
59
- pending "keeps untrusted status" do
59
+ it "keeps untrusted status" do
60
60
  a = [1, 2].untrust
61
61
  a.pop
62
62
  a.untrusted?.should be_true
@@ -173,7 +173,7 @@ describe "Array#pop" do
173
173
  end
174
174
 
175
175
  ruby_version_is '1.9' do
176
- pending "returns a trusted array even if the array is untrusted" do
176
+ it "returns a trusted array even if the array is untrusted" do
177
177
  ary = [1, 2].untrust
178
178
  ary.pop(2).untrusted?.should be_false
179
179
  ary.pop(0).untrusted?.should be_false
@@ -184,7 +184,7 @@ describe "Array#pop" do
184
184
  lambda { ArraySpecs.frozen_array.pop(0) }.should raise_error(RuntimeError)
185
185
  end
186
186
 
187
- pending "keeps untrusted status" do
187
+ it "keeps untrusted status" do
188
188
  a = [1, 2].untrust
189
189
  a.pop(2)
190
190
  a.untrusted?.should be_true
@@ -20,7 +20,7 @@ describe "Array#rassoc" do
20
20
  [[empty, array]].rassoc(array).should == [empty, array]
21
21
  end
22
22
 
23
- pending "calls elem == obj on the second element of each contained array" do
23
+ it "calls elem == obj on the second element of each contained array" do
24
24
  key = 'foobar'
25
25
  o = mock('foobar')
26
26
  def o.==(other); other == 'foobar'; end
@@ -28,7 +28,7 @@ describe "Array#rassoc" do
28
28
  [[1, :foobar], [2, o], [3, mock('foo')]].rassoc(key).should == [2, o]
29
29
  end
30
30
 
31
- pending "does not check the last element in each contained but speficically the second" do
31
+ it "does not check the last element in each contained but speficically the second" do
32
32
  key = 'foobar'
33
33
  o = mock('foobar')
34
34
  def o.==(other); other == 'foobar'; end
@@ -57,9 +57,7 @@ describe "Array#reject" do
57
57
  end
58
58
  end
59
59
 
60
- pending do
61
- it_behaves_like :enumeratorize, :reject
62
- end
60
+ it_behaves_like :enumeratorize, :reject
63
61
  end
64
62
 
65
63
  describe "Array#reject!" do
@@ -132,7 +130,5 @@ describe "Array#reject!" do
132
130
  end
133
131
  end
134
132
 
135
- pending do
136
- it_behaves_like :enumeratorize, :reject!
137
- end
133
+ it_behaves_like :enumeratorize, :reject!
138
134
  end
@@ -3,7 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__)
3
3
  require File.expand_path('../shared/replace', __FILE__)
4
4
 
5
5
  describe "Array#replace" do
6
- pending do
7
- it_behaves_like(:array_replace, :replace)
8
- end
6
+ it_behaves_like(:array_replace, :replace)
9
7
  end
@@ -33,7 +33,5 @@ describe "Array#reverse_each" do
33
33
  ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1]
34
34
  end
35
35
 
36
- pending do
37
- it_behaves_like :enumeratorize, :reverse_each
38
- end
36
+ it_behaves_like :enumeratorize, :reverse_each
39
37
  end
@@ -7,7 +7,7 @@ describe "Array#reverse" do
7
7
  [1, 3, 5, 2].reverse.should == [2, 5, 3, 1]
8
8
  end
9
9
 
10
- pending "properly handles recursive arrays" do
10
+ it "properly handles recursive arrays" do
11
11
  empty = ArraySpecs.empty_recursive_array
12
12
  empty.reverse.should == empty
13
13
 
@@ -16,7 +16,7 @@ describe "Array#reverse" do
16
16
  end
17
17
 
18
18
  ruby_version_is "" ... "1.9.3" do
19
- pending "returns subclass instance on Array subclasses" do
19
+ it "returns subclass instance on Array subclasses" do
20
20
  ArraySpecs::MyArray[1, 2, 3].reverse.should be_kind_of(ArraySpecs::MyArray)
21
21
  end
22
22
  end
@@ -29,14 +29,14 @@ describe "Array#reverse" do
29
29
  end
30
30
 
31
31
  describe "Array#reverse!" do
32
- pending "reverses the elements in place" do
32
+ it "reverses the elements in place" do
33
33
  a = [6, 3, 4, 2, 1]
34
34
  a.reverse!.should equal(a)
35
35
  a.should == [1, 2, 4, 3, 6]
36
36
  [].reverse!.should == []
37
37
  end
38
38
 
39
- pending "properly handles recursive arrays" do
39
+ it "properly handles recursive arrays" do
40
40
  empty = ArraySpecs.empty_recursive_array
41
41
  empty.reverse!.should == [empty]
42
42
 
@@ -6,7 +6,7 @@ require File.expand_path('../fixtures/classes', __FILE__)
6
6
  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23633
7
7
 
8
8
  describe "Array#rindex" do
9
- pending "returns the first index backwards from the end where element == to object" do
9
+ it "returns the first index backwards from the end where element == to object" do
10
10
  key = 3
11
11
  uno = mock('one')
12
12
  dos = mock('two')
@@ -4,11 +4,9 @@ require File.expand_path('../shared/enumeratorize', __FILE__)
4
4
  require File.expand_path('../shared/keep_if', __FILE__)
5
5
 
6
6
  describe "Array#select" do
7
- pending do
8
- it_behaves_like :enumeratorize, :select
9
- end
7
+ it_behaves_like :enumeratorize, :select
10
8
 
11
- pending "returns a new array of elements for which block is true" do
9
+ it "returns a new array of elements for which block is true" do
12
10
  [1, 3, 4, 5, 6, 9].select { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
13
11
  end
14
12
 
@@ -33,8 +31,6 @@ ruby_version_is "1.9" do
33
31
  [1, 2, 3].select! { true }.should be_nil
34
32
  end
35
33
 
36
- pending do
37
- it_behaves_like :keep_if, :select!
38
- end
34
+ it_behaves_like :keep_if, :select!
39
35
  end
40
36
  end
@@ -0,0 +1,7 @@
1
+ describe :array_collect, :shared => true do
2
+
3
+ end
4
+
5
+ describe :array_collect_b, :shared => true do
6
+
7
+ end
@@ -32,6 +32,6 @@ describe :array_index, :shared => true do
32
32
  it "produces an Enumerator" do
33
33
  [].send(@method).should be_kind_of(enumerator_class)
34
34
  end
35
- end
35
+ end if false
36
36
  end
37
37
  end
@@ -0,0 +1,3 @@
1
+ describe :keep_if, :shared => true do
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ describe :array_length, :shared => true do
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ describe :array_replace, :shared => true do
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ describe :array_slice, :shared => true do
2
+
3
+ end
@@ -24,7 +24,7 @@ describe "Array#shuffle" do
24
24
  end
25
25
 
26
26
  ruby_version_is "1.8.7" ... "1.9.3" do
27
- pending "returns subclass instances with Array subclass" do
27
+ it "returns subclass instances with Array subclass" do
28
28
  ArraySpecs::MyArray[1, 2, 3].shuffle.should be_an_instance_of(ArraySpecs::MyArray)
29
29
  end
30
30
  end
@@ -3,7 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__)
3
3
  require File.expand_path('../shared/length', __FILE__)
4
4
 
5
5
  describe "Array#size" do
6
- pending do
7
- it_behaves_like(:array_length, :size)
8
- end
6
+ it_behaves_like(:array_length, :size)
9
7
  end
@@ -48,7 +48,7 @@ describe "Array#slice!" do
48
48
  array.slice(0..3).should == [1, 'two', 3.0, array]
49
49
  end
50
50
 
51
- pending "calls to_int on start and length arguments" do
51
+ it "calls to_int on start and length arguments" do
52
52
  obj = mock('2')
53
53
  def obj.to_int() 2 end
54
54
 
@@ -61,7 +61,7 @@ describe "Array#slice!" do
61
61
  a.should == []
62
62
  end
63
63
 
64
- pending "removes and return elements in range" do
64
+ it "removes and return elements in range" do
65
65
  a = [1, 2, 3, 4, 5, 6, 7, 8]
66
66
  a.slice!(1..4).should == [2, 3, 4, 5]
67
67
  a.should == [1, 6, 7, 8]
@@ -79,7 +79,7 @@ describe "Array#slice!" do
79
79
  a.should == []
80
80
  end
81
81
 
82
- pending "calls to_int on range arguments" do
82
+ it "calls to_int on range arguments" do
83
83
  from = mock('from')
84
84
  to = mock('to')
85
85
 
@@ -162,7 +162,5 @@ describe "Array#slice!" do
162
162
  end
163
163
 
164
164
  describe "Array#slice" do
165
- pending do
166
- it_behaves_like(:array_slice, :slice)
167
- end
165
+ it_behaves_like(:array_slice, :slice)
168
166
  end
@@ -96,7 +96,7 @@ describe "Array#sort" do
96
96
  a.sort { -1 }.should be_kind_of(Array)
97
97
  end
98
98
 
99
- pending "does not freezes self during being sorted" do
99
+ it "does not freezes self during being sorted" do
100
100
  a = [1, 2, 3]
101
101
  a.sort { |x,y| a.frozen?.should == false; x <=> y }
102
102
  end
@@ -159,7 +159,7 @@ describe "Array#sort" do
159
159
  end
160
160
 
161
161
  ruby_version_is "" ... "1.9.3" do
162
- pending "returns subclass instance on Array subclasses" do
162
+ it "returns subclass instance on Array subclasses" do
163
163
  ary = ArraySpecs::MyArray[1, 2, 3]
164
164
  ary.sort.should be_kind_of(ArraySpecs::MyArray)
165
165
  end
@@ -8,7 +8,7 @@ describe "Array#to_a" do
8
8
  a.should equal(a.to_a)
9
9
  end
10
10
 
11
- pending "does not return subclass instance on Array subclasses" do
11
+ it "does not return subclass instance on Array subclasses" do
12
12
  e = ArraySpecs::MyArray.new(1, 2)
13
13
  e.to_a.should be_an_instance_of(Array)
14
14
  e.to_a.should == [1, 2]
@@ -8,42 +8,42 @@ ruby_version_is "1.9" do
8
8
  Array.try_convert(x).should equal(x)
9
9
  end
10
10
 
11
- pending "returns the argument if it's a kind of Array" do
11
+ it "returns the argument if it's a kind of Array" do
12
12
  x = ArraySpecs::MyArray[]
13
13
  Array.try_convert(x).should equal(x)
14
14
  end
15
15
 
16
- pending "returns nil when the argument does not respond to #to_ary" do
16
+ it "returns nil when the argument does not respond to #to_ary" do
17
17
  Array.try_convert(Object.new).should be_nil
18
18
  end
19
19
 
20
- pending "sends #to_ary to the argument and returns the result if it's nil" do
20
+ it "sends #to_ary to the argument and returns the result if it's nil" do
21
21
  obj = mock("to_ary")
22
22
  obj.should_receive(:to_ary).and_return(nil)
23
23
  Array.try_convert(obj).should be_nil
24
24
  end
25
25
 
26
- pending "sends #to_ary to the argument and returns the result if it's an Array" do
26
+ it "sends #to_ary to the argument and returns the result if it's an Array" do
27
27
  x = Array.new
28
28
  obj = mock("to_ary")
29
29
  obj.should_receive(:to_ary).and_return(x)
30
30
  Array.try_convert(obj).should equal(x)
31
31
  end
32
32
 
33
- pending "sends #to_ary to the argument and returns the result if it's a kind of Array" do
33
+ it "sends #to_ary to the argument and returns the result if it's a kind of Array" do
34
34
  x = ArraySpecs::MyArray[]
35
35
  obj = mock("to_ary")
36
36
  obj.should_receive(:to_ary).and_return(x)
37
37
  Array.try_convert(obj).should equal(x)
38
38
  end
39
39
 
40
- pending "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do
40
+ it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do
41
41
  obj = mock("to_ary")
42
42
  obj.should_receive(:to_ary).and_return(Object.new)
43
43
  lambda { Array.try_convert obj }.should raise_error(TypeError)
44
44
  end
45
45
 
46
- pending "does not rescue exceptions raised by #to_ary" do
46
+ it "does not rescue exceptions raised by #to_ary" do
47
47
  obj = mock("to_ary")
48
48
  obj.should_receive(:to_ary).and_raise(RuntimeError)
49
49
  lambda { Array.try_convert obj }.should raise_error(RuntimeError)
@@ -16,7 +16,7 @@ describe "Array#uniq" do
16
16
  end
17
17
  end
18
18
 
19
- pending "uses eql? semantics" do
19
+ it "uses eql? semantics" do
20
20
  [1.0, 1].uniq.should == [1.0, 1]
21
21
  end
22
22
 
@@ -43,7 +43,7 @@ describe "Array#uniq" do
43
43
  [x, y].uniq.should == [x, y]
44
44
  end
45
45
 
46
- pending "compares elements with matching hash codes with #eql?" do
46
+ it "compares elements with matching hash codes with #eql?" do
47
47
  # Can't use should_receive because it uses hash and eql? internally
48
48
  a = Array.new(2) do
49
49
  obj = mock('0')
@@ -81,14 +81,14 @@ describe "Array#uniq" do
81
81
  end
82
82
 
83
83
  ruby_version_is "1.9" do
84
- pending "compares elements based on the value returned from the block" do
84
+ it "compares elements based on the value returned from the block" do
85
85
  a = [1, 2, 3, 4]
86
86
  a.uniq { |x| x >= 2 ? 1 : 0 }.should == [1, 2]
87
87
  end
88
88
  end
89
89
 
90
90
  ruby_version_is "" ... "1.9.3" do
91
- pending "returns subclass instance on Array subclasses" do
91
+ it "returns subclass instance on Array subclasses" do
92
92
  ArraySpecs::MyArray[1, 2, 3].uniq.should be_kind_of(ArraySpecs::MyArray)
93
93
  end
94
94
  end
@@ -113,7 +113,7 @@ describe "Array#uniq!" do
113
113
  end
114
114
 
115
115
  ruby_bug "#", "1.8.6.277" do
116
- pending "properly handles recursive arrays" do
116
+ it "properly handles recursive arrays" do
117
117
  empty = ArraySpecs.empty_recursive_array
118
118
  empty_dup = empty.dup
119
119
  empty.uniq!
@@ -143,7 +143,7 @@ describe "Array#uniq!" do
143
143
  end
144
144
 
145
145
  ruby_version_is "1.9" do
146
- pending "raises a RuntimeError on a frozen array when the array is modified" do
146
+ it "raises a RuntimeError on a frozen array when the array is modified" do
147
147
  dup_ary = [1, 1, 2]
148
148
  dup_ary.freeze
149
149
  lambda { dup_ary.uniq! }.should raise_error(RuntimeError)
@@ -159,7 +159,7 @@ describe "Array#uniq!" do
159
159
  lambda { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(RuntimeError)
160
160
  end
161
161
 
162
- pending "compares elements based on the value returned from the block" do
162
+ it "compares elements based on the value returned from the block" do
163
163
  a = [1, 2, 3, 4]
164
164
  a.uniq! { |x| x >= 2 ? 1 : 0 }.should == [1, 2]
165
165
  end
@@ -22,7 +22,7 @@ describe "Array#zip" do
22
22
  b.zip(b).should == [ [b[0], b[0]], [b[1], b[1]] ]
23
23
  end
24
24
 
25
- pending "calls #to_ary to convert the argument to an Array" do
25
+ it "calls #to_ary to convert the argument to an Array" do
26
26
  obj = mock('[3,4]')
27
27
  obj.should_receive(:to_ary).and_return([3, 4])
28
28
  [1, 2].zip(obj).should == [[1, 3], [2, 4]]
@@ -12,4 +12,28 @@ describe "Enumerable#collect" do
12
12
  numerous.collect { |i| i % 2 }.should == [0, 1, 1, 0, 1, 0]
13
13
  numerous.collect { |i| i }.should == entries
14
14
  end
15
+
16
+ ruby_version_is ""..."1.9" do
17
+ it "gathers whole arrays as elements when each yields multiple" do
18
+ multi = EnumerableSpecs::YieldsMulti.new
19
+ multi.send(@method) {|e| e}.should == [[1,2],[3,4,5],[6,7,8,9]]
20
+ end
21
+
22
+ it "returns to_a when no block given" do
23
+ EnumerableSpecs::Numerous.new.send(@method).should == [2, 5, 3, 6, 1, 4]
24
+ end
25
+ end
26
+
27
+ ruby_version_is "1.9" do
28
+ it "gathers initial args as elements when each yields multiple" do
29
+ multi = EnumerableSpecs::YieldsMulti.new
30
+ multi.collect {|e| e}.should == [1, 3, 6]
31
+ end
32
+
33
+ it "returns an enumerator when no block given" do
34
+ enum = EnumerableSpecs::Numerous.new.collect
35
+ enum.should be_an_instance_of(enumerator_class)
36
+ enum.each { |i| -i }.should == [-2, -5, -3, -6, -1, -4]
37
+ end
38
+ end
15
39
  end