opal 0.8.1 → 0.9.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (331) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.gitmodules +3 -3
  4. data/.jshintrc +17 -20
  5. data/.travis.yml +22 -11
  6. data/CHANGELOG.md +51 -1
  7. data/CODE_OF_CONDUCT.md +15 -0
  8. data/CONTRIBUTING.md +125 -9
  9. data/Gemfile +1 -1
  10. data/Guardfile +2 -2
  11. data/README.md +95 -29
  12. data/Rakefile +1 -1
  13. data/benchmark/benchmarks +103 -0
  14. data/benchmark/bm_array_flatten.rb +9 -0
  15. data/benchmark/bm_array_intersection_numbers.rb +7 -0
  16. data/benchmark/bm_array_intersection_objects.rb +7 -0
  17. data/benchmark/bm_array_intersection_strings.rb +7 -0
  18. data/benchmark/bm_array_join_ary.rb +9 -0
  19. data/benchmark/bm_array_minus_numbers.rb +7 -0
  20. data/benchmark/bm_array_minus_objects.rb +7 -0
  21. data/benchmark/bm_array_minus_strings.rb +7 -0
  22. data/benchmark/bm_array_union_numbers.rb +7 -0
  23. data/benchmark/bm_array_union_objects.rb +7 -0
  24. data/benchmark/bm_array_union_strings.rb +7 -0
  25. data/benchmark/bm_array_uniq_bang_numbers.rb +5 -0
  26. data/benchmark/bm_array_uniq_bang_objects.rb +5 -0
  27. data/benchmark/bm_array_uniq_bang_strings.rb +5 -0
  28. data/benchmark/bm_array_uniq_numbers.rb +5 -0
  29. data/benchmark/bm_array_uniq_objects.rb +5 -0
  30. data/benchmark/bm_array_uniq_strings.rb +5 -0
  31. data/benchmark/bm_dispatch_bind_table.rb +57 -0
  32. data/benchmark/bm_dispatch_code_gen.rb +65 -0
  33. data/benchmark/bm_dispatch_code_gen_if.rb +64 -0
  34. data/benchmark/bm_dispatch_hardcoded.rb +44 -0
  35. data/benchmark/bm_dispatch_send.rb +38 -0
  36. data/benchmark/bm_dispatch_send_table.rb +57 -0
  37. data/benchmark/bm_hash_assoc_object.rb +11 -0
  38. data/benchmark/bm_hash_assoc_string.rb +9 -0
  39. data/benchmark/bm_hash_clone_object.rb +9 -0
  40. data/benchmark/bm_hash_clone_string.rb +9 -0
  41. data/benchmark/bm_hash_delete_object.rb +11 -0
  42. data/benchmark/bm_hash_delete_string.rb +9 -0
  43. data/benchmark/bm_hash_each_key_object.rb +9 -0
  44. data/benchmark/bm_hash_each_key_string.rb +9 -0
  45. data/benchmark/bm_hash_each_object.rb +9 -0
  46. data/benchmark/bm_hash_each_string.rb +9 -0
  47. data/benchmark/bm_hash_each_value_object.rb +9 -0
  48. data/benchmark/bm_hash_each_value_string.rb +9 -0
  49. data/benchmark/bm_hash_element_reference_object.rb +11 -0
  50. data/benchmark/bm_hash_element_reference_string.rb +9 -0
  51. data/benchmark/bm_hash_element_set_object.rb +5 -0
  52. data/benchmark/bm_hash_element_set_string.rb +5 -0
  53. data/benchmark/bm_hash_equal_value_object.rb +14 -0
  54. data/benchmark/bm_hash_equal_value_string.rb +11 -0
  55. data/benchmark/bm_hash_fetch_object.rb +11 -0
  56. data/benchmark/bm_hash_fetch_string.rb +9 -0
  57. data/benchmark/bm_hash_flatten_object.rb +9 -0
  58. data/benchmark/bm_hash_flatten_string.rb +9 -0
  59. data/benchmark/bm_hash_has_key_object.rb +11 -0
  60. data/benchmark/bm_hash_has_key_string.rb +9 -0
  61. data/benchmark/bm_hash_has_value_object.rb +9 -0
  62. data/benchmark/bm_hash_has_value_string.rb +9 -0
  63. data/benchmark/bm_hash_hash_object.rb +9 -0
  64. data/benchmark/bm_hash_hash_string.rb +9 -0
  65. data/benchmark/bm_hash_inspect_object.rb +9 -0
  66. data/benchmark/bm_hash_inspect_string.rb +9 -0
  67. data/benchmark/bm_hash_invert_object.rb +9 -0
  68. data/benchmark/bm_hash_invert_string.rb +9 -0
  69. data/benchmark/bm_hash_keep_if_object.rb +9 -0
  70. data/benchmark/bm_hash_keep_if_string.rb +9 -0
  71. data/benchmark/bm_hash_key_object.rb +9 -0
  72. data/benchmark/bm_hash_key_string.rb +9 -0
  73. data/benchmark/bm_hash_keys_object.rb +9 -0
  74. data/benchmark/bm_hash_keys_string.rb +9 -0
  75. data/benchmark/bm_hash_literal_mixed_large.rb +3 -0
  76. data/benchmark/bm_hash_literal_mixed_small.rb +3 -0
  77. data/benchmark/bm_hash_literal_object_large.rb +4 -0
  78. data/benchmark/bm_hash_literal_object_small.rb +3 -0
  79. data/benchmark/bm_hash_literal_string_large.rb +4 -0
  80. data/benchmark/bm_hash_literal_string_small.rb +3 -0
  81. data/benchmark/bm_hash_merge_object.rb +22 -0
  82. data/benchmark/bm_hash_merge_string.rb +18 -0
  83. data/benchmark/bm_hash_rassoc_object.rb +9 -0
  84. data/benchmark/bm_hash_rassoc_string.rb +9 -0
  85. data/benchmark/bm_hash_rehash_object.rb +9 -0
  86. data/benchmark/bm_hash_rehash_string.rb +9 -0
  87. data/benchmark/bm_hash_reject_bang_object.rb +9 -0
  88. data/benchmark/bm_hash_reject_bang_string.rb +9 -0
  89. data/benchmark/bm_hash_reject_object.rb +9 -0
  90. data/benchmark/bm_hash_reject_string.rb +9 -0
  91. data/benchmark/bm_hash_replace_object.rb +18 -0
  92. data/benchmark/bm_hash_replace_string.rb +14 -0
  93. data/benchmark/bm_hash_select_bang_object.rb +9 -0
  94. data/benchmark/bm_hash_select_bang_string.rb +9 -0
  95. data/benchmark/bm_hash_select_object.rb +9 -0
  96. data/benchmark/bm_hash_select_string.rb +9 -0
  97. data/benchmark/bm_hash_shift_object.rb +10 -0
  98. data/benchmark/bm_hash_shift_string.rb +10 -0
  99. data/benchmark/bm_hash_to_a_object.rb +9 -0
  100. data/benchmark/bm_hash_to_a_string.rb +9 -0
  101. data/benchmark/bm_hash_to_h_object.rb +10 -0
  102. data/benchmark/bm_hash_to_h_string.rb +10 -0
  103. data/benchmark/bm_hash_values_object.rb +9 -0
  104. data/benchmark/bm_hash_values_string.rb +9 -0
  105. data/benchmark/run.rb +48 -0
  106. data/bin/opal-mspec +1 -1
  107. data/bin/opal-repl +4 -4
  108. data/docs/compiled_ruby.md +214 -56
  109. data/docs/configuring_gems.md +2 -2
  110. data/docs/faq.md +2 -2
  111. data/docs/getting_started.md +19 -2
  112. data/docs/jquery.md +5 -5
  113. data/docs/opal_parser.md +53 -0
  114. data/docs/unsupported_features.md +2 -2
  115. data/docs/upgrading.md +22 -0
  116. data/docs/using_sprockets.md +15 -0
  117. data/examples/rack/config.ru +13 -0
  118. data/examples/sinatra/config.ru +4 -5
  119. data/lib/mspec/opal/runner.rb +54 -11
  120. data/lib/opal.rb +1 -1
  121. data/lib/opal/builder.rb +1 -1
  122. data/lib/opal/builder_processors.rb +1 -1
  123. data/lib/opal/cli.rb +17 -13
  124. data/lib/opal/cli_options.rb +1 -1
  125. data/lib/opal/compiler.rb +12 -0
  126. data/lib/opal/config.rb +4 -0
  127. data/lib/opal/nodes/arglist.rb +5 -7
  128. data/lib/opal/nodes/call.rb +6 -1
  129. data/lib/opal/nodes/call_special.rb +74 -0
  130. data/lib/opal/nodes/def.rb +35 -28
  131. data/lib/opal/nodes/definitions.rb +3 -5
  132. data/lib/opal/nodes/for.rb +13 -0
  133. data/lib/opal/nodes/helpers.rb +15 -1
  134. data/lib/opal/nodes/if.rb +5 -5
  135. data/lib/opal/nodes/iter.rb +6 -1
  136. data/lib/opal/nodes/literal.rb +1 -1
  137. data/lib/opal/nodes/logic.rb +2 -2
  138. data/lib/opal/nodes/masgn.rb +1 -2
  139. data/lib/opal/nodes/module.rb +2 -1
  140. data/lib/opal/nodes/rescue.rb +10 -1
  141. data/lib/opal/nodes/scope.rb +8 -2
  142. data/lib/opal/nodes/singleton_class.rb +1 -1
  143. data/lib/opal/nodes/top.rb +11 -0
  144. data/lib/opal/nodes/variables.rb +4 -4
  145. data/lib/opal/parser.rb +21 -3
  146. data/lib/opal/parser/grammar.rb +3115 -2961
  147. data/lib/opal/parser/grammar.y +29 -6
  148. data/lib/opal/parser/lexer.rb +18 -8
  149. data/lib/opal/sprockets.rb +85 -0
  150. data/lib/opal/sprockets/processor.rb +11 -35
  151. data/lib/opal/sprockets/server.rb +3 -15
  152. data/lib/opal/version.rb +2 -2
  153. data/opal.gemspec +4 -4
  154. data/opal/README.md +9 -0
  155. data/opal/corelib/array.rb +433 -181
  156. data/opal/corelib/basic_object.rb +48 -4
  157. data/opal/corelib/boolean.rb +15 -6
  158. data/opal/corelib/class.rb +6 -5
  159. data/opal/corelib/comparable.rb +12 -0
  160. data/opal/corelib/complex.rb +282 -0
  161. data/opal/corelib/constants.rb +9 -0
  162. data/opal/corelib/enumerable.rb +83 -34
  163. data/opal/corelib/enumerator.rb +3 -1
  164. data/opal/corelib/error.rb +49 -10
  165. data/opal/corelib/file.rb +1 -0
  166. data/opal/corelib/hash.rb +353 -577
  167. data/opal/corelib/helpers.rb +20 -0
  168. data/opal/corelib/kernel.rb +114 -59
  169. data/opal/corelib/math.rb +470 -0
  170. data/opal/corelib/method.rb +11 -2
  171. data/opal/corelib/module.rb +96 -96
  172. data/opal/corelib/{nil_class.rb → nil.rb} +20 -1
  173. data/opal/corelib/number.rb +751 -0
  174. data/opal/corelib/numeric.rb +77 -437
  175. data/opal/corelib/proc.rb +81 -1
  176. data/opal/corelib/process.rb +27 -0
  177. data/opal/corelib/rational.rb +358 -0
  178. data/opal/corelib/regexp.rb +156 -27
  179. data/opal/corelib/runtime.js +724 -335
  180. data/opal/corelib/string.rb +93 -104
  181. data/opal/corelib/string/encoding.rb +177 -0
  182. data/opal/corelib/string/inheritance.rb +2 -0
  183. data/opal/corelib/struct.rb +105 -18
  184. data/opal/corelib/time.rb +267 -146
  185. data/opal/corelib/unsupported.rb +216 -0
  186. data/opal/corelib/variables.rb +0 -6
  187. data/opal/opal.rb +8 -22
  188. data/opal/opal/base.rb +9 -0
  189. data/opal/opal/mini.rb +17 -0
  190. data/spec/README.md +1 -1
  191. data/spec/filters/bugs/array.rb +38 -136
  192. data/spec/filters/bugs/{basic_object.rb → basicobject.rb} +14 -15
  193. data/spec/filters/bugs/class.rb +6 -12
  194. data/spec/filters/bugs/complex.rb +3 -0
  195. data/spec/filters/bugs/date.rb +162 -10
  196. data/spec/filters/bugs/enumerable.rb +31 -58
  197. data/spec/filters/bugs/enumerator.rb +42 -0
  198. data/spec/filters/bugs/exception.rb +66 -10
  199. data/spec/filters/bugs/float.rb +17 -0
  200. data/spec/filters/bugs/hash.rb +11 -97
  201. data/spec/filters/bugs/inheritance.rb +5 -0
  202. data/spec/filters/bugs/integer.rb +28 -0
  203. data/spec/filters/bugs/kernel.rb +304 -12
  204. data/spec/filters/bugs/language.rb +133 -399
  205. data/spec/filters/bugs/language_opal.rb +88 -0
  206. data/spec/filters/bugs/module.rb +203 -62
  207. data/spec/filters/bugs/numeric.rb +32 -0
  208. data/spec/filters/bugs/proc.rb +39 -0
  209. data/spec/filters/bugs/range.rb +148 -0
  210. data/spec/filters/bugs/regexp.rb +168 -0
  211. data/spec/filters/bugs/set.rb +46 -3
  212. data/spec/filters/bugs/singleton.rb +1 -2
  213. data/spec/filters/bugs/string.rb +59 -90
  214. data/spec/filters/bugs/strscan.rb +80 -0
  215. data/spec/filters/bugs/struct.rb +10 -20
  216. data/spec/filters/bugs/time.rb +17 -184
  217. data/spec/filters/bugs/unboundmethod.rb +22 -0
  218. data/spec/filters/unsupported/array.rb +163 -0
  219. data/spec/filters/unsupported/basicobject.rb +14 -0
  220. data/spec/filters/unsupported/bignum.rb +46 -0
  221. data/spec/filters/unsupported/class.rb +4 -0
  222. data/spec/filters/unsupported/delegator.rb +5 -0
  223. data/spec/filters/unsupported/enumerable.rb +11 -0
  224. data/spec/filters/unsupported/enumerator.rb +8 -9
  225. data/spec/filters/unsupported/fixnum.rb +14 -0
  226. data/spec/filters/unsupported/float.rb +41 -7
  227. data/spec/filters/unsupported/freeze.rb +45 -0
  228. data/spec/filters/unsupported/hash.rb +50 -0
  229. data/spec/filters/unsupported/integer.rb +3 -0
  230. data/spec/filters/unsupported/kernel.rb +31 -0
  231. data/spec/filters/unsupported/language.rb +17 -0
  232. data/spec/filters/unsupported/matchdata.rb +30 -0
  233. data/spec/filters/unsupported/math.rb +3 -0
  234. data/spec/filters/unsupported/module.rb +5 -3
  235. data/spec/filters/unsupported/pathname.rb +3 -0
  236. data/spec/filters/unsupported/privacy.rb +136 -0
  237. data/spec/filters/unsupported/proc.rb +3 -0
  238. data/spec/filters/unsupported/regexp.rb +59 -0
  239. data/spec/filters/unsupported/set.rb +4 -0
  240. data/spec/filters/unsupported/{marshal.rb → singleton.rb} +4 -2
  241. data/spec/filters/unsupported/{mutable_strings.rb → string.rb} +456 -336
  242. data/spec/filters/unsupported/struct.rb +3 -0
  243. data/spec/filters/unsupported/symbol.rb +5 -0
  244. data/spec/filters/unsupported/taint.rb +16 -0
  245. data/spec/filters/unsupported/thread.rb +5 -0
  246. data/spec/filters/unsupported/time.rb +197 -16
  247. data/spec/lib/cli_spec.rb +14 -4
  248. data/spec/lib/compiler_spec.rb +9 -1
  249. data/spec/lib/parser/call_spec.rb +18 -0
  250. data/spec/lib/parser/not_spec.rb +2 -8
  251. data/spec/lib/sprockets_spec.rb +24 -0
  252. data/spec/opal/core/array/intersection_spec.rb +38 -0
  253. data/spec/opal/core/array/minus_spec.rb +38 -0
  254. data/spec/opal/core/array/union_spec.rb +38 -0
  255. data/spec/opal/core/array/uniq_spec.rb +49 -0
  256. data/spec/opal/core/exception_spec.rb +7 -0
  257. data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +1 -0
  258. data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +1 -0
  259. data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +1 -0
  260. data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +3 -0
  261. data/spec/opal/core/hash/internals_spec.rb +332 -0
  262. data/spec/opal/core/helpers_spec.rb +14 -0
  263. data/spec/opal/core/kernel/freeze_spec.rb +1 -1
  264. data/spec/opal/core/kernel/raise_spec.rb +13 -0
  265. data/spec/opal/core/kernel/require_tree_spec.rb +9 -0
  266. data/spec/opal/core/language/class_spec.rb +55 -0
  267. data/spec/opal/core/language/fixtures/send.rb +1 -0
  268. data/spec/opal/core/language/keyword_arguments_spec.rb +11 -0
  269. data/spec/opal/core/language/send_spec.rb +5 -0
  270. data/spec/opal/core/method/to_proc_spec.rb +28 -0
  271. data/spec/opal/core/module/name_spec.rb +0 -17
  272. data/spec/opal/core/runtime/bridged_classes_spec.rb +2 -2
  273. data/spec/opal/core/runtime/eval_spec.rb +1 -1
  274. data/spec/opal/core/runtime/method_missing_spec.rb +6 -0
  275. data/spec/opal/core/runtime_spec.rb +51 -0
  276. data/spec/opal/stdlib/js_spec.rb +66 -0
  277. data/spec/opal/stdlib/native/hash_spec.rb +36 -0
  278. data/spec/rubyspecs +152 -273
  279. data/spec/spec_helper.rb +10 -11
  280. data/stdlib/base64.rb +9 -9
  281. data/stdlib/benchmark.rb +551 -4
  282. data/stdlib/console.rb +94 -0
  283. data/stdlib/date.rb +1 -1
  284. data/stdlib/encoding.rb +1 -170
  285. data/stdlib/js.rb +56 -0
  286. data/stdlib/json.rb +9 -14
  287. data/stdlib/math.rb +1 -370
  288. data/stdlib/native.rb +133 -63
  289. data/stdlib/nodejs/file.rb +5 -0
  290. data/stdlib/nodejs/fileutils.rb +13 -6
  291. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +1 -1
  292. data/stdlib/opal-parser.rb +1 -2
  293. data/stdlib/ostruct.rb +65 -6
  294. data/stdlib/pp.rb +2 -4
  295. data/stdlib/rbconfig.rb +1 -3
  296. data/stdlib/strscan.rb +164 -28
  297. data/tasks/benchmarking.rake +88 -0
  298. data/tasks/testing.rake +181 -55
  299. data/{lib/mspec/opal/special_calls.rb → tasks/testing/mspec_special_calls.rb} +1 -1
  300. data/{lib/mspec/opal/sprockets.js → tasks/testing/phantomjs1-sprockets.js} +17 -6
  301. data/test/opal/test_keyword.rb +590 -0
  302. data/vendored-minitest/minitest.rb +2 -2
  303. data/vendored-minitest/test/unit.rb +5 -0
  304. metadata +229 -62
  305. data/benchmarks/operators.rb +0 -11
  306. data/benchmarks/prova.js.rb +0 -13
  307. data/docs/libraries.md +0 -36
  308. data/lib/mspec/opal/new.html.erb +0 -1
  309. data/lib/mspec/opal/rake_task.rb +0 -248
  310. data/opal/corelib/match_data.rb +0 -128
  311. data/spec/filters/bugs/math.rb +0 -95
  312. data/spec/filters/bugs/nil.rb +0 -7
  313. data/spec/filters/bugs/opal.rb +0 -9
  314. data/spec/filters/bugs/regular_expressions.rb +0 -41
  315. data/spec/filters/bugs/stringscanner.rb +0 -33
  316. data/spec/filters/unsupported/encoding.rb +0 -102
  317. data/spec/filters/unsupported/frozen.rb +0 -92
  318. data/spec/filters/unsupported/hash_compare_by_identity.rb +0 -16
  319. data/spec/filters/unsupported/integer_size.rb +0 -59
  320. data/spec/filters/unsupported/method_added.rb +0 -10
  321. data/spec/filters/unsupported/private_constants.rb +0 -30
  322. data/spec/filters/unsupported/private_methods.rb +0 -55
  323. data/spec/filters/unsupported/random.rb +0 -4
  324. data/spec/filters/unsupported/rational_numbers.rb +0 -4
  325. data/spec/filters/unsupported/regular_expressions.rb +0 -137
  326. data/spec/filters/unsupported/ruby_exe.rb +0 -5
  327. data/spec/filters/unsupported/symbols.rb +0 -17
  328. data/spec/filters/unsupported/tainted.rb +0 -180
  329. data/spec/filters/unsupported/trusted.rb +0 -88
  330. data/stdlib/process.rb +0 -10
  331. data/tasks/documenting.rake +0 -37
