opal 1.2.0 → 1.3.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.await.js +6 -0
  3. data/.eslintrc.js +34 -0
  4. data/.github/workflows/build.yml +8 -0
  5. data/.rubocop.yml +9 -0
  6. data/CHANGELOG.md +4 -0
  7. data/README.md +1 -1
  8. data/Rakefile +1 -0
  9. data/UNRELEASED.md +64 -38
  10. data/docs/async.md +109 -0
  11. data/docs/roda-sprockets.md +0 -2
  12. data/exe/opal +2 -0
  13. data/exe/opal-repl +2 -2
  14. data/lib/opal/builder.rb +5 -1
  15. data/lib/opal/builder_processors.rb +7 -2
  16. data/lib/opal/cache/file_cache.rb +119 -0
  17. data/lib/opal/cache.rb +71 -0
  18. data/lib/opal/cli.rb +35 -1
  19. data/lib/opal/cli_options.rb +21 -0
  20. data/lib/opal/cli_runners/chrome.rb +21 -14
  21. data/lib/opal/cli_runners/chrome_cdp_interface.js +30285 -0
  22. data/lib/opal/cli_runners/{chrome.js → chrome_cdp_interface.rb} +27 -6
  23. data/lib/opal/cli_runners/compiler.rb +2 -1
  24. data/lib/opal/cli_runners/gjs.rb +27 -0
  25. data/lib/opal/cli_runners/mini_racer.rb +36 -0
  26. data/lib/opal/cli_runners/source-map-support-browser.js +276 -91
  27. data/lib/opal/cli_runners/source-map-support-node.js +276 -91
  28. data/lib/opal/cli_runners/source-map-support.js +60 -18
  29. data/lib/opal/cli_runners.rb +2 -0
  30. data/lib/opal/compiler.rb +99 -10
  31. data/lib/opal/fragment.rb +77 -14
  32. data/lib/opal/nodes/args/extract_kwrestarg.rb +6 -4
  33. data/lib/opal/nodes/args/extract_restarg.rb +10 -12
  34. data/lib/opal/nodes/args.rb +28 -0
  35. data/lib/opal/nodes/base.rb +29 -5
  36. data/lib/opal/nodes/call.rb +123 -2
  37. data/lib/opal/nodes/case.rb +7 -1
  38. data/lib/opal/nodes/class.rb +12 -2
  39. data/lib/opal/nodes/def.rb +3 -23
  40. data/lib/opal/nodes/definitions.rb +21 -4
  41. data/lib/opal/nodes/helpers.rb +2 -2
  42. data/lib/opal/nodes/if.rb +39 -9
  43. data/lib/opal/nodes/iter.rb +15 -3
  44. data/lib/opal/nodes/lambda.rb +3 -1
  45. data/lib/opal/nodes/literal.rb +13 -7
  46. data/lib/opal/nodes/logic.rb +2 -2
  47. data/lib/opal/nodes/module.rb +12 -2
  48. data/lib/opal/nodes/rescue.rb +59 -34
  49. data/lib/opal/nodes/scope.rb +88 -6
  50. data/lib/opal/nodes/super.rb +52 -25
  51. data/lib/opal/nodes/top.rb +13 -7
  52. data/lib/opal/nodes/while.rb +7 -1
  53. data/lib/opal/parser/patch.rb +2 -1
  54. data/lib/opal/repl.rb +137 -49
  55. data/lib/opal/rewriters/binary_operator_assignment.rb +10 -10
  56. data/lib/opal/rewriters/block_to_iter.rb +3 -3
  57. data/lib/opal/rewriters/for_rewriter.rb +7 -7
  58. data/lib/opal/rewriters/js_reserved_words.rb +5 -3
  59. data/lib/opal/source_map/file.rb +7 -4
  60. data/lib/opal/source_map/map.rb +17 -3
  61. data/lib/opal/version.rb +1 -1
  62. data/opal/corelib/array.rb +2 -2
  63. data/opal/corelib/binding.rb +46 -0
  64. data/opal/corelib/boolean.rb +54 -4
  65. data/opal/corelib/class.rb +2 -0
  66. data/opal/corelib/constants.rb +2 -2
  67. data/opal/corelib/error.rb +98 -12
  68. data/opal/corelib/io.rb +250 -38
  69. data/opal/corelib/kernel/format.rb +5 -2
  70. data/opal/corelib/kernel.rb +44 -23
  71. data/opal/corelib/main.rb +5 -0
  72. data/opal/corelib/method.rb +1 -0
  73. data/opal/corelib/module.rb +28 -0
  74. data/opal/corelib/number.rb +12 -1
  75. data/opal/corelib/random/seedrandom.js.rb +2 -2
  76. data/opal/corelib/regexp.rb +47 -3
  77. data/opal/corelib/runtime.js +152 -12
  78. data/opal/corelib/string/encoding.rb +17 -17
  79. data/opal/corelib/string.rb +2 -0
  80. data/opal/corelib/struct.rb +10 -3
  81. data/opal/corelib/trace_point.rb +57 -0
  82. data/opal/opal/full.rb +2 -0
  83. data/package.json +3 -2
  84. data/spec/filters/bugs/array.rb +0 -1
  85. data/spec/filters/bugs/basicobject.rb +0 -1
  86. data/spec/filters/bugs/binding.rb +27 -0
  87. data/spec/filters/bugs/enumerator.rb +132 -0
  88. data/spec/filters/bugs/exception.rb +70 -93
  89. data/spec/filters/bugs/float.rb +0 -1
  90. data/spec/filters/bugs/kernel.rb +3 -9
  91. data/spec/filters/bugs/language.rb +15 -58
  92. data/spec/filters/bugs/main.rb +16 -0
  93. data/spec/filters/bugs/matrix.rb +39 -0
  94. data/spec/filters/bugs/method.rb +0 -2
  95. data/spec/filters/bugs/module.rb +36 -79
  96. data/spec/filters/bugs/proc.rb +0 -1
  97. data/spec/filters/bugs/regexp.rb +0 -16
  98. data/spec/filters/bugs/trace_point.rb +12 -0
  99. data/spec/filters/bugs/warnings.rb +0 -4
  100. data/spec/filters/unsupported/freeze.rb +2 -0
  101. data/spec/filters/unsupported/privacy.rb +4 -0
  102. data/spec/lib/compiler_spec.rb +7 -1
  103. data/spec/lib/repl_spec.rb +4 -2
  104. data/spec/lib/source_map/file_spec.rb +1 -1
  105. data/spec/mspec-opal/formatters.rb +18 -4
  106. data/spec/mspec-opal/runner.rb +2 -2
  107. data/spec/opal/core/boolean_spec.rb +44 -0
  108. data/spec/opal/core/hash_spec.rb +8 -0
  109. data/spec/opal/core/number/to_s_spec.rb +11 -0
  110. data/spec/opal/stdlib/json/ext_spec.rb +3 -3
  111. data/spec/opal/stdlib/logger/logger_spec.rb +10 -1
  112. data/spec/ruby_specs +18 -0
  113. data/stdlib/await.rb +83 -0
  114. data/stdlib/base64.rb +4 -4
  115. data/stdlib/bigdecimal/bignumber.js.rb +4 -2
  116. data/stdlib/bigdecimal.rb +1 -0
  117. data/stdlib/gjs/io.rb +33 -0
  118. data/stdlib/gjs/kernel.rb +5 -0
  119. data/stdlib/gjs.rb +2 -0
  120. data/stdlib/js.rb +4 -0
  121. data/stdlib/json.rb +3 -3
  122. data/stdlib/logger.rb +1 -1
  123. data/stdlib/nashorn/file.rb +2 -0
  124. data/stdlib/nodejs/env.rb +7 -0
  125. data/stdlib/nodejs/file.rb +6 -41
  126. data/stdlib/nodejs/io.rb +21 -5
  127. data/stdlib/nodejs/js-yaml-3-6-1.js +2 -2
  128. data/stdlib/opal/miniracer.rb +6 -0
  129. data/stdlib/opal/platform.rb +4 -0
  130. data/stdlib/opal/repl_js.rb +5 -0
  131. data/stdlib/opal/replutils.rb +271 -0
  132. data/stdlib/opal-parser.rb +24 -11
  133. data/stdlib/opal-platform.rb +8 -0
  134. data/stdlib/promise/v2.rb +16 -4
  135. data/stdlib/promise.rb +14 -0
  136. data/stdlib/stringio.rb +13 -110
  137. data/stdlib/thread.rb +29 -0
  138. data/tasks/building.rake +10 -4
  139. data/tasks/linting-parse-eslint-results.js +39 -0
  140. data/tasks/linting.rake +38 -28
  141. data/tasks/performance/asciidoctor_test.rb.erb +6 -0
  142. data/tasks/performance/optimization_status.rb +77 -0
  143. data/tasks/performance.rake +149 -0
  144. data/tasks/testing.rake +9 -1
  145. data/test/nodejs/test_await.rb +169 -0
  146. data/test/opal/promisev2/test_error.rb +9 -3
  147. data/test/opal/unsupported_and_bugs.rb +5 -0
  148. data/vendored-minitest/minitest/benchmark.rb +9 -7
  149. data/vendored-minitest/minitest/test.rb +14 -12
  150. data/vendored-minitest/minitest.rb +19 -16
  151. data/yarn.lock +686 -117
  152. metadata +60 -23
  153. data/.jshintrc +0 -41
  154. data/spec/filters/unsupported/refinements.rb +0 -8
  155. data/vendored-minitest/minitest/hell.rb +0 -11
  156. data/vendored-minitest/minitest/parallel.rb +0 -65
  157. data/vendored-minitest/minitest/pride.rb +0 -4
  158. data/vendored-minitest/minitest/pride_plugin.rb +0 -142
  159. data/vendored-minitest/minitest/unit.rb +0 -45
