opal 1.5.1 → 1.6.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +4 -1
  3. data/HACKING.md +23 -0
  4. data/UNRELEASED.md +42 -0
  5. data/benchmark/run.rb +1 -0
  6. data/docs/compiled_ruby.md +8 -0
  7. data/docs/compiler.md +1 -1
  8. data/docs/compiler_directives.md +1 -1
  9. data/docs/getting_started.md +17 -0
  10. data/docs/headless_chrome.md +1 -1
  11. data/docs/index.md +123 -0
  12. data/docs/templates.md +37 -37
  13. data/docs/unsupported_features.md +0 -4
  14. data/lib/opal/builder.rb +59 -39
  15. data/lib/opal/builder_scheduler/prefork.rb +259 -0
  16. data/lib/opal/builder_scheduler/sequential.rb +13 -0
  17. data/lib/opal/builder_scheduler.rb +29 -0
  18. data/lib/opal/cache/file_cache.rb +5 -0
  19. data/lib/opal/cli.rb +22 -18
  20. data/lib/opal/cli_options.rb +4 -0
  21. data/lib/opal/cli_runners/chrome.rb +13 -9
  22. data/lib/opal/cli_runners/chrome_cdp_interface.rb +19 -2
  23. data/lib/opal/cli_runners/compiler.rb +1 -1
  24. data/lib/opal/cli_runners/gjs.rb +3 -1
  25. data/lib/opal/cli_runners/mini_racer.rb +5 -3
  26. data/lib/opal/cli_runners/nodejs.rb +3 -3
  27. data/lib/opal/cli_runners/server.rb +13 -28
  28. data/lib/opal/cli_runners/system_runner.rb +5 -3
  29. data/lib/opal/cli_runners.rb +7 -6
  30. data/lib/opal/compiler.rb +25 -2
  31. data/lib/opal/config.rb +10 -0
  32. data/lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb +2 -6
  33. data/lib/opal/nodes/args/extract_kwarg.rb +3 -4
  34. data/lib/opal/nodes/args/extract_kwargs.rb +3 -1
  35. data/lib/opal/nodes/args/extract_kwoptarg.rb +1 -1
  36. data/lib/opal/nodes/args/extract_kwrestarg.rb +4 -1
  37. data/lib/opal/nodes/args/extract_optarg.rb +1 -1
  38. data/lib/opal/nodes/args/extract_post_arg.rb +1 -1
  39. data/lib/opal/nodes/args/extract_post_optarg.rb +1 -1
  40. data/lib/opal/nodes/args/extract_restarg.rb +2 -2
  41. data/lib/opal/nodes/args/initialize_iterarg.rb +1 -1
  42. data/lib/opal/nodes/args/initialize_shadowarg.rb +1 -1
  43. data/lib/opal/nodes/args/prepare_post_args.rb +4 -2
  44. data/lib/opal/nodes/base.rb +14 -3
  45. data/lib/opal/nodes/call.rb +10 -14
  46. data/lib/opal/nodes/class.rb +3 -1
  47. data/lib/opal/nodes/closure.rb +250 -0
  48. data/lib/opal/nodes/def.rb +7 -11
  49. data/lib/opal/nodes/definitions.rb +4 -2
  50. data/lib/opal/nodes/if.rb +12 -2
  51. data/lib/opal/nodes/iter.rb +11 -17
  52. data/lib/opal/nodes/logic.rb +15 -63
  53. data/lib/opal/nodes/module.rb +3 -1
  54. data/lib/opal/nodes/rescue.rb +23 -15
  55. data/lib/opal/nodes/scope.rb +7 -1
  56. data/lib/opal/nodes/top.rb +27 -4
  57. data/lib/opal/nodes/while.rb +42 -26
  58. data/lib/opal/nodes.rb +1 -0
  59. data/lib/opal/os.rb +59 -0
  60. data/lib/opal/rewriter.rb +2 -0
  61. data/lib/opal/rewriters/returnable_logic.rb +14 -0
  62. data/lib/opal/rewriters/thrower_finder.rb +90 -0
  63. data/lib/opal/simple_server.rb +12 -6
  64. data/lib/opal/source_map/file.rb +1 -1
  65. data/lib/opal/source_map/map.rb +9 -1
  66. data/lib/opal/util.rb +1 -1
  67. data/lib/opal/version.rb +1 -1
  68. data/opal/corelib/array.rb +68 -3
  69. data/opal/corelib/basic_object.rb +1 -0
  70. data/opal/corelib/comparable.rb +1 -1
  71. data/opal/corelib/complex.rb +1 -0
  72. data/opal/corelib/constants.rb +2 -2
  73. data/opal/corelib/enumerable.rb +4 -2
  74. data/opal/corelib/enumerator/chain.rb +4 -0
  75. data/opal/corelib/enumerator/generator.rb +5 -3
  76. data/opal/corelib/enumerator/lazy.rb +3 -1
  77. data/opal/corelib/enumerator/yielder.rb +2 -4
  78. data/opal/corelib/enumerator.rb +3 -1
  79. data/opal/corelib/error/errno.rb +2 -1
  80. data/opal/corelib/error.rb +13 -2
  81. data/opal/corelib/hash.rb +39 -1
  82. data/opal/corelib/kernel.rb +56 -5
  83. data/opal/corelib/module.rb +60 -4
  84. data/opal/corelib/proc.rb +8 -5
  85. data/opal/corelib/rational.rb +1 -0
  86. data/opal/corelib/regexp.rb +15 -1
  87. data/opal/corelib/runtime.js +307 -238
  88. data/opal/corelib/string/encoding.rb +0 -6
  89. data/opal/corelib/string.rb +28 -7
  90. data/opal/corelib/time.rb +5 -2
  91. data/opal/corelib/unsupported.rb +2 -14
  92. data/spec/filters/bugs/delegate.rb +11 -0
  93. data/spec/filters/bugs/kernel.rb +1 -3
  94. data/spec/filters/bugs/language.rb +3 -23
  95. data/spec/filters/bugs/method.rb +0 -1
  96. data/spec/filters/bugs/module.rb +0 -3
  97. data/spec/filters/bugs/proc.rb +0 -3
  98. data/spec/filters/bugs/set.rb +4 -16
  99. data/spec/filters/bugs/unboundmethod.rb +0 -2
  100. data/spec/filters/unsupported/array.rb +0 -58
  101. data/spec/filters/unsupported/freeze.rb +8 -192
  102. data/spec/filters/unsupported/hash.rb +0 -25
  103. data/spec/filters/unsupported/kernel.rb +0 -1
  104. data/spec/filters/unsupported/privacy.rb +17 -0
  105. data/spec/lib/builder_spec.rb +14 -0
  106. data/spec/lib/cli_runners/server_spec.rb +2 -3
  107. data/spec/lib/cli_spec.rb +1 -1
  108. data/spec/lib/compiler_spec.rb +1 -1
  109. data/spec/opal/core/language/if_spec.rb +13 -0
  110. data/spec/opal/core/module_spec.rb +8 -0
  111. data/spec/ruby_specs +2 -1
  112. data/stdlib/await.rb +44 -7
  113. data/stdlib/delegate.rb +427 -6
  114. data/stdlib/headless_chrome.rb +6 -2
  115. data/stdlib/nodejs/file.rb +2 -1
  116. data/stdlib/opal-parser.rb +1 -1
  117. data/stdlib/opal-platform.rb +1 -1
  118. data/stdlib/opal-replutils.rb +5 -3
  119. data/stdlib/promise.rb +3 -0
  120. data/stdlib/rbconfig.rb +4 -1
  121. data/stdlib/ruby2_keywords.rb +60 -0
  122. data/stdlib/set.rb +21 -0
  123. data/tasks/performance.rake +41 -35
  124. data/tasks/releasing.rake +1 -0
  125. data/tasks/testing/mspec_special_calls.rb +1 -0
  126. data/tasks/testing.rake +5 -5
  127. data/test/nodejs/test_await.rb +39 -1
  128. metadata +27 -14
  129. data/docs/faq.md +0 -17
  130. data/lib/opal/rewriters/break_finder.rb +0 -36
  131. data/spec/opal/core/kernel/freeze_spec.rb +0 -15