@@ -0,0 +1,216 @@
1
+ %x{
2
+ var warnings = {};
3
+
4
+ function warn(string) {
5
+ if (warnings[string]) {
6
+ return;
7
+ }
8
+
9
+ warnings[string] = true;
10
+ #{warn(`string`)};
11
+ }
12
+ }
13
+
14
+ class String
15
+ `var ERROR = "String#%s not supported. Mutable String methods are not supported in Opal.";`
16
+
17
+ def <<(*)
18
+ raise NotImplementedError, `ERROR` % '<<'
19
+ end
20
+
21
+ def capitalize!(*)
22
+ raise NotImplementedError, `ERROR` % 'capitalize!'
23
+ end
24
+
25
+ def chomp!(*)
26
+ raise NotImplementedError, `ERROR` % 'chomp!'
27
+ end
28
+
29
+ def chop!(*)
30
+ raise NotImplementedError, `ERROR` % 'chop!'
31
+ end
32
+
33
+ def downcase!(*)
34
+ raise NotImplementedError, `ERROR` % 'downcase!'
35
+ end
36
+
37
+ def gsub!(*)
38
+ raise NotImplementedError, `ERROR` % 'gsub!'
39
+ end
40
+
41
+ def lstrip!(*)
42
+ raise NotImplementedError, `ERROR` % 'lstrip!'
43
+ end
44
+
45
+ def next!(*)
46
+ raise NotImplementedError, `ERROR` % 'next!'
47
+ end
48
+
49
+ def reverse!(*)
50
+ raise NotImplementedError, `ERROR` % 'reverse!'
51
+ end
52
+
53
+ def slice!(*)
54
+ raise NotImplementedError, `ERROR` % 'slice!'
55
+ end
56
+
57
+ def squeeze!(*)
58
+ raise NotImplementedError, `ERROR` % 'squeeze!'
59
+ end
60
+
61
+ def strip!(*)
62
+ raise NotImplementedError, `ERROR` % 'strip!'
63
+ end
64
+
65
+ def sub!(*)
66
+ raise NotImplementedError, `ERROR` % 'sub!'
67
+ end
68
+
69
+ def succ!(*)
70
+ raise NotImplementedError, `ERROR` % 'succ!'
71
+ end
72
+
73
+ def swapcase!(*)
74
+ raise NotImplementedError, `ERROR` % 'swapcase!'
75
+ end
76
+
77
+ def tr!(*)
78
+ raise NotImplementedError, `ERROR` % 'tr!'
79
+ end
80
+
81
+ def tr_s!(*)
82
+ raise NotImplementedError, `ERROR` % 'tr_s!'
83
+ end
84
+
85
+ def upcase!(*)
86
+ raise NotImplementedError, `ERROR` % 'upcase!'
87
+ end
88
+ end
89
+
90
+ module Kernel
91
+ `var ERROR = "Object freezing is not supported by Opal";`
92
+
93
+ def freeze
94
+ if `OPAL_CONFIG.freezing`
95
+ `warn(ERROR)`
96
+ else
97
+ raise NotImplementedError, `ERROR`
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ def frozen?
104
+ if `OPAL_CONFIG.freezing`
105
+ `warn(ERROR)`
106
+ else
107
+ raise NotImplementedError, `ERROR`
108
+ end
109
+
110
+ false
111
+ end
112
+ end
113
+
114
+ module Kernel
115
+ `var ERROR = "Object tainting is not supported by Opal";`
116
+
117
+ def taint
118
+ if `OPAL_CONFIG.tainting`
119
+ `warn(ERROR)`
120
+ else
121
+ raise NotImplementedError, `ERROR`
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ def untaint
128
+ if `OPAL_CONFIG.tainting`
129
+ `warn(ERROR)`
130
+ else
131
+ raise NotImplementedError, `ERROR`
132
+ end
133
+
134
+ self
135
+ end
136
+
137
+ def tainted?
138
+ if `OPAL_CONFIG.tainting`
139
+ `warn(ERROR)`
140
+ else
141
+ raise NotImplementedError, `ERROR`
142
+ end
143
+
144
+ false
145
+ end
146
+ end
147
+
148
+ module Marshal
149
+ `var ERROR = "Marshalling is not supported by Opal";`
150
+
151
+ module_function
152
+
153
+ def dump(*)
154
+ raise NotImplementedError, `ERROR`
155
+ end
156
+
157
+ def load(*)
158
+ raise NotImplementedError, `ERROR`
159
+ end
160
+
161
+ def restore(*)
162
+ raise NotImplementedError, `ERROR`
163
+ end
164
+ end
165
+
166
+ class Module
167
+ def public(*methods)
168
+ %x{
169
+ if (methods.length === 0) {
170
+ self.$$module_function = false;
171
+ }
172
+
173
+ return nil;
174
+ }
175
+ end
176
+
177
+ alias private public
178
+
179
+ alias protected public
180
+
181
+ alias nesting public
182
+
183
+ def private_class_method(name)
184
+ `self['$' + name] || nil`
185
+ end
186
+
187
+ alias public_class_method private_class_method
188
+
189
+ def private_method_defined?(obj)
190
+ false
191
+ end
192
+
193
+ def private_constant(*)
194
+ end
195
+
196
+ alias protected_method_defined? private_method_defined?
197
+
198
+ alias public_instance_methods instance_methods
199
+
200
+ alias public_method_defined? method_defined?
201
+ end
202
+
203
+ module Kernel
204
+ def private_methods(*)
205
+ []
206
+ end
207
+
208
+ alias private_instance_methods private_methods
209
+ end
210
+
211
+ module Kernel
212
+ def eval(*)
213
+ raise NotImplementedError, "To use Kernel#eval, you must first require 'opal-parser'. "\
214
+ "See https://github.com/opal/opal/blob/#{RUBY_ENGINE_VERSION}/docs/opal_parser.md for details."
215
+ end
216
+ end
@@ -16,9 +16,3 @@ ENV = {}
16
16
  $VERBOSE = false