@@ -71,8 +71,7 @@ opal_filter "Module" do
71
71
  fails "Module#autoload when changing $LOAD_PATH does not reload a file due to a different load path"
72
72
  fails "Module#autoload? returns nil if no file has been registered for a constant"
73
73
  fails "Module#autoload? returns the name of the file that will be autoloaded"
74
- fails "Module#class_eval activates refinements from the eval scope with block" # NoMethodError: undefined method `refine' for #<Module:0x89ba>
75
- fails "Module#class_eval activates refinements from the eval scope" # NoMethodError: undefined method `refine' for #<Module:0x90be>
74
+ fails "Module#class_eval activates refinements from the eval scope" # NoMethodError: undefined method `foo' for #<ModuleSpecs::NamedClass:0x4a168>
76
75
  fails "Module#class_eval converts a non-string filename to a string using to_str"
77
76
  fails "Module#class_eval converts non string eval-string to string using to_str"
78
77
  fails "Module#class_eval raises a TypeError when the given eval-string can't be converted to string using to_str"
@@ -160,8 +159,7 @@ opal_filter "Module" do
160
159
  fails "Module#method_defined? returns true if a public or private method with the given name is defined in self, self's ancestors or one of self's included modules"
161
160
  fails "Module#method_defined? when passed false as a second optional argument checks only the class itself" # ArgumentError: [Child.method_defined?] wrong number of arguments(2 for 1)
162
161
  fails "Module#method_defined? when passed true as a second optional argument performs a lookup in ancestors" # ArgumentError: [Child.method_defined?] wrong number of arguments(2 for 1)
163
- fails "Module#module_eval activates refinements from the eval scope with block" # NoMethodError: undefined method `refine' for #<Module:0x81e0>
164
- fails "Module#module_eval activates refinements from the eval scope" # NoMethodError: undefined method `refine' for #<Module:0x88e4>
162
+ fails "Module#module_eval activates refinements from the eval scope" # NoMethodError: undefined method `foo' for #<ModuleSpecs::NamedClass:0x81f82>
165
163
  fails "Module#module_eval converts a non-string filename to a string using to_str"
166
164
  fails "Module#module_eval converts non string eval-string to string using to_str"
167
165
  fails "Module#module_eval raises a TypeError when the given eval-string can't be converted to string using to_str"
@@ -197,62 +195,32 @@ opal_filter "Module" do
197
195
  fails "Module#protected_method_defined? when passed false as a second optional argument checks only the class itself" # ArgumentError: [Child.private_method_defined?] wrong number of arguments(2 for 1)
198
196
  fails "Module#protected_method_defined? when passed true as a second optional argument performs a lookup in ancestors" # ArgumentError: [Child.private_method_defined?] wrong number of arguments(2 for 1)
199
197
  fails "Module#public_method_defined? raises a TypeError if passed an Integer" # Expected TypeError but no exception was raised (false was returned)