@@ -403,12 +403,6 @@ class ::String
403
403
  }
404
404
  end
405
405
 
406
- def length
407
- `self.length`
408
- end
409
-
410
- alias size length
411
-
412
406
  # stub
413
407
  def valid_encoding?
414
408
  true
@@ -1,4 +1,4 @@
1
- # helpers: coerce_to, respond_to, global_multiline_regexp
1
+ # helpers: coerce_to, respond_to, global_multiline_regexp, prop
2
2
 
3
3
  require 'corelib/comparable'
4
4
  require 'corelib/regexp'
@@ -339,10 +339,21 @@ class ::String < `String`
339
339
  `self.charAt(0)`
340
340
  end
341
341
 
342
- def clone
342
+ def clone(freeze: nil)
343
+ unless freeze.nil? || freeze == true || freeze == false
344
+ raise ArgumentError, "unexpected value for freeze: #{freeze.class}"
345
+ end
346
+
343
347
  copy = `new String(self)`
344
348
  copy.copy_singleton_methods(self)
345
- copy.initialize_clone(self)
349
+ copy.initialize_clone(self, freeze: freeze)
350
+
351
+ if freeze == true
352
+ `if (!copy.$$frozen) { copy.$$frozen = true; }`
353
+ elsif freeze.nil?
354
+ `if (self.$$frozen) { copy.$$frozen = true; }`
355
+ end
356
+
346
357
  copy
347
358
  end
348
359
 
@@ -648,6 +659,12 @@ class ::String < `String`
648
659
  `self.toString()`
649
660
  end
650
661
 
662
+ def length
663
+ `self.length`
664
+ end
665
+
666
+ alias size length
667
+
651
668
  def lines(separator = $/, chomp: false, &block)
652
669
  e = each_line(separator, chomp: chomp, &block)
653
670
  block ? self : e.to_a
@@ -1317,7 +1334,7 @@ class ::String < `String`
1317
1334
  def to_proc
1318
1335
  method_name = `self.valueOf()`
1319
1336
 
1320
- ::Kernel.proc do |*args, &block|
1337
+ proc = ::Kernel.proc do |*args, &block|
1321
1338
  %x{
1322
1339
  if (args.length === 0) {
1323
1340
  #{::Kernel.raise ::ArgumentError, 'no receiver given'}
@@ -1347,6 +1364,10 @@ class ::String < `String`
1347
1364
  }
1348
1365
  }
1349
1366
  end
1367
+
1368
+ `proc.$$source_location = nil`
1369
+
1370
+ proc
1350
1371
  end
1351
1372
 
1352
1373
  def to_s
@@ -1832,8 +1853,8 @@ class ::String < `String`
1832
1853
 
1833
1854
  def freeze
1834
1855
  %x{
1835
- if (typeof self === 'string') return self;
1836
- self.$$frozen = true;
1856
+ if (typeof self === 'string') { return self; }
1857
+ $prop(self, "$$frozen", true);
1837
1858
  return self;
1838
1859
  }
1839
1860
  end
@@ -1841,7 +1862,7 @@ class ::String < `String`
1841
1862
  def -@