17
17
  $DEBUG = false
18
18
  $SAFE = 0
19
-
20
- RUBY_PLATFORM = 'opal'
21
- RUBY_ENGINE = 'opal'
22
- RUBY_VERSION = '2.1.5'
23
- RUBY_ENGINE_VERSION = '0.8.1'
24
- RUBY_RELEASE_DATE = '2015-10-12'
data/opal/opal.rb CHANGED
@@ -1,32 +1,18 @@
1
- require 'corelib/runtime'
2
- require 'corelib/helpers'
3
- require 'corelib/module'
4
- require 'corelib/class'
5
- require 'corelib/basic_object'
6
- require 'corelib/kernel'
7
- require 'corelib/nil_class'
8
- require 'corelib/boolean'
9
- require 'corelib/error'
10
- require 'corelib/regexp'
11
- require 'corelib/comparable'
12
- require 'corelib/enumerable'
13
- require 'corelib/enumerator'
14
- require 'corelib/array'
1
+ require 'opal/base'
2
+ require 'opal/mini'
3
+
15
4
  require 'corelib/array/inheritance'
16
- require 'corelib/hash'
17
- require 'corelib/string'
18
5
  require 'corelib/string/inheritance'
19
- require 'corelib/match_data'
20
- require 'corelib/numeric'
6
+ require 'corelib/string/encoding'
7
+ require 'corelib/math'
21
8
  require 'corelib/complex'