200
- fails "Module#refine accepts a module as argument" # NoMethodError: undefined method `refine' for #<Module:0x4c172>
201
- fails "Module#refine adds methods defined in its block to the anonymous module's public instance methods" # NoMethodError: undefined method `refine' for #<Module:0x3ae64>
202
- fails "Module#refine and alias aliases a method within a refinement module, but not outside it" # NoMethodError: undefined method `refine' for #<Module:0x1aab4>
203
- fails "Module#refine and alias_method aliases a method within a refinement module, but not outside it" # NoMethodError: undefined method `refine' for #<Module:0x1aab0>
204
- fails "Module#refine and instance_methods returns a list of methods including those of the refined module" # NoMethodError: undefined method `refine' for #<Module:0x228>
205
- fails "Module#refine applies refinements to calls in the refine block" # NoMethodError: undefined method `refine' for #<Module:0x3ae7a>
206
- fails "Module#refine applies refinements to the module" # NoMethodError: undefined method `refine' for #<Module:0x22c>
207
- fails "Module#refine does not apply refinements to external scopes not using the module" # NoMethodError: undefined method `refine' for #<Module:0x3ae60>
208
- fails "Module#refine does not list methods defined only in refinement" # NoMethodError: undefined method `refine' for #<Module:0x1e042>
209
- fails "Module#refine does not make available methods from another refinement module" # NoMethodError: undefined method `refine' for #<Module:0x3ae8c>
210
- fails "Module#refine does not override methods in subclasses" # NoMethodError: undefined method `refine' for #<Module:0x3ae56>
211
- fails "Module#refine doesn't apply refinements outside the refine block" # NoMethodError: undefined method `refine' for #<Module:0x3ae72>
212
- fails "Module#refine for methods accessed indirectly is honored by &" # NoMethodError: undefined method `refine' for #<Module:0x4b006>
213
- fails "Module#refine for methods accessed indirectly is honored by BasicObject#__send__" # NoMethodError: undefined method `refine' for #<Module:0x3aeb2>
214
- fails "Module#refine for methods accessed indirectly is honored by Kernel#binding" # NoMethodError: undefined method `refine' for #<Module:0x3aeaa>
215
- fails "Module#refine for methods accessed indirectly is honored by Kernel#instance_method" # NoMethodError: undefined method `refine' for #<Module:0x3a6b2>
216
- fails "Module#refine for methods accessed indirectly is honored by Kernel#method" # NoMethodError: undefined method `refine' for #<Module:0x4b00a>
217
- fails "Module#refine for methods accessed indirectly is honored by Kernel#public_method" # NoMethodError: undefined method `refine' for #<Module:0x3a6b6>
218
- fails "Module#refine for methods accessed indirectly is honored by Kernel#public_send" # NoMethodError: undefined method `refine' for #<Module:0x4b00e>
219
- fails "Module#refine for methods accessed indirectly is honored by Kernel#respond_to?" # NoMethodError: undefined method `refine' for #<Module:0x4b016>
220
- fails "Module#refine for methods accessed indirectly is honored by Kernel#send" # NoMethodError: undefined method `refine' for #<Module:0x3aeae>
221
- fails "Module#refine for methods accessed indirectly is honored by Symbol#to_proc" # NoMethodError: undefined method `refine' for #<Module:0x3aeba>
222
- fails "Module#refine for methods accessed indirectly is honored by string interpolation" # NoMethodError: undefined method `refine' for #<Module:0x3aeb6>
223
- fails "Module#refine for methods accessed indirectly is not honored by &" # NoMethodError: undefined method `refine' for #<Module:0x21e9c>
224
- fails "Module#refine for methods accessed indirectly is not honored by Kernel#instance_method" # NoMethodError: undefined method `refine' for #<Module:0x4c176>
225
- fails "Module#refine for methods accessed indirectly is not honored by Kernel#method" # NoMethodError: undefined method `refine' for #<Module:0x3aec0>
226
- fails "Module#refine for methods accessed indirectly is not honored by Kernel#public_send" # NoMethodError: undefined method `refine' for #<Module:0x21ea0>
227
- fails "Module#refine for methods accessed indirectly is not honored by Kernel#respond_to?" # NoMethodError: undefined method `refine' for #<Module:0x3aea6>
228
- fails "Module#refine makes available all refinements from the same module" # NoMethodError: undefined method `refine' for #<Module:0x3ae88>
229
- fails "Module#refine method lookup looks in included modules from the refinement then" # NoMethodError: undefined method `refine' for #<Module:0x3aea0>
230
- fails "Module#refine method lookup looks in later included modules of the refined module first" # NoMethodError: undefined method `refine' for #<Module:0x230>
231
- fails "Module#refine method lookup looks in prepended modules from the refinement first" # NoMethodError: undefined method `refine' for #<Module:0x3ae98>
232
- fails "Module#refine method lookup looks in refinement then" # NoMethodError: undefined method `refine' for #<Module:0x3ae94>
233
- fails "Module#refine method lookup looks in the class then" # NoMethodError: undefined method `refine' for #<Module:0x3ae90>
234
- fails "Module#refine method lookup looks in the included modules for builtin methods" # NoMethodError: undefined method `insert' for "rubyexe.rb"
235
- fails "Module#refine method lookup looks in the object singleton class first" # NoMethodError: undefined method `refine' for #<Module:0x3ae9c>
236
- fails "Module#refine module inclusion activates all refinements from all ancestors" # NoMethodError: undefined method `refine' for #<Module:0x3aed4>
237
- fails "Module#refine module inclusion overrides methods of ancestors by methods in descendants" # NoMethodError: undefined method `refine' for #<Module:0x3aed0>
238
- fails "Module#refine raises ArgumentError if not given a block" # NoMethodError: undefined method `refine' for #<Module:0x3ae5c>
239
- fails "Module#refine raises ArgumentError if not passed an argument" # NoMethodError: undefined method `refine' for #<Module:0x3ae80>
240
- fails "Module#refine raises TypeError if not passed a class" # NoMethodError: undefined method `refine' for #<Module:0x3ae6e>
241
- fails "Module#refine returns created anonymous module" # NoMethodError: undefined method `refine' for #<Module:0x3ae68>
242
- fails "Module#refine runs its block in an anonymous module" # NoMethodError: undefined method `refine' for #<Module:0x3ae76>
243
- fails "Module#refine uses the same anonymous module for future refines of the same class" # NoMethodError: undefined method `refine' for #<Module:0x3ae84>
244
- fails "Module#refine when super is called in a refinement does't have access to active refinements for C from included module" # NoMethodError: undefined method `refine' for #<Module:0x242>
245
- fails "Module#refine when super is called in a refinement does't have access to other active refinements from included module" # NoMethodError: undefined method `refine' for #<Module:0x24a>
246
- fails "Module#refine when super is called in a refinement looks in the another active refinement if super called from included modules" # NoMethodError: undefined method `refine' for #<Module:0x252>
247
- fails "Module#refine when super is called in a refinement looks in the current active refinement from included modules" # NoMethodError: undefined method `refine' for #<Module:0x256>
248
- fails "Module#refine when super is called in a refinement looks in the included to refinery module" # NoMethodError: undefined method `refine' for #<Module:0x3aec8>
249
- fails "Module#refine when super is called in a refinement looks in the lexical scope refinements before other active refinements" # NoMethodError: undefined method `refine' for #<Module:0x236>
250
- fails "Module#refine when super is called in a refinement looks in the refined ancestors from included module" # NoMethodError: undefined method `refine' for #<Module:0x23e>
251
- fails "Module#refine when super is called in a refinement looks in the refined class even if there is another active refinement" # NoMethodError: undefined method `refine' for #<Module:0x3aec4>
252
- fails "Module#refine when super is called in a refinement looks in the refined class first if called from refined method" # NoMethodError: undefined method `refine' for #<Module:0x246>
253
- fails "Module#refine when super is called in a refinement looks in the refined class from included module" # NoMethodError: undefined method `refine' for #<Module:0x23a>
254
- fails "Module#refine when super is called in a refinement looks in the refined class" # NoMethodError: undefined method `refine' for #<Module:0x3aecc>
255
- fails "Module#refine when super is called in a refinement looks only in the refined class even if there is another active refinement" # NoMethodError: undefined method `refine' for #<Module:0x24e>
198
+ fails "Module#refine and alias aliases a method within a refinement module, but not outside it" # NameError: undefined method `count' for class `'
199
+ fails "Module#refine and alias_method aliases a method within a refinement module, but not outside it" # NameError: undefined method `count' for class `'
200
+ fails "Module#refine and instance_methods returns a list of methods including those of the refined module" # Expected ["to_json_format", "initialize", "&", "|", "*", "+", "-", "<<", "<=>", "==", "[]", "[]=", "any?", "assoc", "at", "bsearch_index", "bsearch", "cycle", "clear", "count", "initialize_copy", "collect", "collect!", "combination", "repeated_combination", "compact", "compact!", "concat", "delete", "delete_at", "delete_if", "difference", "dig", "drop", "dup", "each", "each_index", "empty?", "eql?", "fetch", "fill", "first", "flatten", "flatten!", "hash", "include?", "index", "insert", "inspect", "intersection", "join", "keep_if", "last", "length", "map", "map!", "max", "min", "permutation", "repeated_permutation", "pop", "product", "push", "append", "rassoc", "reject", "reject!", "replace", "reverse", "reverse!", "reverse_each", "rindex", "rotate", "rotate!", "sample", "select", "select!", "filter", "filter!", "shift", "size", "shuffle", "shuffle!", "slice", "slice!", "sort", "sort!", "sort_by!", "take", "take_while", "to_a", "to_ary", "to_h", "to_s", "transpose", "union", "uniq", "uniq!", "unshift", "prepend", "values_at", "zip", "instance_variables", "pack", "pretty_print", "pretty_print_cycle", "__marshal__", "deconstruct", "all?", "chunk", "chunk_while", "collect_concat", "detect", "drop_while", "each_cons", "each_entry", "each_slice", "each_with_index", "each_with_object", "entries", "filter_map", "find", "find_all", "find_index", "flat_map", "grep", "grep_v", "group_by", "inject", "lazy", "enumerator_size", "max_by", "member?", "min_by", "minmax", "minmax_by", "none?", "one?", "partition", "reduce", "slice_before", "slice_after", "slice_when", "sort_by", "sum", "tally", "to_set", "require", "using", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "toplevel_define_other_method", "some_toplevel_method", "public_toplevel_method", "main_public_method", "main_public_method2", "main_private_method", "main_private_method2", "check_autoload", "defined_specs_method", "defined_specs_receiver", "expect", "eq", "pretty_print_instance_variables", "pretty_print_inspect", "method_missing", "=~", "!~", "===", "method", "methods", "public_methods", "Array", "at_exit", "caller", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "initialize_clone", "define_singleton_method", "initialize_dup", "enum_for", "to_enum", "equal?", "exit", "extend", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "Integer", "Float", "Hash", "is_a?", "itself", "kind_of?", "lambda", "load", "loop", "nil?", "object_id", "printf", "proc", "puts", "p", "print", "warn", "raise", "fail", "rand", "respond_to?", "respond_to_missing?", "require_relative", "require_tree", "send", "public_send", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "catch", "throw", "open", "yield_self", "then", "format", "sprintf", "Complex", "Rational", "freeze", "frozen?", "taint", "untaint", "tainted?", "private_methods", "private_instance_methods", "eval", "node_require", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "binding", "BigDecimal", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel", "__send__", "!=", "__id__", "!", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined"] == [] to be truthy but was false
201
+ fails "Module#refine applies refinements to calls in the refine block" # NoMethodError: undefined method `foo' for "hello"
202
+ fails "Module#refine does not override methods in subclasses" # Expected "foo from refinement" == "foo from subclass" to be truthy but was false
203
+ fails "Module#refine for methods accessed indirectly is honored by BasicObject#__send__" # Expected "foo" == "foo from refinement" to be truthy but was false
204
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#instance_method" # NameError: undefined method `foo' for class `'
205
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#method" # NameError: undefined method `foo' for class `#<Class:0x6854>'
206
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#public_method" # NoMethodError: undefined method `public_method' for #<#<Class:0x1b194>:0x1b196>
207
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#public_send" # Expected "foo" == "foo from refinement" to be truthy but was false
208
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#respond_to?" # Expected false == true to be truthy but was false
209
+ fails "Module#refine for methods accessed indirectly is honored by Kernel#send" # Expected "foo" == "foo from refinement" to be truthy but was false
210
+ fails "Module#refine for methods accessed indirectly is honored by Symbol#to_proc"
211
+ fails "Module#refine for methods accessed indirectly is honored by string interpolation"
212
+ fails "Module#refine looks in the included modules for builtin methods"
213
+ fails "Module#refine makes available all refinements from the same module" # NoMethodError: undefined method `dump' for "1"
214
+ fails "Module#refine method lookup looks in the included modules for builtin methods" # NoMethodError: undefined method `tmp' for #<MSpecEnv:0x1aaee>
215
+ fails "Module#refine method lookup looks in the object singleton class first" # Expected "foo from refinement" == "foo from singleton class" to be truthy but was false
216
+ fails "Module#refine module inclusion activates all refinements from all ancestors" # NoMethodError: undefined method `to_json_format' for 5
217
+ fails "Module#refine module inclusion overrides methods of ancestors by methods in descendants" # NoMethodError: undefined method `to_json_format' for 5
218
+ fails "Module#refine raises ArgumentError if not given a block" # Expected ArgumentError but got: LocalJumpError (no block given)
219
+ fails "Module#refine raises TypeError if not passed a class" # Expected TypeError but no exception was raised (#<Module:0x1abe8> was returned)
220
+ fails "Module#refine when super is called in a refinement looks in the another active refinement if super called from included modules" # Expected ["B", "C"] == ["B", "A", "C"] to be truthy but was false
221
+ fails "Module#refine when super is called in a refinement looks in the current active refinement from included modules" # Expected ["B", "C"] == ["B", "A", "LAST", "C"] to be truthy but was false
222
+ fails "Module#refine when super is called in a refinement looks in the included to refinery module" # Expected "foo" == "foo from included module" to be truthy but was false
223
+ fails "Module#refine when super is called in a refinement looks in the lexical scope refinements before other active refinements" # Expected ["A", "C"] == ["A", "LOCAL", "C"] to be truthy but was false
256
224
  fails "Module#remove_const calls #to_str to convert the given name to a String"