1842
1863
  %x{
1843
1864
  if (typeof self === 'string') return self;
1844
- if (self.$$frozen === true) return self;
1865
+ if (self.$$frozen) return self;
1845
1866
  if (self.encoding.name == 'UTF-8' && self.internal_encoding.name == 'UTF-8') return self.toString();
1846
1867
  return self.$dup().$freeze();
1847
1868
  }
data/opal/corelib/time.rb CHANGED
@@ -1,4 +1,4 @@
1
- # helpers: slice
1
+ # helpers: slice, deny_frozen_access
2
2
 
3
3
  require 'corelib/comparable'
4
4
 
@@ -445,7 +445,10 @@ class ::Time < `Date`
445
445
 
446
446
  def gmtime
447
447
  %x{
448
- self.timezone = 0;
448
+ if (self.timezone !== 0) {
449
+ $deny_frozen_access(self);
450
+ self.timezone = 0;
451
+ }
449
452
  return self;
450
453
  }
451
454
  end
@@ -38,20 +38,6 @@ class ::String
38
38
  end
39
39
  end
40
40
 
41
- module ::Kernel
42
- `var ERROR = "Object freezing is not supported by Opal"`
43
-
44
- def freeze
45
- `handle_unsupported_feature(ERROR)`
46
- self
47
- end
48
-
49
- def frozen?
50
- `handle_unsupported_feature(ERROR)`
51
- false
52
- end
53
- end
54
-
55
41
  module ::Kernel
56
42
  `var ERROR = "Object tainting is not supported by Opal"`
57
43
 
@@ -108,7 +94,9 @@ module ::Kernel
108
94
  []
109
95
  end
110
96
 
97
+ alias protected_methods private_methods
111
98
  alias private_instance_methods private_methods
99
+ alias protected_instance_methods private_methods
112
100
  end
113
101
 
114
102
  module ::Kernel
@@ -0,0 +1,11 @@
1
+ # NOTE: run bin/format-filters after changing this file
2
+ opal_filter "Delegate" do
3
+ fails "Delegator#!= is delegated in general" # Exception: Maximum call stack size exceeded
4
+ fails "Delegator#== is delegated in general" # Exception: Maximum call stack size exceeded
5
+ fails "Delegator#method raises a NameError if method is no longer valid because object has changed" # Expected NameError but no exception was raised ("foo" was returned)
6
+ fails "Delegator#method returns a method that respond_to_missing?" # NameError: undefined method `pub_too' for class `DelegateSpecs::Simple'
7
+ fails "Delegator#methods includes instance methods of the Delegator class" # Expected ["singleton_method", "pub", "respond_to_missing?", "method_missing", "priv", "prot", "to_json", "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", "DelegateClass", "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", "be_close_to_matrix", "example_instance_method_of_object", "check_autoload", "main_public_method", "main_public_method2", "main_private_method", "main_private_method2", "lang_send_rest_len", "toplevel_define_other_method", "some_toplevel_method", "public_toplevel_method", "defined_specs_method", "defined_specs_receiver", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "=~", "!~", "===", "<=>", "method", "methods", "public_methods", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "initialize_clone", "define_singleton_method", "dup", "initialize_dup", "enum_for", "equal?", "exit", "extend", "gets", "hash", "initialize_copy", "inspect", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "to_s", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "freeze", "frozen?", "taint", "untaint", "tainted?", "private_methods", "protected_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel", "__send__", "__id__", "==", "!", "initialize", "eql?", "!=", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "__marshal__"] to include "extra"
8
+ fails "Delegator#tap yield the delegator object" # Expected 0 == 1 to be truthy but was false
9
+ fails "SimpleDelegator can be marshalled with its instance variables intact" # Exception: Cannot create property 'foo' on string 'hello'
10
+ fails "SimpleDelegator can be marshalled" # Expected String == SimpleDelegator to be truthy but was false
11
+ end
@@ -109,7 +109,7 @@ opal_filter "Kernel" do
109
109
  fails "Kernel#p flushes output if receiver is a File"
110
110
  fails "Kernel#p is not affected by setting $\\, $/ or $,"
111
111
  fails "Kernel#pp lazily loads the 'pp' library and delegates the call to that library" # NoMethodError: undefined method `tmp' for #<MSpecEnv:0x4f28>
112
- fails "Kernel#print prints $_ when no arguments are given" # Expected: $stdout: "foo" got: $stdout: ""
112
+ fails "Kernel#print prints $_ when no arguments are given" # Expected: $stdout: "foo" got: $stdout: ""
113
113
  fails "Kernel#public_method changes the method called for super on a target aliased method"
114
114
  fails "Kernel#public_method raises a NameError if we only repond_to_missing? method, true"
115
115
  fails "Kernel#public_method returns a method object for a valid method"
@@ -316,10 +316,8 @@ opal_filter "Kernel" do
316
316
  fails "Kernel.global_variables finds subset starting with std"
317
317
  fails "Kernel.lambda does not create lambda-style Procs when captured with #method" # Expected true to be false
318
318
  fails "Kernel.lambda raises an ArgumentError when no block is given"
319
- fails "Kernel.lambda returns from the lambda itself, not the creation site of the lambda"
320
319
  fails "Kernel.lambda returns the passed Proc if given an existing Proc through super" # Expected true to be false
321
320
  fails "Kernel.lambda returns the passed Proc if given an existing Proc" # Expected true to be false
322
- fails "Kernel.lambda treats the block as a Proc when lambda is re-defined" # Expected 2 == 1 to be truthy but was false
323
321
  fails "Kernel.loop returns StopIteration#result, the result value of a finished iterator" # requires changes in enumerator.rb