22
9
  require 'corelib/rational'
23
- require 'corelib/proc'
24
- require 'corelib/method'
25
- require 'corelib/range'
26
10
  require 'corelib/time'
27
11
  require 'corelib/struct'
28
12
  require 'corelib/io'
29
13
  require 'corelib/main'
30
- require 'corelib/variables'
31
14
  require 'corelib/dir'
32
15
  require 'corelib/file'
16
+ require 'corelib/process'
17
+
18
+ require 'corelib/unsupported'
data/opal/opal/base.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'corelib/runtime'
2
+ require 'corelib/helpers'
3
+ require 'corelib/module'
4
+ require 'corelib/class'
5
+ require 'corelib/basic_object'
6
+ require 'corelib/kernel'
7
+ require 'corelib/error'
8
+
9
+ require 'corelib/constants'
data/opal/opal/mini.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'opal/base'
2
+
3
+ require 'corelib/nil'
4
+ require 'corelib/boolean'
5
+ require 'corelib/string'
6
+ require 'corelib/comparable'
7
+ require 'corelib/enumerable'
8
+ require 'corelib/enumerator'
9
+ require 'corelib/array'
10
+ require 'corelib/hash'
11
+ require 'corelib/number'
12
+ require 'corelib/range'
13
+ require 'corelib/proc'
14
+ require 'corelib/method'
15
+ require 'corelib/regexp'
16
+
17
+ require 'corelib/variables'
data/spec/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Opal specs overview
2
2
 