257
225
  fails "Module#remove_const raises a TypeError if conversion to a String by calling #to_str fails"
258
226
  fails "Module#remove_const returns nil when removing autoloaded constant"
@@ -274,23 +242,12 @@ opal_filter "Module" do
274
242
  fails "Module#undef_method raises a NameError when passed a missing name for a metaclass" # Expected NameError (/undefined method `not_exist' for class `String'/) but got: NameError (method 'not_exist' not defined in )
275
243
  fails "Module#undef_method raises a NameError when passed a missing name for a module" # Expected NameError (/undefined method `not_exist' for module `#<Module:0xa502>'/) but got: NameError (method 'not_exist' not defined in )
276
244
  fails "Module#undef_method raises a NameError when passed a missing name for a singleton class" # Expected NameError (/undefined method `not_exist' for class `#<Class:#<:0xa51a>>'/) but got: NameError (method 'not_exist' not defined in )
277
- fails "Module#using accepts module as argument" # NoMethodError: undefined method `refine' for #<Module:0x2a040>
278
- fails "Module#using accepts module without refinements" # Expected to not get Exception but got NoMethodError (undefined method `using' for #<Module:0x2a02a>)
279
- fails "Module#using activates refinement even for existed objects" # NoMethodError: undefined method `refine' for #<Module:0x2a052>
280
- fails "Module#using activates updates when refinement reopens later" # NoMethodError: undefined method `refine' for #<Module:0x2a018>
281
- fails "Module#using does not accept class" # NoMethodError: undefined method `using' for #<Module:0x2a03c>
282
- fails "Module#using imports class refinements from module into the current class/module" # NoMethodError: undefined method `refine' for #<Module:0x2a02e>
283
- fails "Module#using raises TypeError if passed something other than module" # NoMethodError: undefined method `using' for #<Module:0x2a034>
284
- fails "Module#using raises error in method scope" # NoMethodError: undefined method `using' for #<Module:0x2a044>
285
- fails "Module#using returns self" # NoMethodError: undefined method `using' for #<Module:0x2a022>
286
- fails "Module#using scope of refinement is active for block called via instance_eval" # NoMethodError: undefined method `refine' for #<Module:0x102>
287
- fails "Module#using scope of refinement is active for block called via instance_exec" # NoMethodError: undefined method `refine' for #<Module:0xfe>
288
- fails "Module#using scope of refinement is active for class defined via Class.new {}" # NoMethodError: undefined method `refine' for #<Module:0x106>
289
- fails "Module#using scope of refinement is active for method defined in a scope wherever it's called" # NoMethodError: undefined method `refine' for #<Module:0x2a06a>
290
- fails "Module#using scope of refinement is active for module defined via Module.new {}" # NoMethodError: undefined method `refine' for #<Module:0x10a>
291
- fails "Module#using scope of refinement is active until the end of current class/module" # NoMethodError: undefined method `refine' for #<Module:0x2a07a>
292
- fails "Module#using scope of refinement is not active before the `using` call" # NoMethodError: undefined method `refine' for #<Module:0x2a05e>
293
- fails "Module#using scope of refinement is not active for code defined outside the current scope" # NoMethodError: undefined method `refine' for #<Module:0x2a072>
294
- fails "Module#using scope of refinement is not active when class/module reopens" # NoMethodError: undefined method `refine' for #<Module:0x2a056>
295
- fails "Module#using works in classes too" # NoMethodError: undefined method `refine' for #<Module:0x2a01c>
245
+ fails "Module#using does not accept class" # Expected TypeError but no exception was raised (#<Module:0x3dd76> was returned)
246
+ fails "Module#using imports class refinements from module into the current class/module" # NoMethodError: undefined method `foo' for 1
247
+ fails "Module#using raises TypeError if passed something other than module" # Expected TypeError but no exception was raised (#<Module:0x3dd66> was returned)
248
+ fails "Module#using scope of refinement is active for block called via instance_eval" # TypeError: can't define singleton
249
+ fails "Module#using scope of refinement is active for block called via instance_exec" # NoMethodError: undefined method `foo' for 1
250
+ fails "Module#using scope of refinement is active for class defined via Class.new {}" # NoMethodError: undefined method `foo' for 1
251
+ fails "Module#using scope of refinement is active for module defined via Module.new {}" # NoMethodError: undefined method `foo' for 1
252
+ fails "Module#using works in classes too" # NoMethodError: undefined method `foo' for 1
296
253
  end