324
322
  fails "Kernel.printf calls write on the first argument when it is not a string"
325
323
  fails "Kernel.printf formatting io is not specified other formats s preserves encoding of the format string" # Expected #<Encoding:UTF-8> == #<Encoding:ASCII-8BIT (dummy)> to be truthy but was false
@@ -52,7 +52,7 @@ opal_filter "language" do
52
52
  fails "A singleton class doesn't have singleton class"
53
53
  fails "A singleton class raises a TypeError for symbols"
54
54
  fails "A singleton method definition can be declared for a global variable"
55
- fails "A singleton method definition raises FrozenError with the correct class name" # Expected FrozenError but no exception was raised ("foo" was returned)
55
+ fails "A singleton method definition raises FrozenError with the correct class name" # Expected "can't modify frozen Class: #<Class:#<Object:0x80db0>>".start_with? "can't modify frozen object" to be truthy but was false
56
56
  fails "Accessing a class variable raises a RuntimeError when a class variable is overtaken in an ancestor class" # Expected RuntimeError (/class variable @@cvar_overtaken of .+ is overtaken by .+/) but no exception was raised ("subclass" was returned)
57
57
  fails "Accessing a class variable raises a RuntimeError when accessed from the toplevel scope (not in some module or class)" # Expected RuntimeError (class variable access from toplevel) but got: NameError (uninitialized class variable @@cvar_toplevel1 in MSpecEnv)
58
58
  fails "Allowed characters allows non-ASCII lowercased characters at the beginning" # Expected nil == 1 to be truthy but was false
@@ -62,14 +62,13 @@ opal_filter "language" do
62
62
  fails "An ensure block inside a begin block is executed even when a symbol is thrown in it's corresponding begin block"
63
63
  fails "An ensure block inside a class is executed even when a symbol is thrown" # Expected ["class", "rescue", "ensure"] to equal ["class", "ensure"]
64
64
  fails "An instance method definition with a splat requires the presence of any arguments that precede the *" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(1 for -3)
65
- fails "An instance method raises FrozenError with the correct class name" # Expected FrozenError but no exception was raised (#<Module:0x225b4> was returned)
65
+ fails "An instance method raises FrozenError with the correct class name" # Expected "can't modify frozen Module: #<Module:0x80c36>".start_with? "can't modify frozen module" to be truthy but was false
66
66
  fails "An instance method raises an error with too few arguments" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(1 for 2)
67
67
  fails "An instance method raises an error with too many arguments" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(2 for 1)
68
68
  fails "An instance method with a default argument evaluates the default when required arguments precede it" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(0 for -2)
69
69
  fails "An instance method with a default argument prefers to assign to a default argument before a splat argument" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(0 for -2)
70
70
  fails "Assigning an anonymous module to a constant sets the name of a module scoped by an anonymous module" # NoMethodError: undefined method `end_with?' for nil
71
71
  fails "Executing break from within a block raises LocalJumpError when converted into a proc during a a super call" # Expected LocalJumpError but no exception was raised (1 was returned)
72
- fails "Executing break from within a block returns from the original invoking method even in case of chained calls"
73
72
  fails "Executing break from within a block works when passing through a super call" # Expected to not get Exception
74
73
  fails "Execution variable $: is initialized to an array of strings"
75
74
  fails "Execution variable $: is read-only"
@@ -176,7 +175,7 @@ opal_filter "language" do
176
175
  fails "Operators * / % are left-associative"
177
176
  fails "Operators <=> == === != =~ !~ have higher precedence than &&" # Expected false == false to be falsy but was true
178
177
  fails "Optional constant assignment with ||= causes side-effects of the module part to be applied (for nil constant)" # Expected 3 == 1 to be truthy but was false
179
- fails "Optional constant assignment with ||= causes side-effects of the module part to be applied only once (for undefined constant)" # Expected 2 == 1 to be truthy but was false
178
+ fails "Optional constant assignment with ||= causes side-effects of the module part to be applied only once (for undefined constant)" # Expected 2 == 1 to be truthy but was false
180
179
  fails "Optional variable assignments using compounded constants with &&= assignments" # Expected warning to match: /already initialized constant/ but got: ""
181
180
  fails "Optional variable assignments using compounded constants with operator assignments" # Expected warning to match: /already initialized constant/ but got: ""
182
181
  fails "Pattern matching Array pattern calls #deconstruct once for multiple patterns, caching the result" # Expected ["deconstruct", "deconstruct"] == ["deconstruct"] to be truthy but was false
@@ -248,15 +247,6 @@ opal_filter "language" do
248
247
  fails "The break statement in a lambda created at the toplevel returns a value when invoking from a block"
249
248
  fails "The break statement in a lambda created at the toplevel returns a value when invoking from a method"
250
249
  fails "The break statement in a lambda created at the toplevel returns a value when invoking from the toplevel"
251
- fails "The break statement in a lambda from a scope that has returned raises a LocalJumpError when yielding to a lambda passed as a block argument"
252
- fails "The break statement in a lambda from a scope that has returned returns a value to the block scope invoking the lambda in a method" # Exception: $brk is not defined
253
- fails "The break statement in a lambda from a scope that has returned returns a value to the method scope invoking the lambda" # Exception: $brk is not defined
254
- fails "The break statement in a lambda returns from the call site if the lambda is passed as a block" # Expected ["before", "unreachable1", "unreachable2", "after"] to equal ["before", "after"]
255
- fails "The break statement in a lambda when the invocation of the scope creating the lambda is still active returns a value to a block scope invoking the lambda in a method below" # Exception: $brk is not defined
256
- fails "The break statement in a lambda when the invocation of the scope creating the lambda is still active returns a value to the method scope below invoking the lambda" # Exception: $brk is not defined
257
- fails "The break statement in a lambda when the invocation of the scope creating the lambda is still active returns a value to the scope creating and calling the lambda" # Exception: $brk is not defined
258
- fails "The break statement in a lambda when the invocation of the scope creating the lambda is still active returns from the lambda" # Exception: unexpected break
259
- fails "The break statement in a lambda when the invocation of the scope creating the lambda is still active returns nil when not passed an argument" # Exception: $brk is not defined
260
250
  fails "The class keyword does not raise a SyntaxError when opening a class without a semicolon" # NameError: uninitialized constant ClassSpecsKeywordWithoutSemicolon