3
3
  * **rubyspecs** (file) a whitelist of RubySpec files to be ran
4
- * **corelib** RubySpec examples (submodule)
4
+ * **rubyspec** RubySpec examples (submodule)
5
5
  * **stdlib** `rubysl-*` examples (submodules)
6
6
  * **filters** The list of MSpec/RubySpec examples that are either bugs or unsupported
7
7
  * **opal** opal additions/special behaviour in the runtime/corelib
@@ -1,157 +1,59 @@
1
1
  opal_filter "Array" do
2
- fails "Array#clone copies singleton methods"
3
-
4
- fails "Array#<=> calls <=> left to right and return first non-0 result"
5
- fails "Array#<=> returns -1 if the arrays have same length and a pair of corresponding elements returns -1 for <=>"
6
- fails "Array#<=> returns +1 if the arrays have same length and a pair of corresponding elements returns +1 for <=>"
7
- fails "Array#<=> tries to convert the passed argument to an Array using #to_ary"
8
- fails "Array#<=> returns nil when the argument is not array-like"
9
-
10
- fails "Array.[] can unpack 2 or more nested referenced array"
11
-
12
- fails "Array#[]= sets elements in the range arguments when passed ranges"
13
-
14
- fails "Array#initialize with (size, object=nil) sets the array to the values returned by the block before break is executed"
15
- fails "Array#initialize with (size, object=nil) returns the value passed to break"
16
- fails "Array#initialize with (size, object=nil) uses the block value instead of using the default value"
17
- fails "Array#initialize with (size, object=nil) yields the index of the element and sets the element to the value of the block"
18
- fails "Array#initialize with (size, object=nil) raises a TypeError if the size argument is not an Integer type"
19
- fails "Array#initialize with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is not given"
20
- fails "Array#initialize with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is given"
21
- fails "Array#initialize with (size, object=nil) raises an ArgumentError if size is too large"
22
- fails "Array#initialize with (size, object=nil) sets the array to size and fills with the object"
23
- fails "Array#initialize with (array) calls #to_ary to convert the value to an array"
24
- fails "Array#initialize preserves the object's identity even when changing its value"
25
-
26
- fails "Array#& determines equivalence between elements in the sense of eql?"
27
-
28
- fails "Array#- removes an identical item even when its #eql? isn't reflexive"
29
- fails "Array#- doesn't remove an item with the same hash but not #eql?"
30
- fails "Array#- removes an item identified as equivalent via #hash and #eql?"
31
-
32
- fails "Array#* raises a TypeError is the passed argument is nil"
33
- fails "Array#* converts the passed argument to a String rather than an Integer"
34
- fails "Array#* raises a TypeError if the argument can neither be converted to a string nor an integer"
35
- fails "Array#* tires to convert the passed argument to an Integer using #to_int"
36
- fails "Array#* tries to convert the passed argument to a String using #to_str"
37
- fails "Array#* with a string uses the same separator with nested arrays"
38
- fails "Array#* with a string returns a string formed by concatenating each element.to_str separated by separator"
39
-
40
- fails "Array.new with (size, object=nil) raises an ArgumentError if size is too large"
41
- fails "Array.new with (array) calls #to_ary to convert the value to an array"
42
- fails "Array.new with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is given"
43
- fails "Array.new with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is not given"
44
- fails "Array.new with (size, object=nil) raises a TypeError if the size argument is not an Integer type"
45
-
46
- fails "Array#permutation generates from a defensive copy, ignoring mutations"
47
- fails "Array#permutation returns an Enumerator which works as expected even when the array was modified"
48
- fails "Array#permutation truncates Float arguments"
49
- fails "Array#permutation handles nested Arrays correctly"
50
- fails "Array#permutation handles duplicate elements correctly"
51
- fails "Array#permutation returns no permutations when the given length has no permutations"
52
- fails "Array#permutation returns the empty permutation([]) when called on an empty Array"
53
- fails "Array#permutation returns the empty permutation ([[]]) when the given length is 0"
54
- fails "Array#permutation yields all permutations of given length to the block then returns self when called with block and argument"
55
- fails "Array#permutation yields all permutations to the block then returns self when called with block but no arguments"
56
- fails "Array#permutation returns an Enumerator of permutations of given length when called with an argument but no block"
57
- fails "Array#permutation returns an Enumerator of all permutations when called without a block or arguments"
58
-
59
- fails "Array#rassoc does not check the last element in each contained but speficically the second"
60
- fails "Array#rassoc calls elem == obj on the second element of each contained array"
61
-
62
- fails "Array#repeated_combination generates from a defensive copy, ignoring mutations"
2
+ fails "Array#flatten performs respond_to? and method_missing-aware checks when coercing elements to array"
3
+ fails "Array#flatten with a non-Array object in the Array calls #method_missing if defined"
4
+ fails "Array#flatten with a non-Array object in the Array calls #to_ary if not defined when #respond_to_missing? returns true"
5
+ fails "Array#flatten with a non-Array object in the Array does not call #to_ary if not defined when #respond_to_missing? returns false"
6
+ fails "Array#join raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s"
7
+ fails "Array#partition returns in the left array values for which the block evaluates to true"
8
+ fails "Array#permutation when no block is given returned Enumerator size with an array size greater than 0 returns the descending factorial of array size and given length"
9
+ fails "Array#permutation when no block is given returned Enumerator size with an array size greater than 0 returns the descending factorial of array size with array size when there's no param"
10
+ fails "Array#permutation when no block is given returned Enumerator size with an empty array returns 1 when the given length is 0"
11
+ fails "Array#permutation when no block is given returned Enumerator size with an empty array returns 1 when there's param"
12
+ fails "Array#pop passed a number n as an argument raises an ArgumentError if more arguments are passed" #Arity issue?
13
+ fails "Array#rassoc calls elem == obj on the second element of each contained array" #Spec assumes string and symbols are not equal.
14
+ fails "Array#rassoc does not check the last element in each contained but speficically the second" #Spec assumes string and symbols are not equal.
63
15
  fails "Array#repeated_combination accepts sizes larger than the original array"