@@ -20,7 +20,6 @@ opal_filter "Proc" do
20
20
  fails "Proc#arity for instances created with proc { || } returns zero for definition \n @a = proc { |a: 1| }\n @b = proc { |a: 1, b: 2| }"
21
21
  fails "Proc#arity for instances created with proc { || } returns zero for definition \n @a = proc { |a=1, b: 2| }\n @b = proc { |a=1, b: 2| }"
22
22
  fails "Proc#arity for instances created with proc { || } returns zero for definition \n @a = proc { |a=1| }\n @b = proc { |a=1, b=2| }"
23
- fails "Proc#binding returns a Binding instance"
24
23
  fails "Proc#binding returns the binding associated with self"
25
24
  fails "Proc#call can call its block argument declared with a block argument" # Expected 6 to equal 10
26
25
  fails "Proc#call on a Proc created with Kernel#lambda or Kernel#proc ignores excess arguments when self is a proc" # ArgumentError: expected kwargs
@@ -1,6 +1,5 @@
1
1
  # NOTE: run bin/format-filters after changing this file
2
2
  opal_filter "regular_expressions" do
3
- fails "MatchData#inspect returns a human readable representation of named captures" # Exception: named captures are not supported in javascript: "(?<first>\w+)\s+(?<last>\w+)\s+(\w+)"
4
3
  fails "MatchData#regexp returns a Regexp for the result of gsub(String)" # Expected /\[/gm == /\[/ to be truthy but was false