261
251
  fails "The def keyword within a closure looks outside the closure for the visibility"
262
252
  fails "The defined? keyword for a scoped constant returns nil when a constant is defined on top-level but not on the class" # Expected "constant" to be nil
@@ -280,7 +270,6 @@ opal_filter "language" do
280
270
  fails "The defined? keyword when called with a method name without a receiver returns 'method' if the method is defined" # Expected false == true to be truthy but was false
281
271
  fails "The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with exclusive-end range"
282
272
  fails "The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with inclusive-end range"
283
- fails "The or operator has a lower precedence than 'next' in 'next true or false'"
284
273
  fails "The redo statement in a method is invalid and raises a SyntaxError" # Expected SyntaxError but no exception was raised ("m" was returned)
285
274
  fails "The redo statement triggers ensure block when re-executing a block"
286
275
  fails "The rescue keyword allows rescue in 'do end' block" # NoMethodError: undefined method `call' for nil
@@ -294,11 +283,6 @@ opal_filter "language" do
294
283
  fails "The super keyword uses given block even if arguments are passed explicitly"
295
284
  fails "The throw keyword raises an UncaughtThrowError if used to exit a thread" # NotImplementedError: Thread creation not available
296
285
  fails "The unpacking splat operator (*) when applied to a BasicObject coerces it to Array if it respond_to?(:to_a)" # NoMethodError: undefined method `respond_to?' for BasicObject
297
- fails "The until expression restarts the current iteration without reevaluating condition with redo"
298
- fails "The until modifier restarts the current iteration without reevaluating condition with redo"
299
- fails "The until modifier with begin .. end block restart the current iteration without reevaluating condition with redo" # Expected [1] to equal [0, 0, 0, 1, 2]
300
- fails "The while expression stops running body if interrupted by break in a begin ... end element op-assign value"
301
- fails "The while expression stops running body if interrupted by break in a parenthesized element op-assign value"
302
286
  fails "The yield call taking a single argument yielding to a lambda should not destructure an Array into multiple arguments" # Expected ArgumentError but no exception was raised ([1, 2] was returned)
303
287
  fails "The yield call taking no arguments ignores assignment to the explicit block argument and calls the passed block"
304
288
  fails "Using yield in a singleton class literal raises a SyntaxError" # Expected SyntaxError (/Invalid yield/) but got: SyntaxError (undefined method `uses_block!' for nil)
@@ -314,8 +298,4 @@ opal_filter "language" do
314
298
  fails_badly "Pattern matching refinements are used for #=== in constant pattern"
315
299
  fails_badly "Pattern matching refinements are used for #deconstruct"
316
300
  fails_badly "Pattern matching refinements are used for #deconstruct_keys"
317
- fails_badly "The while expression stops running body if interrupted by break in a begin ... end attribute op-assign-or value"
318
- fails_badly "The while expression stops running body if interrupted by break in a parenthesized attribute op-assign-or value"
319
- fails_badly "The while expression stops running body if interrupted by break with unless in a begin ... end attribute op-assign-or value"
320
- fails_badly "The while expression stops running body if interrupted by break with unless in a parenthesized attribute op-assign-or value"
321
301
  end
@@ -54,7 +54,6 @@ opal_filter "Method" do
54
54
  fails "Method#receiver for a Method generated by respond_to_missing? returns the receiver of the method"
55
55
  fails "Method#source_location for a Method generated by respond_to_missing? returns nil"
56
56
  fails "Method#source_location sets the first value to the path of the file in which the method was defined" # Expected "ruby/core/method/fixtures/classes.rb" to equal "./ruby/core/method/fixtures/classes.rb"
57
- fails "Method#source_location works for methods defined with a block"
58
57
  fails "Method#source_location works for methods defined with an UnboundMethod"
59
58
  fails "Method#super_method returns nil when the parent's method is removed"
60
59
  fails "Method#super_method returns nil when there's no super method in the parent"
@@ -14,7 +14,6 @@ opal_filter "Module" do
14
14
  fails "Module#attr_accessor converts non string/symbol names to strings using to_str" # Expected false == true to be truthy but was false
15
15
  fails "Module#attr_accessor not allows creating an attr_accessor on an immediate class"
16
16
  fails "Module#attr_accessor on immediates can read through the accessor" # NoMethodError: undefined method `foobar' for 1
17
- fails "Module#attr_accessor raises FrozenError if the receiver if frozen" # Expected FrozenError but no exception was raised (42 was returned)
18
17
  fails "Module#attr_accessor raises a TypeError when the given names can't be converted to strings using to_str"
19
18
  fails "Module#attr_accessor returns an array of defined method names as symbols" # Expected nil == ["foo", "foo=", "bar", "bar="] to be truthy but was false
20
19
  fails "Module#attr_reader applies current visibility to methods created"
@@ -25,7 +24,6 @@ opal_filter "Module" do
25
24
  fails "Module#attr_writer applies current visibility to methods created"