16
+ fails "Array#repeated_combination generates from a defensive copy, ignoring mutations"
17
+ fails "Array#repeated_combination returns an enumerator when no block is provided"
18
+ fails "Array#repeated_combination returns self when a block is given"
19
+ fails "Array#repeated_combination when no block is given returned Enumerator size returns 0 when the combination_size is < 0"
20
+ fails "Array#repeated_combination when no block is given returned Enumerator size returns 1 when the combination_size is 0"
21
+ fails "Array#repeated_combination when no block is given returned Enumerator size returns the binomial coeficient between combination_size and array size + combination_size -1"
64
22
  fails "Array#repeated_combination yields a partition consisting of only singletons"
23
+ fails "Array#repeated_combination yields nothing for negative length and return self"
65
24
  fails "Array#repeated_combination yields nothing when the array is empty and num is non zero"
66
- fails "Array#repeated_combination yields [] when length is 0"
67
25
  fails "Array#repeated_combination yields the expected repeated_combinations"
68
- fails "Array#repeated_combination yields nothing for negative length and return self"
69
- fails "Array#repeated_combination returns self when a block is given"
70
- fails "Array#repeated_combination returns an enumerator when no block is provided"
71
-
72
- fails "Array#repeated_permutation generates from a defensive copy, ignoring mutations"
26
+ fails "Array#repeated_combination yields [] when length is 0"
73
27
  fails "Array#repeated_permutation allows permutations larger than the number of elements"