5
4
  fails "MatchData#string returns a frozen copy of the matched string for gsub(String)" # NotImplementedError: String#gsub! not supported. Mutable String methods are not supported in Opal.
6
5
  fails "MatchData.allocate is undefined" # Expected NoMethodError but no exception was raised (#<MatchData>(#pretty_inspect raised #<NoMethodError: undefined method `named_captures' for nil>) was returned)
@@ -33,18 +32,8 @@ opal_filter "regular_expressions" do
33
32
  fails "Regexp#inspect does not include a character set code"
34
33
  fails "Regexp#inspect does not include the 'o' option"
35
34
  fails "Regexp#inspect returns options in the order 'mixn'"
36
- fails "Regexp#named_captures returns a Hash"
37
- fails "Regexp#named_captures returns an empty Hash when there are no capture groups"
38
- fails "Regexp#named_captures sets each element of the Array to the corresponding group's index"
39
- fails "Regexp#named_captures sets the keys of the Hash to the names of the capture groups"
40
- fails "Regexp#named_captures sets the values of the Hash to Arrays"
41
35
  fails "Regexp#named_captures works with duplicate capture group names"
42
- fails "Regexp#names returns all of the named captures"
43
- fails "Regexp#names returns an Array"
44
- fails "Regexp#names returns an empty Array if there are no named captures"
45
36
  fails "Regexp#names returns each capture name only once"
46
- fails "Regexp#names returns each named capture as a String"
47
- fails "Regexp#names works with nested named captures"
48
37
  fails "Regexp#source will remove escape characters" # Expected "foo\\/bar" to equal "foo/bar"
49
38
  fails "Regexp#to_s deals properly with the two types of lookahead groups"
50
39
  fails "Regexp#to_s returns a string in (?xxx:yyy) notation"
@@ -74,11 +63,6 @@ opal_filter "regular_expressions" do
74
63
  fails "Regexp.compile works by default for subclasses with overridden #initialize" # Expected /hi/ (Regexp) to be kind of RegexpSpecsSubclass
75
64
  fails "Regexp.escape sets the encoding of the result to BINARY if any non-US-ASCII characters are present in an input String with invalid encoding" # Expected true to be false
76
65
  fails "Regexp.last_match returns nil when there is no match" # NoMethodError: undefined method `[]' for nil
77
- fails "Regexp.last_match when given a String returns a named capture" # Exception: named captures are not supported in javascript: "(?<test>[A-Z]+.*)"
78
- fails "Regexp.last_match when given a Symbol raises an IndexError when given a missing name" # Exception: named captures are not supported in javascript: "(?<test>[A-Z]+.*)"
79
- fails "Regexp.last_match when given a Symbol returns a named capture" # Exception: named captures are not supported in javascript: "(?<test>[A-Z]+.*)"
80
- fails "Regexp.last_match when given an Object coerces argument to an index using #to_int" # Exception: named captures are not supported in javascript: "(?<test>[A-Z]+.*)"
81
- fails "Regexp.last_match when given an Object raises a TypeError when unable to coerce" # Exception: named captures are not supported in javascript: "(?<test>[A-Z]+.*)"
82
66
  fails "Regexp.new given a String accepts an Integer of two or more options ORed together as the second argument" # Expected 0 == 0 to be falsy but was true
83
67
  fails "Regexp.new given a String raises a RegexpError when passed an incorrect regexp"
84
68
  fails "Regexp.new given a String with escaped characters raises a RegexpError if \\x is not followed by any hexadecimal digits"
@@ -0,0 +1,12 @@
1
+ # NOTE: run bin/format-filters after changing this file
2
+ opal_filter "TracePoint" do
3
+ fails "TracePoint#inspect returns a String showing the event and thread for :thread_begin event" # RuntimeError: Only the :class event is supported
4
+ fails "TracePoint#inspect returns a String showing the event and thread for :thread_end event" # RuntimeError: Only the :class event is supported
5
+ fails "TracePoint#inspect returns a String showing the event, method, path and line for a :c_call event" # RuntimeError: Only the :class event is supported
6
+ fails "TracePoint#inspect returns a String showing the event, method, path and line for a :call event" # RuntimeError: Only the :class event is supported
7
+ fails "TracePoint#inspect returns a String showing the event, method, path and line for a :return event" # RuntimeError: Only the :class event is supported
8
+ fails "TracePoint#inspect returns a String showing the event, path and line for a :class event"
9
+ fails "TracePoint#inspect returns a String showing the event, path and line"
10
+ fails "TracePoint#inspect returns a string containing a human-readable TracePoint status"
11
+ fails "TracePoint#self return the trace object from event"
12
+ end
@@ -19,10 +19,6 @@ opal_filter "warnings" do
19
19
  fails "Regexp.new given a Regexp does not honour options given as additional arguments" # Expected warning to match: /flags ignored/
20
20
  fails "String#split with String when $; is not nil warns" # Expected warning to match: /warning: \$; is set to non-nil value/ but got: ""
21
21
  fails "Struct.new overwrites previously defined constants with string as first argument" # Expected warning to match: /redefining constant/
22
- fails "The defined? keyword for a variable scoped constant returns 'constant' if the constant is defined in the scope of the class variable" # Expected warning to match: /class variable access from toplevel/
23
- fails "The defined? keyword for a variable scoped constant returns nil if the class scoped constant is not defined" # Expected warning to match: /class variable access from toplevel/
24
- fails "The defined? keyword for an expression with logical connectives returns nil for an expression with '!' and an unset class variable" # Expected warning to match: /class variable access from toplevel/
25
- fails "The defined? keyword for an expression with logical connectives returns nil for an expression with 'not' and an unset class variable" # Expected warning to match: /class variable access from toplevel/
26
22
  fails "The for expression allows a constant as an iterator name" # Expected warning to match: /already initialized constant/
27
23
  fails "The predefined global constants includes FALSE" # Expected warning to match: /constant ::FALSE is deprecated/
28
24
  fails "The predefined global constants includes NIL" # Expected warning to match: /constant ::NIL is deprecated/
@@ -72,6 +72,8 @@ opal_unsupported_filter "freezing" do
72
72
  fails "Date constants freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES"
73
73
  fails "Enumerable#sort doesn't raise an error if #to_a returns a frozen Array"
74
74
  fails "Enumerator#initialize on frozen instance raises a RuntimeError"