26
25
  fails "Module#attr_writer converts non string/symbol names to strings using to_str" # Expected false == true to be truthy but was false
27
26
  fails "Module#attr_writer not allows for adding an attr_writer to an immediate"
28
- fails "Module#attr_writer raises FrozenError if the receiver if frozen" # Expected FrozenError but no exception was raised (42 was returned)
29
27
  fails "Module#attr_writer raises a TypeError when the given names can't be converted to strings using to_str"
30
28
  fails "Module#attr_writer returns an array of defined method names as symbols" # Expected nil == ["foo=", "bar="] to be truthy but was false
31
29
  fails "Module#class_eval activates refinements from the eval scope" # NoMethodError: undefined method `foo' for #<ModuleSpecs::NamedClass:0x4a168>
@@ -135,7 +133,6 @@ opal_filter "Module" do
135
133
  fails "Module#private_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)
136
134
  fails "Module#private_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)
137
135
  fails "Module#protected with argument array as a single argument sets visibility of given method names" # NoMethodError: undefined method `protected_instance_methods' for #<Module:0x6994a>
138
- fails "Module#protected with argument does not clone method from the ancestor when setting to the same visibility in a child" # NoMethodError: undefined method `protected_instance_methods' for #<Module:0xa2d8>
139
136
  fails "Module#protected with argument one or more arguments sets visibility of given method names" # NoMethodError: undefined method `protected_instance_methods' for #<Module:0x33d4a>
140
137
  fails "Module#protected_method_defined? raises a TypeError if passed an Integer" # Expected TypeError but no exception was raised (false was returned)
141
138
  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)
@@ -45,12 +45,9 @@ opal_filter "Proc" do
45
45
  fails "Proc#ruby2_keywords prints warning when a proc does not accept argument splat" # NoMethodError: undefined method `ruby2_keywords' for #<Proc:0x3660a>
46
46
  fails "Proc#ruby2_keywords returns self" # NoMethodError: undefined method `ruby2_keywords' for #<Proc:0x36602>
47
47
  fails "Proc#source_location returns an Array"
48
- fails "Proc#source_location returns the first line of a multi-line proc (i.e. the line containing 'proc do')"
49
- fails "Proc#source_location returns the location of the proc's body; not necessarily the proc itself"
50
48
  fails "Proc#source_location returns the same value for a proc-ified method as the method reports" # Expected ["ruby/core/proc/fixtures/source_location.rb", 3] to equal nil
51
49
  fails "Proc#source_location sets the first value to the path of the file in which the proc was defined"
52
50
  fails "Proc#source_location sets the last value to an Integer representing the line on which the proc was defined" # NoMethodError: undefined method `last' for nil
53
- fails "Proc#source_location works even if the proc was created on the same line"
54
51
  fails "Proc#to_s for a proc created with Proc.new has a binary encoding" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
55
52
  fails "Proc#to_s for a proc created with Proc.new returns a description including file and line number" # Expected "#<Proc:0x17cc0>" =~ /^#<Proc:([^ ]*?)@ruby\/core\/proc\/shared\/to_s\.rb:6>$/ to be truthy but was nil
56
53
  fails "Proc#to_s for a proc created with Symbol#to_proc has a binary encoding" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
@@ -11,22 +11,10 @@ opal_filter "Set" do
11
11
  fails "Set#=== returns true when self contains the passed Object" # Expected false to be true
12
12
  fails "Set#^ raises an ArgumentError when passed a non-Enumerable"
13
13
  fails "Set#^ returns a new Set containing elements that are not in both self and the passed Enumerable" # NoMethodError: undefined method `^' for #<Set: {1,2,3,4}>
14
- fails "Set#compare_by_identity causes future comparisons on the receiver to be made by identity" # NoMethodError: undefined method `compare_by_identity' for #<Set: {1}>
15
- fails "Set#compare_by_identity compares its members by identity" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
16
- fails "Set#compare_by_identity does not call #hash on members" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
17
- fails "Set#compare_by_identity is idempotent and has no effect on an already compare_by_identity set" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
18
- fails "Set#compare_by_identity is not equal to set what does not compare by identity" # NoMethodError: undefined method `compare_by_identity' for #<Set: {1,2}>
19
- fails "Set#compare_by_identity persists over #clones" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
20
- fails "Set#compare_by_identity persists over #dups" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
21
- fails "Set#compare_by_identity regards #clone'd objects as having different identities" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
22
- fails "Set#compare_by_identity regards #dup'd objects as having different identities" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
23
- fails "Set#compare_by_identity rehashes internally so that old members can be looked up" # NoMethodError: undefined method `compare_by_identity' for #<Set: {1,2,3,4,5,6,7,8,9,10,#<Object:0x13a2>}>
24
- fails "Set#compare_by_identity returns self" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
25
- fails "Set#compare_by_identity uses #equal? semantics, but doesn't actually call #equal? to determine identity" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
26
- fails "Set#compare_by_identity uses the semantics of BasicObject#equal? to determine members identity" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
27
- fails "Set#compare_by_identity? returns false by default" # NoMethodError: undefined method `compare_by_identity?' for #<Set: {}>
28
- fails "Set#compare_by_identity? returns true once #compare_by_identity has been invoked on self" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
29
- fails "Set#compare_by_identity? returns true when called multiple times on the same set" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
14
+ fails "Set#compare_by_identity compares its members by identity" # Expected ["a", "b"] == ["a", "b", "b"] to be truthy but was false
15
+ fails "Set#compare_by_identity is not equal to set what does not compare by identity" # Expected #<Set: {1,2}> == #<Set: {1,2}> to be falsy but was true
16
+ fails "Set#compare_by_identity regards #clone'd objects as having different identities" # Expected ["a"] == ["a", "a"] to be truthy but was false
17
+ fails "Set#compare_by_identity regards #dup'd objects as having different identities" # Expected ["a"] == ["a", "a"] to be truthy but was false
30
18
  fails "Set#divide divides self into a set of subsets based on the blocks return values"