28
+ fails "Array#repeated_permutation does not yield when called on an empty Array with a nonzero argument"
29
+ fails "Array#repeated_permutation generates from a defensive copy, ignoring mutations"
30
+ fails "Array#repeated_permutation handles duplicate elements correctly"
31
+ fails "Array#repeated_permutation returns an Enumerator of all repeated permutations of given length when called without a block"
74
32
  fails "Array#repeated_permutation returns an Enumerator which works as expected even when the array was modified"
75
33
  fails "Array#repeated_permutation truncates Float arguments"
76
- fails "Array#repeated_permutation handles duplicate elements correctly"
77
- fails "Array#repeated_permutation does not yield when called on an empty Array with a nonzero argument"
78
- fails "Array#repeated_permutation yields the empty repeated_permutation ([[]]) when the given length is 0"
34
+ fails "Array#repeated_permutation when no block is given returned Enumerator size returns 0 when combination_size is < 0"
35
+ fails "Array#repeated_permutation when no block is given returned Enumerator size returns array size ** combination_size"
79
36
  fails "Array#repeated_permutation yields all repeated_permutations to the block then returns self when called with block but no arguments"
80
- fails "Array#repeated_permutation returns an Enumerator of all repeated permutations of given length when called without a block"
81
-
82
- fails "Array#rindex rechecks the array size during iteration"
83
-
84
- fails "Array#sample calls #rand on the Object passed by the :random key in the arguments Hash"
85
- fails "Array#sample calls #to_hash to convert the passed Object"
86
- fails "Array#sample calls #to_int on the Object returned by #rand"
87
- fails "Array#sample calls #to_int on the first argument and #to_hash on the second when passed Objects"
88
- fails "Array#sample calls #to_int to convert the count when passed an Object"
89
- fails "Array#sample does not return the same value if the Array has unique values"
90
- fails "Array#sample ignores an Object passed for the RNG if it does not define #rand"
91
- fails "Array#sample raises ArgumentError when passed a negative count"
92
- fails "Array#sample raises a RangeError if the value is equal to the Array size"
93
- fails "Array#sample raises a RangeError if the value is less than zero"
94
- fails "Array#sample returns at most the number of elements in the Array"
95
- fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int calls #to_int on the Object"
96
- fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is equal to the Array size"
97
- fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is less than zero"
98
- fails "Array#sample with options calls #rand on the Object passed by the :random key in the arguments Hash"
99
- fails "Array#sample with options calls #to_hash to convert the passed Object"
100
- fails "Array#sample with options calls #to_int on the first argument and #to_hash on the second when passed Objects"
101
- fails "Array#sample with options ignores an Object passed for the RNG if it does not define #rand"
102
- fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is equal to the Array size"
103
- fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is less than zero"
104
- fails "Array#sample with options when the object returned by #rand is a Fixnum uses the fixnum as index"
105
-
106
- fails "Array#select returns a new array of elements for which block is true"
107
-
108
- fails "Array#shuffle attempts coercion via #to_hash"
109
- fails "Array#shuffle is not destructive"
110
- fails "Array#shuffle returns the same values, in a usually different order"
111
- fails "Array#shuffle calls #rand on the Object passed by the :random key in the arguments Hash"
112
- fails "Array#shuffle ignores an Object passed for the RNG if it does not define #rand"
113
- fails "Array#shuffle accepts a Float for the value returned by #rand"
114
- fails "Array#shuffle calls #to_int on the Object returned by #rand"
115
- fails "Array#shuffle raises a RangeError if the value is less than zero"
116
- fails "Array#shuffle raises a RangeError if the value is equal to one"
117
-
118
- fails "Array#shuffle! returns the same values, in a usually different order"
119
-
37
+ fails "Array#repeated_permutation yields the empty repeated_permutation ([[]]) when the given length is 0"
38
+ fails "Array#select returns a new array of elements for which block is true" #Spec assumes integer division
39
+ fails "Array#shift passed a number n as an argument raises an ArgumentError if more arguments are passed" #Arity issue?
120
40
  fails "Array#slice! calls to_int on range arguments"