75
+ fails "Enumerator::Generator#initialize on frozen instance raises a RuntimeError" # Expected RuntimeError but no exception was raised (#<Proc:0x1b314> was returned)
76
+ fails "Enumerator::Lazy#initialize on frozen instance raises a RuntimeError" # Expected RuntimeError but no exception was raised (nil was returned)
75
77
  fails "FalseClass#to_s returns a frozen string" # Expected "false".frozen? to be truthy but was false
76
78
  fails "File.basename returns a new unfrozen String" # Expected "foo.rb" not to be identical to "foo.rb"
77
79
  fails "FrozenError#receiver should return frozen object that modification was attempted on" # RuntimeError: RuntimeError
@@ -15,6 +15,9 @@ opal_unsupported_filter "private" do
15
15
  fails "Defining an 'initialize_copy' method sets the method's visibility to private"
16
16
  fails "Defining an 'initialize_dup' method sets the method's visibility to private"
17
17
  fails "Enumerator#initialize is a private method"
18
+ fails "Enumerator::Generator#initialize is a private method" # Expected Enumerator::Generator to have private instance method 'initialize' but it does not
19
+ fails "Enumerator::Lazy#initialize is a private method" # Expected Enumerator::Lazy to have private instance method 'initialize' but it does not
20
+ fails "Enumerator::Yielder#initialize is a private method" # Expected Enumerator::Yielder to have private instance method 'initialize' but it does not
18
21
  fails "Invoking a private getter method does not permit self as a receiver"
19
22
  fails "Kernel#block_given? is a private method"
20
23
  fails "Kernel#eval is a private method"
@@ -107,6 +110,7 @@ opal_unsupported_filter "private" do
107
110
  fails "Kernel.proc is a private method"
108
111
  fails "Kernel.rand is a private method"
109
112
  fails "Kernel.srand is a private method"
113
+ fails "Matrix.new is private" # Expected Matrix to have private method 'new' but it does not
110
114
  fails "Method#== missing methods calls respond_to_missing? with true to include private methods"
111
115
  fails "Method#eql? missing methods calls respond_to_missing? with true to include private methods"
112
116
  fails "Module#alias_method aliasing special methods keeps initialize private when aliasing"
@@ -18,7 +18,8 @@ RSpec.describe Opal::Compiler do
18
18
  describe 'requirable' do
19
19
  it 'executes the file' do
20
20
  expect_compiled("").to include('(function(Opal) {')
21
- expect_compiled("").to end_with("})(Opal);\n")
21
+ expect_compiled("").to start_with('Opal.queue(function(Opal) {')
22
+ expect_compiled("").to end_with("});\n")
22
23
  end
23
24
 
24
25
  it 'puts the compiled into "Opal.modules"' do
@@ -42,6 +43,11 @@ RSpec.describe Opal::Compiler do
42
43
  expect_compiled('"hello #{100}"').to include('"hello "', '100')
43
44
  end
44
45
 
46
+ it "should compile ruby strings with escapes" do
47
+ expect_compiled('"hello \e"').to include('\u001b')
48
+ expect_compiled('"hello \e#{nil}"').to include('\u001b')
49
+ end
50
+
45
51
  it "should compile ruby ranges" do
46
52
  expect_compiled('1..1').to include('$range(1, 1, false)')
47
53
  expect_compiled('1...1').to include('$range(1, 1, true)')
@@ -1,7 +1,7 @@
1
1
  require 'lib/spec_helper'
2
2
  require 'opal/repl'
3
3
 
4
- RSpec.describe Opal::REPL, skip: RUBY_PLATFORM != 'ruby' do
4
+ RSpec.describe Opal::REPL do
5
5
  describe '#eval_ruby' do