31
19
  fails "Set#divide when passed a block with an arity of 2 divides self into a set of subsets based on the blocks return values"
32
20
  fails "Set#divide when passed a block with an arity of 2 yields each two Object to the block"
@@ -14,8 +14,6 @@ opal_filter "UnboundMethod" do
14
14
  fails "UnboundMethod#original_name returns the original name even when aliased twice" # NoMethodError: undefined method `original_name' for #<UnboundMethod: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)>
15
15
  fails "UnboundMethod#original_name returns the original name" # NoMethodError: undefined method `original_name' for #<UnboundMethod: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)>
16
16
  fails "UnboundMethod#source_location sets the first value to the path of the file in which the method was defined" # Expected "ruby/core/unboundmethod/fixtures/classes.rb" to equal "./ruby/core/unboundmethod/fixtures/classes.rb"
17
- fails "UnboundMethod#source_location works for define_method methods"
18
- fails "UnboundMethod#source_location works for define_singleton_method methods"
19
17
  fails "UnboundMethod#super_method returns nil when the parent's method is removed"
20
18
  fails "UnboundMethod#super_method returns nil when there's no super method in the parent"
21
19
  fails "UnboundMethod#super_method returns the method that would be called by super in the method"
@@ -14,69 +14,43 @@ opal_unsupported_filter "Array" do
14
14
  fails "Array#* with an integer copies the untrusted status of the original array if the passed count is not 0"
15
15
  fails "Array#+ does not get infected even if an original array is tainted"
16
16
  fails "Array#+ does not infected even if an original array is untrusted"
17
- fails "Array#<< raises a RuntimeError on a frozen array"
18
17
  fails "Array#[] raises a RangeError when the length is out of range of Fixnum"
19
18
  fails "Array#[] raises a RangeError when the start index is out of range of Fixnum"
20
- fails "Array#[]= checks frozen before attempting to coerce arguments"
21
- fails "Array#[]= raises a RuntimeError on a frozen array"
22
19
  fails "Array#clear keeps tainted status"
23
20
  fails "Array#clear keeps untrusted status"
24
- fails "Array#clear raises a RuntimeError on a frozen array"
25
- fails "Array#clone copies frozen status from the original"
26
21
  fails "Array#clone copies taint status from the original"
27
22
  fails "Array#clone copies untrusted status from the original"
28
23
  fails "Array#collect does not copy tainted status"
29
24
  fails "Array#collect does not copy untrusted status"
30
25
  fails "Array#collect! keeps tainted status"
31
26
  fails "Array#collect! keeps untrusted status"
32
- fails "Array#collect! when frozen raises a RuntimeError when calling #each on the returned Enumerator when empty"
33
- fails "Array#collect! when frozen raises a RuntimeError when calling #each on the returned Enumerator"
34
- fails "Array#collect! when frozen raises a RuntimeError when empty"
35
- fails "Array#collect! when frozen raises a RuntimeError"
36
27
  fails "Array#compact does not keep tainted status even if all elements are removed"
37
28
  fails "Array#compact does not keep untrusted status even if all elements are removed"
38
29
  fails "Array#compact! keeps tainted status even if all elements are removed"
39
30
  fails "Array#compact! keeps untrusted status even if all elements are removed"
40
- fails "Array#compact! raises a RuntimeError on a frozen array"
41
31
  fails "Array#concat is not infected by the other"
42
32
  fails "Array#concat is not infected untrustedness by the other"
43
33
  fails "Array#concat keeps tainted status"
44
34
  fails "Array#concat keeps the tainted status of elements"
45
35
  fails "Array#concat keeps the untrusted status of elements"
46
36
  fails "Array#concat keeps untrusted status"
47
- fails "Array#concat raises a RuntimeError when Array is frozen and modification occurs"
48
- fails "Array#concat raises a RuntimeError when Array is frozen and no modification occurs"
49
37
  fails "Array#delete keeps tainted status"
50
38
  fails "Array#delete keeps untrusted status"
51
- fails "Array#delete raises a RuntimeError on a frozen array"
52
39
  fails "Array#delete_at keeps tainted status"
53
40
  fails "Array#delete_at keeps untrusted status"
54
- fails "Array#delete_at raises a RuntimeError on a frozen array"
55
41
  fails "Array#delete_if keeps tainted status"
56
42
  fails "Array#delete_if keeps untrusted status"
57
- fails "Array#delete_if raises a RuntimeError on a frozen array"
58
- fails "Array#delete_if raises a RuntimeError on an empty frozen array"
59
- fails "Array#delete_if returns an Enumerator if no block given, and the array is frozen"
60
43
  fails "Array#dup copies taint status from the original"
61
44
  fails "Array#dup copies untrusted status from the original"
62
45
  fails "Array#eql? returns false if any corresponding elements are not #eql?"
63
46
  fails "Array#fill does not replicate the filler"
64
- fails "Array#fill raises a RuntimeError on a frozen array"
65
- fails "Array#fill raises a RuntimeError on an empty frozen array"
66
47
  fails "Array#fill with (filler, index, length) raises an ArgumentError or RangeError for too-large sizes"
67
48
  fails "Array#first raises a RangeError when count is a Bignum"
68
49
  fails "Array#flatten returns a tainted array if self is tainted"
69
50
  fails "Array#flatten returns an untrusted array if self is untrusted"