121
41
  fails "Array#slice! calls to_int on start and length arguments"
122
42
  fails "Array#slice! does not expand array with indices out of bounds"
123
43
  fails "Array#slice! does not expand array with negative indices out of bounds"
124
44
  fails "Array#slice! removes and return elements in range"
125
45
  fails "Array#slice! removes and returns elements in end-exclusive ranges"
126
-
46
+ fails "Array#slice! returns nil if length is negative"
47
+ fails "Array#sort_by! completes when supplied a block that always returns the same result"
127
48
  fails "Array#sort_by! makes some modification even if finished sorting when it would break in the given block"
128
- fails "Array#sort_by! returns the specified value when it would break in the given block"
129
- fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
130
49
  fails "Array#sort_by! raises a RuntimeError on a frozen array"
131
- fails "Array#sort_by! completes when supplied a block that always returns the same result"
50
+ fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
132
51
  fails "Array#sort_by! returns an Enumerator if not given a block"
52
+ fails "Array#sort_by! returns the specified value when it would break in the given block"
133
53
  fails "Array#sort_by! sorts array in place by passing each element to the given block"
134
-
135
- fails "Array#uniq compares elements based on the value returned from the block"
136
- fails "Array#uniq compares elements with matching hash codes with #eql?"
137
- fails "Array#uniq handles nil and false like any other values"
138
- fails "Array#uniq uses eql? semantics"
139
- fails "Array#uniq yields items in order"
140
-
141
- fails "Array#uniq! compares elements based on the value returned from the block"
142
-
143
- fails "Array#hash returns the same fixnum for arrays with the same content"
144
-
145
- fails "Array#partition returns in the left array values for which the block evaluates to true"
146
-
147
- fails "Array#| acts as if using an intermediate hash to collect values"
148
-
149
- # recursive arrays
54
+ fails "Array#sort_by! when no block is given returned Enumerator size returns the enumerable size"
150
55
  fails "Array#uniq! properly handles recursive arrays"
151
- fails "Array#<=> properly handles recursive arrays"
152
- fails "Array#values_at properly handles recursive arrays"
153
- fails "Array#hash returns the same hash for equal recursive arrays through hashes"
154
-
155
- fails "Array#first raises a RangeError when count is a Bignum"
156
- fails "Array#hash calls to_int on result of calling hash on each element"
56
+ fails "Array#zip fills nil when the given enumereator is shorter than self"
57
+ fails "Array#zip stops at own size when given an infinite enumerator"
58
+ fails "Array.[] can unpack 2 or more nested referenced array"
157
59
  end