6
6
  let(:input_and_output) { {
7
7
  'puts 5' => "5\n=> nil\n",
@@ -16,10 +16,12 @@ RSpec.describe Opal::REPL, skip: RUBY_PLATFORM != 'ruby' do
16
16
  subject(:repl) { described_class.new }
17
17
 
18
18
  it 'evaluates user inputs' do
19
+ repl.colorize = false
20
+
19
21
  repl.load_opal
20
22
 
21
23
  input_and_output.each do |input, output|
22
- expect { repl.run_line(input) }.to output(output).to_stdout
24
+ expect { repl.eval_ruby(input) }.to output(output).to_stdout
23
25
  end
24
26
 
25
27
  repl.finish
@@ -49,7 +49,7 @@ RSpec.describe Opal::SourceMap::File do
49
49
  sourceRoot: '',
50
50
  sources: ['foo.rb'],
51
51
  sourcesContent: ["puts 5\n\nputs 6"],
52
- names: ['puts', '5', '6'],
52
+ names: ['self', 'puts', '5', '6'],
53
53
  mappings: nil,
54
54
  )
55
55
 
@@ -124,17 +124,17 @@ class BrowserFormatter < BaseOpalFormatter
124
124
  end
125
125
  end
126
126
 
127
- class NodeJSFormatter < BaseOpalFormatter
127
+ class ColoredDottedFormatter < BaseOpalFormatter
128
128
  def red(str)
129
- `process.stdout.write("\u001b[31m"+#{str}+"\u001b[0m")`
129
+ print "\e[31m"+str+"\e[0m"
130
130
  end
131
131
 
132
132
  def green(str)
133
- `process.stdout.write("\u001b[32m"+#{str}+"\u001b[0m")`
133
+ print "\e[32m"+str+"\e[0m"
134
134
  end
135
135
 
136
136
  def cyan(str)
137
- `process.stdout.write("\u001b[36m"+#{str}+"\u001b[0m")`
137
+ print "\e[36m"+str+"\e[0m"
138
138
  end
139
139
 
140
140
  def log(str)
@@ -159,6 +159,20 @@ class NodeJSFormatter < BaseOpalFormatter
159
159
  end
160
160
  end
161
161
 
162
+ class NodeJSFormatter < ColoredDottedFormatter
163
+ def red(str)
164
+ `process.stdout.write("\u001b[31m"+#{str}+"\u001b[0m")`
165
+ end
166
+
167
+ def green(str)
168
+ `process.stdout.write("\u001b[32m"+#{str}+"\u001b[0m")`
169
+ end
170
+
171
+ def cyan(str)
172
+ `process.stdout.write("\u001b[36m"+#{str}+"\u001b[0m")`
173
+ end
174
+ end
175
+
162
176
  class NodeJSDocFormatter < NodeJSFormatter
163
177
  def before(example)
164
178
  print example.description
@@ -81,6 +81,7 @@ class OSpecFormatter
81
81
  'chrome' => DottedFormatter,
82
82
  'node' => NodeJSFormatter,
83
83
  'nodejs' => NodeJSFormatter,
84
+ 'gjs' => ColoredDottedFormatter,
84
85
  'nodedoc' => NodeJSDocFormatter,
85
86
  'nodejsdoc' => NodeJSDocFormatter,
86
87
  'dotted' => DottedFormatter
@@ -153,8 +154,7 @@ end
153
154
  module OutputSilencer
154
155
  def silence_stdout
155
156
  original_stdout = $stdout
156
- new_stdout = IO.new
157
- new_stdout.extend IO::Writable
157
+ new_stdout = IO.new(1, 'w')
158
158
  new_stdout.write_proc = ->s{}
159
159
 
160
160
  begin
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe "TrueClass/FalseClass" do
4
+ it 'correctly resolves a boolean class' do
5
+ expect(true.class).to eq(TrueClass)
6
+ expect(false.class).to eq(FalseClass)
7
+
8
+ expect(true.class).not_to eq(false.class)
9
+ end
10
+
11
+ it 'correctly resolves a boolean class with #is_a?' do
12
+ expect(true.is_a? TrueClass).to be_true
13
+ expect(false.is_a? FalseClass).to be_true
14
+ expect(false.is_a? TrueClass).to be_false
15
+ expect(true.is_a? FalseClass).to be_false
16
+ end
17
+
18
+ it 'correctly resolves a boolean class with #===' do
19
+ expect(TrueClass === true).to be_true
20
+ expect(FalseClass === false).to be_true
21
+ expect(TrueClass === false).to be_false
22
+ expect(FalseClass === true).to be_false
23
+ expect(TrueClass === 6).to be_false
24
+ expect(true === true).to be_true
25
+ expect(false === false).to be_true
26
+ end
27
+
28
+ it 'allows defining methods on TrueClass/FalseClass' do
29
+ class TrueClass
30
+ def test_opal
31
+ false
32
+ end
33
+ end
34
+
35
+ class FalseClass
36
+ def test_opal
37
+ true
38
+ end
39
+ end
40
+
41
+ expect(true.test_opal).to be_false
42
+ expect(false.test_opal).to be_true
43
+ end
44
+ end
@@ -0,0 +1,8 @@
1
+ describe 'Hash' do
2
+ it 'works with object-strings with regards to deleting' do
3
+ h = {`new String('a')` => 'a'}
4
+ k = h.keys.first
5
+ h.delete(k)
6
+ h.inspect.should == '{}'
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Number#to_s' do
4
+ it "should convert 0.0 to '0.0'" do
5
+ 0.0.to_s.should == '0'
6
+ end
7
+
8
+ it "should convert -0.0 to '-0.0'" do
9
+ -0.0.to_s.should == '-0.0'
10
+ end
11
+ end
@@ -3,7 +3,7 @@ require 'json'
3
3
  describe "Hash#to_json" do
4
4
  it "returns a string of all key and value pairs" do
5
5
  {}.to_json.should == "{}"
6
- {"a" => 1, "b" => 2}.to_json.should == '{"a":1, "b":2}'
6
+ {"a" => 1, "b" => 2}.to_json.should == '{"a":1,"b":2}'
7
7
 
8
8
  hash = {"a" => 1, "b" => false, "c" => nil, "d" => true}
9
9
  JSON.parse(hash.to_json).should == hash
@@ -13,8 +13,8 @@ end
13
13
  describe "Array#to_json" do
14
14
  it "returns a string of all array elements converted to json" do
15
15
  [].to_json.should == "[]"
16
- [1, 2, 3].to_json.should == "[1, 2, 3]"
17
- [true, nil, false, "3", 42].to_json.should == '[true, null, false, "3", 42]'
16
+ [1, 2, 3].to_json.should == "[1,2,3]"
17
+ [true, nil, false, "3", 42].to_json.should == '[true,null,false,"3",42]'
18
18
  end
19
19
  end
20
20
 
@@ -301,8 +301,17 @@ describe Logger do
301
301
  rescue => e
302
302
  message = e
303
303
  end
304
+
305
+ # Disable formatting for #full_message by making sure we are not on a tty
306
+ tty = $stderr.JS[:tty]
307
+ $stderr.JS[:tty] = false
308
+
304
309
  @logger.debug(message).should == true
305
- @pipe.string.should =~ / message \(ArgumentError\)\nArgumentError: message\n from /
310
+
311
+ # Restore a tty status
312
+ $stderr.JS[:tty] = tty
313
+
314
+ @pipe.string.should =~ / message \(ArgumentError\)\n\tfrom /
306
315
  end
307
316
  end
308
317
  end
data/spec/ruby_specs CHANGED
@@ -27,6 +27,9 @@ ruby/core/array/pack/u_spec
27
27
  !ruby/core/array/pack/z_spec
28
28
 
29
29
  ruby/core/basicobject
30
+
31
+ ruby/core/binding
32
+
30
33
  ruby/core/builtin_constants
31
34
  ruby/core/class
32
35
  ruby/core/comparable
@@ -36,6 +39,11 @@ ruby/core/complex
36
39
 
37
40
  ruby/core/enumerable
38
41
  ruby/core/enumerator
42
+ !ruby/core/enumerator/arithmetic_sequence
43
+ !ruby/core/enumerator/chain
44
+ ruby/core/enumerator/generator
45
+ ruby/core/enumerator/lazy
46
+ ruby/core/enumerator/yielder
39
47
 
40
48
  ruby/core/exception
41
49
  !ruby/core/exception/load_error_spec
@@ -90,6 +98,8 @@ ruby/core/kernel
90
98
  !ruby/core/kernel/untrusted_spec
91
99
  !ruby/core/kernel/untrust_spec
92
100
 
101
+ ruby/core/main
102
+
93
103
  ruby/core/matchdata
94
104
  ruby/core/math
95
105
 
@@ -152,6 +162,9 @@ ruby/core/time
152
162
  !ruby/core/time/_dump_spec
153
163
  !ruby/core/time/_load_spec
154
164
 
165
+ ruby/core/tracepoint/inspect_spec
166
+ ruby/core/tracepoint/self_spec
167
+
155
168
  ruby/core/true
156
169
  ruby/core/unboundmethod
157
170
 
@@ -177,6 +190,11 @@ ruby/library/openstruct
177
190
  ruby/library/pathname
178
191
  !ruby/library/pathname/empty_spec
179
192
  !ruby/library/pathname/glob_spec
193
+ ruby/library/matrix
194
+ ruby/library/matrix/eigenvalue_decomposition
195
+ ruby/library/matrix/lup_decomposition
196
+ ruby/library/matrix/scalar
197
+ ruby/library/matrix/vector
180
198
  ruby/library/pp
181
199
  ruby/library/securerandom
182
200
  ruby/library/set