70
- fails "Array#flatten! raises a RuntimeError on frozen arrays when the array is modified"
71
- fails "Array#flatten! raises a RuntimeError on frozen arrays when the array would not be modified"
72
- fails "Array#frozen? returns false for an array being sorted by #sort"
73
- fails "Array#frozen? returns true if array is frozen"
74
51
  fails "Array#hash calls to_int on result of calling hash on each element"
75
52
  fails "Array#hash returns the same fixnum for arrays with the same content"
76
53
  fails "Array#initialize is private"
77
- fails "Array#initialize raises a RuntimeError on frozen arrays"
78
- fails "Array#insert raises a RuntimeError on frozen arrays when the array is modified"
79
- fails "Array#insert raises a RuntimeError on frozen arrays when the array would not be modified"
80
54
  fails "Array#inspect does not taint the result if the Array is tainted but empty"
81
55
  fails "Array#inspect does not untrust the result if the Array is untrusted but empty"
82
56
  fails "Array#inspect represents a recursive element with '[...]'"
@@ -105,47 +79,20 @@ opal_unsupported_filter "Array" do
105
79
  fails "Array#join with an untrusted separator does not untrust the result if the array has only one element"
106
80
  fails "Array#join with an untrusted separator does not untrust the result if the array is empty"
107
81
  fails "Array#join with an untrusted separator untrusts the result if the array has two or more elements"
108
- fails "Array#keep_if on frozen objects returns an Enumerator if no block is given"
109
- fails "Array#keep_if on frozen objects with falsy block keeps elements after any exception"
110
- fails "Array#keep_if on frozen objects with falsy block raises a RuntimeError"
111
- fails "Array#keep_if on frozen objects with truthy block keeps elements after any exception"
112
- fails "Array#keep_if on frozen objects with truthy block raises a RuntimeError"
113
82
  fails "Array#map does not copy tainted status"
114
83
  fails "Array#map does not copy untrusted status"
115
84
  fails "Array#map! keeps tainted status"
116
85
  fails "Array#map! keeps untrusted status"
117
- fails "Array#map! when frozen raises a RuntimeError when calling #each on the returned Enumerator when empty"
118
- fails "Array#map! when frozen raises a RuntimeError when calling #each on the returned Enumerator"
119
- fails "Array#map! when frozen raises a RuntimeError when empty"
120
- fails "Array#map! when frozen raises a RuntimeError"
121
86
  fails "Array#pop keeps taint status"
122
87
  fails "Array#pop keeps untrusted status"
123
88
  fails "Array#pop passed a number n as an argument keeps taint status"
124
89
  fails "Array#pop passed a number n as an argument keeps untrusted status"
125
- fails "Array#pop passed a number n as an argument raises a RuntimeError on a frozen array"
126
90
  fails "Array#pop passed a number n as an argument returns a trusted array even if the array is untrusted"
127
91
  fails "Array#pop passed a number n as an argument returns an untainted array even if the array is tainted"
128
- fails "Array#pop raises a RuntimeError on a frozen array"
129
- fails "Array#pop raises a RuntimeError on an empty frozen array"
130
- fails "Array#push raises a RuntimeError on a frozen array"
131
- fails "Array#reject! raises a RuntimeError on a frozen array"
132
- fails "Array#reject! raises a RuntimeError on an empty frozen array"
133
- fails "Array#reject! returns an Enumerator if no block given, and the array is frozen"
134
- fails "Array#replace raises a RuntimeError on a frozen array"
135
- fails "Array#reverse! raises a RuntimeError on a frozen array"
136
- fails "Array#select! on frozen objects with falsy block keeps elements after any exception"
137
- fails "Array#select! on frozen objects with falsy block raises a RuntimeError"
138
- fails "Array#select! on frozen objects with truthy block keeps elements after any exception"
139
- fails "Array#select! on frozen objects with truthy block raises a RuntimeError"
140
92
  fails "Array#shift passed a number n as an argument keeps taint status"
141
93
  fails "Array#shift passed a number n as an argument returns an untainted array even if the array is tainted"
142
- fails "Array#shift raises a RuntimeError on a frozen array"
143
- fails "Array#shift raises a RuntimeError on an empty frozen array"
144
- fails "Array#shuffle! raises a RuntimeError on a frozen array"
145
94
  fails "Array#slice raises a RangeError when the length is out of range of Fixnum"
146
95
  fails "Array#slice raises a RangeError when the start index is out of range of Fixnum"
147
- fails "Array#slice! raises a RuntimeError on a frozen array"
148
- fails "Array#sort! raises a RuntimeError on a frozen array"
149
96
  fails "Array#to_s does not taint the result if the Array is tainted but empty"
150
97
  fails "Array#to_s does not untrust the result if the Array is untrusted but empty"
151
98
  fails "Array#to_s represents a recursive element with '[...]'"
@@ -160,9 +107,4 @@ opal_unsupported_filter "Array" do
160
107
  fails "Array#to_s with encoding use the default external encoding if it is ascii compatible"
161
108
  fails "Array#uniq compares elements with matching hash codes with #eql?" #RubySpec uses taint, which is not supported on Opal.
162
109
  fails "Array#uniq uses eql? semantics" #RubySpec expects 1.0 and 1 to be seen as different, which is not supported on Opal.
163
- fails "Array#uniq! doesn't yield to the block on a frozen array"
164
- fails "Array#uniq! raises a RuntimeError on a frozen array when the array is modified"
165
- fails "Array#uniq! raises a RuntimeError on a frozen array when the array would not be modified"
166
- fails "Array#unshift raises a RuntimeError on a frozen array when the array is modified"
167
- fails "Array#unshift raises a RuntimeError on a frozen array when the array would not be modified"
168
110
  end