opal 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +4 -4
  3. data/.github/ISSUE_TEMPLATE/bug-report.md +47 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/build.yml +11 -5
  6. data/.gitignore +1 -0
  7. data/.jshintrc +1 -1
  8. data/.rubocop.yml +2 -1
  9. data/CHANGELOG.md +95 -1
  10. data/Gemfile +0 -4
  11. data/HACKING.md +1 -1
  12. data/README.md +19 -15
  13. data/UNRELEASED.md +37 -96
  14. data/benchmark-ips/bm_array_unshift.rb +7 -0
  15. data/bin/build-browser-source-map-support +2 -3
  16. data/bin/opal-mspec +2 -0
  17. data/docs/compiler.md +1 -1
  18. data/examples/rack/Gemfile +0 -1
  19. data/examples/rack/Gemfile.lock +0 -4
  20. data/lib/opal/cli.rb +1 -0
  21. data/lib/opal/cli_options.rb +4 -0
  22. data/lib/opal/cli_runners/nodejs.rb +5 -1
  23. data/lib/opal/cli_runners/source-map-support-browser.js +8 -2
  24. data/lib/opal/cli_runners/source-map-support-node.js +3706 -0
  25. data/lib/opal/cli_runners/source-map-support.js +3 -1
  26. data/lib/opal/compiler.rb +2 -2
  27. data/lib/opal/nodes/args/arity_check.rb +1 -0
  28. data/lib/opal/nodes/args/parameters.rb +6 -0
  29. data/lib/opal/nodes/class.rb +1 -13
  30. data/lib/opal/nodes/literal.rb +14 -7
  31. data/lib/opal/nodes/module.rb +13 -9
  32. data/lib/opal/nodes/variables.rb +13 -4
  33. data/lib/opal/nodes/while.rb +54 -17
  34. data/lib/opal/parser.rb +1 -5
  35. data/lib/opal/parser/patch.rb +44 -0
  36. data/lib/opal/repl.rb +7 -0
  37. data/lib/opal/rewriter.rb +4 -0
  38. data/lib/opal/rewriters/arguments.rb +4 -1
  39. data/lib/opal/rewriters/forward_args.rb +54 -0
  40. data/lib/opal/rewriters/logical_operator_assignment.rb +5 -2
  41. data/lib/opal/rewriters/opal_engine_check.rb +5 -7
  42. data/lib/opal/rewriters/pattern_matching.rb +287 -0
  43. data/lib/opal/version.rb +1 -1
  44. data/opal/corelib/array.rb +42 -20
  45. data/opal/corelib/array/pack.rb +6 -1
  46. data/opal/corelib/complex.rb +2 -0
  47. data/opal/corelib/constants.rb +3 -3
  48. data/opal/corelib/hash.rb +45 -38
  49. data/opal/corelib/module.rb +2 -7
  50. data/opal/corelib/number.rb +2 -180
  51. data/opal/corelib/numeric.rb +156 -0
  52. data/opal/corelib/object_space.rb +102 -0
  53. data/opal/corelib/pattern_matching.rb +159 -0
  54. data/opal/corelib/random.rb +31 -66
  55. data/opal/corelib/random/formatter.rb +122 -0
  56. data/opal/corelib/range.rb +50 -19
  57. data/opal/corelib/runtime.js +82 -21
  58. data/opal/corelib/string.rb +86 -52
  59. data/opal/corelib/string/encoding.rb +140 -25
  60. data/opal/corelib/string/unpack.rb +26 -40
  61. data/opal/opal.rb +1 -0
  62. data/opal/opal/full.rb +2 -0
  63. data/package.json +1 -1
  64. data/spec/filters/bugs/array.rb +0 -23
  65. data/spec/filters/bugs/basicobject.rb +3 -0
  66. data/spec/filters/bugs/encoding.rb +0 -2
  67. data/spec/filters/bugs/exception.rb +1 -0
  68. data/spec/filters/bugs/float.rb +0 -2
  69. data/spec/filters/bugs/hash.rb +3 -13
  70. data/spec/filters/bugs/integer.rb +0 -2
  71. data/spec/filters/bugs/kernel.rb +16 -3
  72. data/spec/filters/bugs/language.rb +27 -90
  73. data/spec/filters/bugs/marshal.rb +1 -3
  74. data/spec/filters/bugs/module.rb +16 -1
  75. data/spec/filters/bugs/numeric.rb +4 -12
  76. data/spec/filters/bugs/objectspace.rb +67 -0
  77. data/spec/filters/bugs/pack_unpack.rb +0 -9
  78. data/spec/filters/bugs/pathname.rb +1 -0
  79. data/spec/filters/bugs/proc.rb +8 -0
  80. data/spec/filters/bugs/random.rb +3 -6
  81. data/spec/filters/bugs/range.rb +83 -113
  82. data/spec/filters/bugs/set.rb +2 -0
  83. data/spec/filters/bugs/string.rb +32 -70
  84. data/spec/filters/bugs/struct.rb +2 -10
  85. data/spec/filters/bugs/time.rb +8 -2
  86. data/spec/filters/unsupported/float.rb +3 -0
  87. data/spec/filters/unsupported/freeze.rb +1 -0
  88. data/spec/filters/unsupported/integer.rb +3 -0
  89. data/spec/filters/unsupported/refinements.rb +8 -0
  90. data/spec/filters/unsupported/string.rb +100 -95
  91. data/spec/filters/unsupported/time.rb +4 -0
  92. data/spec/lib/compiler_spec.rb +16 -0
  93. data/spec/lib/rewriters/forward_args_spec.rb +61 -0
  94. data/spec/lib/rewriters/logical_operator_assignment_spec.rb +1 -1
  95. data/spec/lib/rewriters/numblocks_spec.rb +44 -0
  96. data/spec/lib/rewriters/opal_engine_check_spec.rb +49 -4
  97. data/spec/opal/core/language/forward_args_spec.rb +53 -0
  98. data/spec/opal/core/language/infinite_range_spec.rb +13 -0
  99. data/spec/opal/core/language/memoization_spec.rb +16 -0
  100. data/spec/opal/core/language/pattern_matching_spec.rb +124 -0
  101. data/spec/opal/core/module_spec.rb +38 -2
  102. data/spec/opal/core/number/to_i_spec.rb +28 -0
  103. data/spec/opal/core/runtime/bridged_classes_spec.rb +16 -0
  104. data/spec/opal/core/runtime/constants_spec.rb +20 -1
  105. data/spec/opal/core/string/subclassing_spec.rb +16 -0
  106. data/spec/opal/core/string/unpack_spec.rb +22 -0
  107. data/spec/opal/core/string_spec.rb +4 -4
  108. data/spec/ruby_specs +4 -1
  109. data/stdlib/json.rb +3 -1
  110. data/stdlib/promise/v1.rb +1 -0
  111. data/stdlib/promise/v2.rb +386 -0
  112. data/stdlib/securerandom.rb +55 -35
  113. data/tasks/releasing.rake +1 -1
  114. data/tasks/testing.rake +6 -4
  115. data/test/nodejs/test_string.rb +25 -0
  116. data/test/opal/promisev2/test_always.rb +63 -0
  117. data/test/opal/promisev2/test_error.rb +16 -0
  118. data/test/opal/promisev2/test_rescue.rb +59 -0
  119. data/test/opal/promisev2/test_then.rb +90 -0
  120. data/test/opal/promisev2/test_trace.rb +52 -0
  121. data/test/opal/promisev2/test_value.rb +16 -0
  122. data/test/opal/promisev2/test_when.rb +35 -0
  123. data/vendored-minitest/minitest/assertions.rb +2 -0
  124. metadata +47 -8
  125. data/lib/opal/parser/with_c_lexer.rb +0 -15
@@ -9,4 +9,7 @@ opal_filter "BasicObject" do
9
9
  fails "BasicObject#instance_exec binds the block's binding self to the receiver"
10
10
  fails "BasicObject#instance_exec raises a LocalJumpError unless given a block"
11
11
  fails "BasicObject#method_missing for an instance sets the receiver of the raised NoMethodError"
12
+ fails "BasicObject#singleton_method_added when singleton_method_added is undefined calls #method_missing" # Expected [] == [["singleton_method_added", "foo"], ["singleton_method_added", "bar"], ["singleton_method_added", "baz"]] to be truthy but was false
13
+ fails "BasicObject#singleton_method_added when singleton_method_added is undefined raises NoMethodError for a metaclass" # Expected NoMethodError (/undefined method `singleton_method_added' for/) but no exception was raised ("foo" was returned)
14
+ fails "BasicObject#singleton_method_added when singleton_method_added is undefined raises NoMethodError for a singleton instance" # Expected NoMethodError (/undefined method `singleton_method_added' for #<Object:/) but no exception was raised ("foo" was returned)
12
15
  end
@@ -103,8 +103,6 @@ opal_filter "Encoding" do
103
103
  fails "String#[]= with a Regexp index replaces multibyte characters with characters" # NoMethodError: undefined method `[]=' for "ありがとう":String
104
104
  fails "String#[]= with a Regexp index replaces multibyte characters with multibyte characters" # NoMethodError: undefined method `[]=' for "ありがとう":String
105
105
  fails "String#ascii_only? returns false after appending non ASCII characters to an empty String" # NotImplementedError: String#<< not supported. Mutable String methods are not supported in Opal.
106
- fails "String#ascii_only? returns false for a non-empty String with non-ASCII-compatible encoding" # Expected true to be false
107
- fails "String#ascii_only? returns false for the empty String with a non-ASCII-compatible encoding" # Expected true to be false
108
106
  fails "String#ascii_only? returns false when concatenating an ASCII and non-ASCII String" # NoMethodError: undefined method `concat' for "":String
109
107
  fails "String#ascii_only? returns false when replacing an ASCII String with a non-ASCII String" # NoMethodError: undefined method `replace' for "":String
110
108
  fails "String#ascii_only? with non-ASCII only characters returns false if the encoding is ASCII-8BIT" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
@@ -53,6 +53,7 @@ opal_filter "Exception" do
53
53
  fails "Exception#to_s calls #to_s on the message" # Mock 'message' expected to receive 'to_s' exactly 1 times but received it 2 times
54
54
  fails "IOError is a superclass of EOFError"
55
55
  fails "Interrupt is a subclass of SignalException" # Expected Exception to equal SignalException
56
+ fails "Interrupt is raised on the main Thread by the default SIGINT handler" # NoMethodError: undefined method `tmp' for #<MSpecEnv:0x2316>
56
57
  fails "Interrupt.new returns an instance of interrupt with no message given" # NoMethodError: undefined method `signo' for #<Interrupt: Interrupt>:Interrupt
57
58
  fails "Interrupt.new takes an optional message argument" # NoMethodError: undefined method `signo' for #<Interrupt: message>:Interrupt
58
59
  fails "KeyError accepts :receiver and :key options" # ArgumentError: no receiver is available
@@ -51,8 +51,6 @@ opal_filter "Float" do
51
51
  fails "Float#round rounds self to an optionally given precision with a half option" # ArgumentError: [Number#round] wrong number of arguments(2 for -1)
52
52
  fails "Float#round when 0.0 is given returns 0 for 0 or undefined ndigits" # TypeError: no implicit conversion of Hash into Integer
53
53
  fails "Float#round when 0.0 is given returns self for positive ndigits" # Expected "0" == "0.0" to be truthy but was false
54
- fails "Float#to_i returns self truncated to an Integer"
55
- fails "Float#to_int returns self truncated to an Integer"
56
54
  fails "Float#to_s encoding returns a String in US-ASCII encoding when Encoding.default_internal is nil" # NoMethodError: undefined method `default_internal' for Encoding
57
55
  fails "Float#to_s encoding returns a String in US-ASCII encoding when Encoding.default_internal is not nil" # NoMethodError: undefined method `default_internal' for Encoding
58
56
  fails "Float#to_s matches random examples in all ranges" # Expected "4.9247416523566613e-8" to equal "4.9247416523566613e-08"
@@ -9,9 +9,7 @@ opal_filter "Hash" do
9
9
  fails "Hash#[]= does not dispatch to hash for Boolean, Integer, Float, String, or Symbol" # NoMethodError: undefined method `insert' for "rubyexe.rb"
10
10
  fails "Hash#[]= keeps the existing String key in the hash if there is a matching one" # Expected "foo" not to be identical to "foo"
11
11
  fails "Hash#compare_by_identity gives different identity for string literals" # Expected [2] to equal [1, 2]
12
- fails "Hash#deconstruct_keys ignores argument" # NoMethodError: undefined method `deconstruct_keys' for {"a"=>1, "b"=>2}
13
- fails "Hash#deconstruct_keys requires one argument" # Expected ArgumentError (/wrong number of arguments \(given 0, expected 1\)/) but got: NoMethodError (undefined method `deconstruct_keys' for {"a"=>1})
14
- fails "Hash#deconstruct_keys returns self" # NoMethodError: undefined method `deconstruct_keys' for {"a"=>1, "b"=>2}
12
+ fails "Hash#deconstruct_keys requires one argument" # Expected ArgumentError (/wrong number of arguments \(given 0, expected 1\)/) but got: ArgumentError ([Hash#deconstruct_keys] wrong number of arguments(0 for 1))
15
13
  fails "Hash#delete allows removing a key while iterating" # Exception: Cannot read property '$$is_string' of undefined
16
14
  fails "Hash#each always yields an Array of 2 elements, even when given a callable of arity 2" # Expected ArgumentError but no exception was raised ({"a"=>1} was returned)
17
15
  fails "Hash#each yields 2 values and not an Array of 2 elements when given a callable of arity 2" # ArgumentError: [Object#foo] wrong number of arguments(1 for 2)
@@ -21,18 +19,12 @@ opal_filter "Hash" do
21
19
  fails "Hash#eql? computes equality for complex recursive hashes"
22
20
  fails "Hash#eql? computes equality for recursive hashes & arrays"
23
21
  fails "Hash#except always returns a Hash without a default" # NoMethodError: undefined method `except' for {"bar"=>12, "foo"=>42}
24
- fails "Hash#except ignores keys not present in the original hash" # NoMethodError: undefined method `except' for {"a"=>1, "b"=>2, "c"=>3}
25
- fails "Hash#except returns a hash without the requested subset" # NoMethodError: undefined method `except' for {"a"=>1, "b"=>2, "c"=>3}
26
- fails "Hash#except returns a new duplicate hash without arguments" # NoMethodError: undefined method `except' for {"a"=>1, "b"=>2, "c"=>3}
27
22
  fails "Hash#inspect calls #to_s on the object returned from #inspect if the Object isn't a String" # Expected "{\"a\"=>abc}" to equal "{:a=>abc}"
28
23
  fails "Hash#inspect does not call #to_s on a String returned from #inspect" # Expected "{\"a\"=>\"abc\"}" to equal "{:a=>\"abc\"}"
29
24
  fails "Hash#inspect does not call #to_str on the object returned from #inspect when it is not a String" # Expected "{\"a\"=>#<MockObject:0x30638>}" to match /^\{:a=>#<MockObject:0x[0-9a-f]+>\}$/
30
25
  fails "Hash#inspect does not call #to_str on the object returned from #to_s when it is not a String" # Exception: Cannot convert object to primitive value
31
26
  fails "Hash#invert compares new keys with eql? semantics" # spec relies on integer and float being different
32
- fails "Hash#merge accepts multiple hashes" # ArgumentError: [Hash#merge] wrong number of arguments(3 for 1)
33
- fails "Hash#merge accepts zero arguments and returns a copy of self" # ArgumentError: [Hash#merge] wrong number of arguments(0 for 1)
34
- fails "Hash#merge! accepts multiple hashes" # ArgumentError: [Hash#merge!] wrong number of arguments(3 for 1)
35
- fails "Hash#merge! accepts zero arguments" # ArgumentError: [Hash#merge!] wrong number of arguments(0 for 1)
27
+ fails "Hash#rehash removes duplicate keys for large hashes" # Expected 102 == 101 to be truthy but was false
36
28
  fails "Hash#rehash removes duplicate keys" # Expected 2 to equal 1
37
29
  fails "Hash#shift allows shifting entries while iterating" # Exception: Cannot read property '$$is_string' of undefined
38
30
  fails "Hash#store does not dispatch to hash for Boolean, Integer, Float, String, or Symbol" # NoMethodError: undefined method `insert' for "rubyexe.rb"
@@ -47,9 +39,7 @@ opal_filter "Hash" do
47
39
  fails "Hash#to_s does not call #to_str on the object returned from #inspect when it is not a String" # Expected "{\"a\"=>#<MockObject:0x1b948>}" to match /^\{:a=>#<MockObject:0x[0-9a-f]+>\}$/
48
40
  fails "Hash#to_s does not call #to_str on the object returned from #to_s when it is not a String" # Exception: Cannot convert object to primitive value
49
41
  fails "Hash#transform_keys! prevents conflicts between new keys and old ones" # Expected {"e"=>1} to equal {"b"=>1, "c"=>2, "d"=>3, "e"=>4}
50
- fails "Hash#transform_keys! returns the processed keys if we broke from the block" # Expected {"c"=>1, "d"=>4} to equal {"b"=>1, "c"=>2}
51
- fails "Hash#update accepts multiple hashes" # ArgumentError: [Hash#merge!] wrong number of arguments(3 for 1)
52
- fails "Hash#update accepts zero arguments" # ArgumentError: [Hash#merge!] wrong number of arguments(0 for 1)
42
+ fails "Hash#transform_keys! returns the processed keys and non evaluated keys if we broke from the block" # Expected {"c"=>1, "d"=>4} == {"b"=>1, "c"=>2, "d"=>4} to be truthy but was false
53
43
  fails "Hash.[] raises for elements that are not arrays" # Expected ArgumentError but no exception was raised (nil was returned)
54
44
  fails "Hash.ruby2_keywords_hash raises TypeError for non-Hash" # Expected TypeError but got: NoMethodError (undefined method `ruby2_keywords_hash' for Hash)
55
45
  fails "Hash.ruby2_keywords_hash returns a copy of a Hash and marks the copy as a keywords Hash" # NoMethodError: undefined method `ruby2_keywords_hash' for Hash
@@ -46,8 +46,6 @@ opal_filter "Integer" do
46
46
  fails "Integer#chr without argument raises a RangeError is self is less than 0"
47
47
  fails "Integer#chr without argument returns a new String for each call"
48
48
  fails "Integer#chr without argument when Encoding.default_internal is nil and self is between 0 and 127 (inclusive) returns a US-ASCII String"
49
- fails "Integer#chr without argument when Encoding.default_internal is nil and self is between 128 and 255 (inclusive) returns a String containing self interpreted as a byte"
50
- fails "Integer#chr without argument when Encoding.default_internal is nil and self is between 128 and 255 (inclusive) returns a binary String" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
51
49
  fails "Integer#chr without argument when Encoding.default_internal is nil and self is between 128 and 255 (inclusive) returns an ASCII-8BIT String"
52
50
  fails "Integer#chr without argument when Encoding.default_internal is nil raises a RangeError is self is greater than 255"
53
51
  fails "Integer#chr without argument when Encoding.default_internal is not nil and self is between 0 and 127 (inclusive) returns a String encoding self interpreted as a US-ASCII codepoint"
@@ -59,6 +59,7 @@ opal_filter "Kernel" do
59
59
  fails "Kernel#caller returns an Array of caller locations using a range" # NoMethodError: undefined method `+' for 1..1
60
60
  fails "Kernel#caller returns an Array with the block given to #at_exit at the base of the stack" # NoMethodError: undefined method `tmp' for #<MSpecEnv:0xe208>
61
61
  fails "Kernel#caller returns the locations as String instances" # Expected "corelib/runtime.js:1675" to include "ruby/core/kernel/caller_spec.rb:32:in"
62
+ fails "Kernel#caller works with beginless ranges" # TypeError: no implicit conversion of NilClass into Integer
62
63
  fails "Kernel#caller works with endless ranges" # Opal::SyntaxError: undefined method `type' for nil
63
64
  fails "Kernel#class returns the class of the object"
64
65
  fails "Kernel#clone copies frozen?" # Expected false to be true
@@ -99,7 +100,6 @@ opal_filter "Kernel" do
99
100
  fails "Kernel#eval with a magic encoding comment ignores the frozen_string_literal magic comment if it appears after a token and warns if $VERBOSE is true" # Expected warning to match: /warning: `frozen_string_literal' is ignored after any tokens/ but got: ""
100
101
  fails "Kernel#eval with a magic encoding comment ignores the magic encoding comment if it is after a frozen_string_literal magic comment" # Opal::SyntaxError: unexpected token $end
101
102
  fails "Kernel#eval with a magic encoding comment uses the magic comment encoding for parsing constants" # Opal::SyntaxError: unexpected token $end
102
- fails "Kernel#eval with a magic encoding comment uses the magic comment encoding for the encoding of literal strings" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:UTF-8>
103
103
  fails "Kernel#extend does not calls append_features on arguments metaclass"
104
104
  fails "Kernel#extend raises an ArgumentError when no arguments given"
105
105
  fails "Kernel#fail accepts an Object with an exception method returning an Exception" # TypeError: exception class/object expected
@@ -108,17 +108,18 @@ opal_filter "Kernel" do
108
108
  fails "Kernel#initialize_copy raises FrozenError if the receiver is frozen" # Expected FrozenError but no exception was raised (nil was returned)
109
109
  fails "Kernel#initialize_copy raises TypeError if the objects are of different class" # Expected TypeError (initialize_copy should take same class object) but no exception was raised (nil was returned)
110
110
  fails "Kernel#inspect does not call #to_s if it is defined"
111
+ fails "Kernel#inspect returns a String for an object without #class method" # Exception: Maximum call stack size exceeded
111
112
  fails "Kernel#instance_variables immediate values returns the correct array if an instance variable is added"
112
113
  fails "Kernel#is_a? does not take into account `class` method overriding" # TypeError: can't define singleton
113
- fails "Kernel#is_a? returns true if given a Module that object has been extended with" # Requires string mutability
114
114
  fails "Kernel#kind_of? does not take into account `class` method overriding" # TypeError: can't define singleton
115
- fails "Kernel#kind_of? returns true if given a Module that object has been extended with" # Requires string mutability
116
115
  fails "Kernel#local_variables contains locals as they are added"
117
116
  fails "Kernel#local_variables includes only unique variable names" # NoMethodError: undefined method `local_variables' for #<MSpecEnv:0x476>
118
117
  fails "Kernel#local_variables is accessible from bindings"
119
118
  fails "Kernel#local_variables is accessible in eval"
120
119
  fails "Kernel#method can be called even if we only repond_to_missing? method, true"
120
+ fails "Kernel#method returns a method object if respond_to_missing?(method) is true" # NameError: undefined method `handled_publicly' for class `KernelSpecs::RespondViaMissing'
121
121
  fails "Kernel#method returns a method object if we repond_to_missing? method"
122
+ fails "Kernel#method the returned method object if respond_to_missing?(method) calls #method_missing with a Symbol name" # NameError: undefined method `handled_publicly' for class `KernelSpecs::RespondViaMissing'
122
123
  fails "Kernel#method will see an alias of the original method as == when in a derived class"
123
124
  fails "Kernel#methods does not return private singleton methods defined in 'class << self'"
124
125
  fails "Kernel#object_id returns a different value for two Bignum literals"
@@ -131,14 +132,21 @@ opal_filter "Kernel" do
131
132
  fails "Kernel#public_method raises a NameError if we only repond_to_missing? method, true"
132
133
  fails "Kernel#public_method returns a method object for a valid method"
133
134
  fails "Kernel#public_method returns a method object for a valid singleton method"
135
+ fails "Kernel#public_method returns a method object if respond_to_missing?(method) is true" # Expected "Done public_method(handled_publicly)" (String) to be an instance of Method
134
136
  fails "Kernel#public_method returns a method object if we repond_to_missing? method"
137
+ fails "Kernel#public_method the returned method object if respond_to_missing?(method) calls #method_missing with a Symbol name" # Expected "Done public_method(handled_publicly)" (String) to be an instance of Method
135
138
  fails "Kernel#public_methods returns a list of names without protected accessible methods in the object"
136
139
  fails "Kernel#public_methods when passed false returns a list of public methods in without its ancestors"
137
140
  fails "Kernel#public_methods when passed nil returns a list of public methods in without its ancestors"
141
+ fails "Kernel#public_send includes `public_send` in the backtrace when passed a single incorrect argument" # Expected TypeError but got: NoMethodError (undefined method `#<Object:0x3da7a>' for #<MSpecEnv:0x3d9f4>)
142
+ fails "Kernel#public_send includes `public_send` in the backtrace when passed not enough arguments" # Expected "ArgumentError: [MSpecEnv#__send__] wrong number of arguments(0 for -2)".include? "`public_send'" to be truthy but was false
138
143
  fails "Kernel#public_send raises a TypeError if the method name is not a string or symbol" # NoMethodError: undefined method `' for SendSpecs
139
144
  fails "Kernel#puts delegates to $stdout.puts"
145
+ fails "Kernel#raise accepts a cause keyword argument that overrides the last exception" # NoMethodError: undefined method `cause' for #<RuntimeError: error>
146
+ fails "Kernel#raise accepts a cause keyword argument that sets the cause" # NoMethodError: undefined method `cause' for #<RuntimeError: error>
140
147
  fails "Kernel#raise passes no arguments to the constructor when given only an exception class" # Expected #<Class:0x4c8> but got: ArgumentError ([#initialize] wrong number of arguments(1 for 0))
141
148
  fails "Kernel#raise raises RuntimeError if no exception class is given" # RuntimeError: RuntimeError
149
+ fails "Kernel#raise raises an ArgumentError when only cause is given" # Expected ArgumentError but got: TypeError (exception class/object expected)
142
150
  fails "Kernel#raise re-raises a previously rescued exception without overwriting the backtrace" # Expected "RuntimeError: raised" to include "ruby/shared/kernel/raise.rb:65:"
143
151
  fails "Kernel#respond_to? throws a type error if argument can't be coerced into a Symbol"
144
152
  fails "Kernel#respond_to_missing? causes #respond_to? to return false if called and returning nil"
@@ -211,6 +219,7 @@ opal_filter "Kernel" do
211
219
  fails "Kernel#singleton_methods when passed true returns the names of singleton methods for an object extented with a module"
212
220
  fails "Kernel#singleton_methods when passed true returns the names of singleton methods for an object extented with two modules"
213
221
  fails "Kernel#singleton_methods when passed true returns the names of singleton methods for an object"
222
+ fails "Kernel#sleep accepts any Object that reponds to divmod" # TypeError: can't convert Object into time interval
214
223
  fails "Kernel#sprintf can produce a string with invalid encoding" # Expected true to be false
215
224
  fails "Kernel#sprintf flags # applies to format o does nothing for negative argument" # Expected "0..7651" to equal "..7651"
216
225
  fails "Kernel#sprintf flags # applies to formats aAeEfgG changes format from dd.dddd to exponential form for gG" # Expected "1.234e+02" to equal "1.e+02"
@@ -245,6 +254,7 @@ opal_filter "Kernel" do
245
254
  fails "Kernel#sprintf integer formats i works well with large numbers" # Expected "1234567890987654400" to equal "1234567890987654321"
246
255
  fails "Kernel#sprintf integer formats u works well with large numbers" # Expected "1234567890987654400" to equal "1234567890987654321"
247
256
  fails "Kernel#sprintf other formats % alone raises an ArgumentError" # Expected ArgumentError but no exception was raised ("%" was returned)
257
+ fails "Kernel#sprintf other formats s preserves encoding of the format string" # Expected #<Encoding:UTF-8> == #<Encoding:ASCII-8BIT (dummy)> to be truthy but was false
248
258
  fails "Kernel#sprintf precision float types controls the number of decimal places displayed in fraction part" # NotImplementedError: `A` and `a` format field types are not implemented in Opal yet
249
259
  fails "Kernel#sprintf precision float types does not affect G format" # Expected "12.12340000" to equal "12.1234"
250
260
  fails "Kernel#sprintf precision string formats determines the maximum number of characters to be copied from the string" # Expected "1" to equal "["
@@ -353,6 +363,8 @@ opal_filter "Kernel" do
353
363
  fails "Kernel.lambda returns the passed Proc if given an existing Proc" # Expected true to be false
354
364
  fails "Kernel.loop returns StopIteration#result, the result value of a finished iterator" # requires changes in enumerator.rb
355
365
  fails "Kernel.printf calls write on the first argument when it is not a string"
366
+ 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
367
+ fails "Kernel.printf formatting io is specified other formats s preserves encoding of the format string" # Expected #<Encoding:UTF-8> == #<Encoding:ASCII-8BIT (dummy)> to be truthy but was false
356
368
  fails "Kernel.printf writes to stdout when a string is the first argument"
357
369
  fails "Kernel.proc returned the passed Proc if given an existing Proc" # Expected false to be true
358
370
  fails "Kernel.rand is random on boot" # NoMethodError: undefined method `insert' for "rubyexe.rb"
@@ -391,6 +403,7 @@ opal_filter "Kernel" do
391
403
  fails "Kernel.sprintf integer formats i works well with large numbers" # Expected "1234567890987654400" to equal "1234567890987654321"
392
404
  fails "Kernel.sprintf integer formats u works well with large numbers" # Expected "1234567890987654400" to equal "1234567890987654321"
393
405
  fails "Kernel.sprintf other formats % alone raises an ArgumentError" # Expected ArgumentError but no exception was raised ("%" was returned)
406
+ fails "Kernel.sprintf other formats s preserves encoding of the format string" # Expected #<Encoding:UTF-8> == #<Encoding:ASCII-8BIT (dummy)> to be truthy but was false
394
407
  fails "Kernel.sprintf precision float types controls the number of decimal places displayed in fraction part" # NotImplementedError: `A` and `a` format field types are not implemented in Opal yet
395
408
  fails "Kernel.sprintf precision float types does not affect G format" # Expected "12.12340000" to equal "12.1234"
396
409
  fails "Kernel.sprintf precision string formats determines the maximum number of characters to be copied from the string" # Expected "1" to equal "["
@@ -23,10 +23,8 @@ opal_filter "language" do
23
23
  fails "A block yielded a single Array raises a TypeError if #to_hash does not return a Hash"
24
24
  fails "A block yielded a single Array when non-symbol keys are in a keyword arguments Hash does not separate non-symbol keys and symbol keys and does not autosplat" # Expected [nil, {"a"=>10, "b"=>2}] == [[{"a"=>10, "b"=>2}], {}] to be truthy but was false
25
25
  fails "A block yielded a single Array when non-symbol keys are in a keyword arguments Hash separates non-symbol keys and symbol keys" # Expected [nil, {"a"=>10, "b"=>2}] to equal [{"a"=>10}, {"b"=>2}]
26
- fails "A class definition allows using self as the superclass if self is a class"
27
26
  fails "A class definition extending an object (sclass) allows accessing the block of the original scope" # Opal::SyntaxError: undefined method `uses_block!' for nil
28
27
  fails "A class definition extending an object (sclass) can use return to cause the enclosing method to return"
29
- fails "A class definition extending an object (sclass) raises a TypeError when trying to extend non-Class" # Expected TypeError (/superclass must be a.* Class/) but no exception was raised (nil was returned)
30
28
  fails "A class definition extending an object (sclass) raises a TypeError when trying to extend numbers"
31
29
  fails "A class definition raises TypeError if any constant qualifying the class is not a Module"
32
30
  fails "A class definition raises TypeError if the constant qualifying the class is nil"
@@ -59,6 +57,7 @@ opal_filter "language" do
59
57
  fails "A method assigns local variables from method parameters for definition 'def m(a=1, b: 2) [a, b] end'"
60
58
  fails "A method assigns local variables from method parameters for definition 'def m(a=1, b:) [a, b] end'"
61
59
  fails "A method assigns local variables from method parameters for definition \n def m(a, b = nil, c = nil, d, e: nil, **f)\n [a, b, c, d, e, f]\n end" # Exception: Cannot read property '$$is_array' of undefined
60
+ fails "A method assigns the last Hash to the last optional argument if the Hash contains non-Symbol keys and is not passed as keywords" # Exception: Object.defineProperty called on non-object
62
61
  fails "A method definition in an eval creates a class method"
63
62
  fails "A method definition in an eval creates a singleton method"
64
63
  fails "A method definition in an eval creates an instance method"
@@ -82,6 +81,7 @@ opal_filter "language" do
82
81
  fails "Allowed characters does not allow non-ASCII upcased characters at the beginning" # Expected SyntaxError (/dynamic constant assignment/) but no exception was raised ("test" was returned)
83
82
  fails "An ensure block inside 'do end' block is executed even when a symbol is thrown in it's corresponding begin block" # Expected ["begin", "rescue", "ensure"] to equal ["begin", "ensure"]
84
83
  fails "An ensure block inside a begin block is executed even when a symbol is thrown in it's corresponding begin block"
84
+ fails "An ensure block inside a begin block sets exception cause if raises exception in block and in ensure" # NoMethodError: undefined method `cause' for #<RuntimeError: from ensure>
85
85
  fails "An ensure block inside a class is executed even when a symbol is thrown" # Expected ["class", "rescue", "ensure"] to equal ["class", "ensure"]
86
86
  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)
87
87
  fails "An instance method raises FrozenError with the correct class name" # Expected FrozenError but no exception was raised (#<Module:0x225b4> was returned)
@@ -92,8 +92,6 @@ opal_filter "language" do
92
92
  fails "An instance method with a default argument shadows an existing method with the same name as the local"
93
93
  fails "An instance method with a default argument warns and uses a nil value when there is an existing local method with same name" # Expected warning to match: /circular argument reference/ but got: ""
94
94
  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
95
- fails "Constant resolution within methods with dynamically assigned constants searches Object as a lexical scope only if Object is explicitly opened"
96
- fails "Constant resolution within methods with statically assigned constants searches Object as a lexical scope only if Object is explicitly opened"
97
95
  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)
98
96
  fails "Executing break from within a block returns from the original invoking method even in case of chained calls"
99
97
  fails "Executing break from within a block works when passing through a super call" # Expected to not get Exception
@@ -114,7 +112,9 @@ opal_filter "language" do
114
112
  fails "Global variable $FILENAME is read-only"
115
113
  fails "Global variable $VERBOSE converts truthy values to true" # Expected 1 to be true
116
114
  fails "Global variable $\" is read-only"
115
+ fails "Hash literal checks duplicated keys on initialization" # Expected warning to match: /key 1000 is duplicated|duplicated key/ but got: ""
117
116
  fails "Hash literal expands a BasicObject using ** into the containing Hash literal initialization" # NoMethodError: undefined method `respond_to?' for BasicObject
117
+ fails "Hash#deconstruct_keys requires one argument" # Expected ArgumentError (/wrong number of arguments \(given 0, expected 1\)/) but got: ArgumentError ([Hash#deconstruct_keys] wrong number of arguments(0 for 1))
118
118
  fails "Heredoc string allow HEREDOC with <<\"identifier\", interpolated" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
119
119
  fails "Heredoc string allows HEREDOC with <<'identifier', no interpolation" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
120
120
  fails "Heredoc string allows HEREDOC with <<-'identifier', allowing to indent identifier, no interpolation" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
@@ -128,8 +128,6 @@ opal_filter "language" do
128
128
  fails "Literal (A::X) constant resolution uses the module or class #inspect to craft the error message if they are anonymous" # Expected NameError (/uninitialized constant <unusable info>::DOES_NOT_EXIST/) but got: NameError (uninitialized constant #<Module:0x50c0>::DOES_NOT_EXIST)
129
129
  fails "Literal (A::X) constant resolution uses the module or class #name to craft the error message" # Expected NameError (/uninitialized constant ModuleName::DOES_NOT_EXIST/) but got: NameError (uninitialized constant #<Module:0x50ba>::DOES_NOT_EXIST)
130
130
  fails "Literal (A::X) constant resolution with dynamically assigned constants evaluates the right hand side before evaluating a constant path"
131
- fails "Literal Ranges creates beginless ranges" # Opal::SyntaxError: undefined method `type' for nil
132
- fails "Literal Ranges creates endless ranges" # Opal::SyntaxError: undefined method `type' for nil
133
131
  fails "Literal Regexps caches the Regexp object"
134
132
  fails "Literal Regexps raises a RegexpError for lookbehind with specific characters" # Expected RegexpError but no exception was raised (0 was returned)
135
133
  fails "Literal Regexps support handling unicode 9.0 characters with POSIX bracket expressions" # Expected "" to equal "𐓘"
@@ -204,87 +202,34 @@ opal_filter "language" do
204
202
  fails "NoMethodError#message fallbacks to a simpler representation of the receiver when receiver.inspect raises an exception" # NoMethodError: undefined method `name' for #<NoMethodErrorSpecs::InstanceException: NoMethodErrorSpecs::InstanceException>
205
203
  fails "Numbered parameters does not support more than 9 parameters" # Expected NameError (/undefined local variable or method `_10'/) but got: NoMethodError (undefined method `_10' for #<MSpecEnv:0x5d700>)
206
204
  fails "Operators * / % are left-associative"
205
+ 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
206
+ 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
207
207
  fails "Optional variable assignments using compounded constants with &&= assignments" # Expected warning to match: /already initialized constant/ but got: ""
208
208
  fails "Optional variable assignments using compounded constants with operator assignments" # Expected warning to match: /already initialized constant/ but got: ""
209
209
  fails "Optional variable assignments using compunded constants with ||= assignments"
210
- fails "Pattern matching AS pattern binds a variable to a value if pattern matches" # Opal::SyntaxError: `n' is not allowed as a local variable name
211
- fails "Pattern matching AS pattern can be used as a nested pattern" # Opal::SyntaxError: `ary' is not allowed as a local variable name
212
- fails "Pattern matching Array pattern accepts a subclass of Array from #deconstruct" # Opal::SyntaxError: Unsupported sexp: case_match
213
- fails "Pattern matching Array pattern binds variables" # Opal::SyntaxError: `a' is not allowed as a local variable name
214
- fails "Pattern matching Array pattern calls #deconstruct even on objects that are already an array" # Opal::SyntaxError: Unsupported sexp: case_match
215
- fails "Pattern matching Array pattern calls #deconstruct once for multiple patterns, caching the result" # Opal::SyntaxError: Unsupported sexp: case_match
216
- fails "Pattern matching Array pattern does match partially from the array beginning if list + , syntax used" # Opal::SyntaxError: Unsupported sexp: case_match
217
- fails "Pattern matching Array pattern does not match object if Constant === object returns false" # Opal::SyntaxError: Unsupported sexp: case_match
218
- fails "Pattern matching Array pattern does not match object if elements of array returned by #deconstruct method does not match elements in pattern" # Opal::SyntaxError: Unsupported sexp: case_match
219
- fails "Pattern matching Array pattern does not match object without #deconstruct method" # Mock '#<Object:0x75326>' expected to receive respond_to?("deconstruct") exactly 1 times but received it 0 times
220
- fails "Pattern matching Array pattern does not match partially by default" # Opal::SyntaxError: Unsupported sexp: case_match
221
- fails "Pattern matching Array pattern matches [] with []" # Opal::SyntaxError: Unsupported sexp: case_match
222
- fails "Pattern matching Array pattern matches an object with #deconstruct method which returns an array and each element in array matches element in pattern" # Opal::SyntaxError: Unsupported sexp: case_match
223
- fails "Pattern matching Array pattern matches anything with *" # Opal::SyntaxError: Unsupported sexp: case_match
224
- fails "Pattern matching Array pattern raises TypeError if #deconstruct method does not return array" # Expected TypeError (/deconstruct must return Array/) but got: Opal::SyntaxError (Unsupported sexp: case_match)
225
- fails "Pattern matching Array pattern supports form Constant(pat, pat, ...)" # Opal::SyntaxError: Unsupported sexp: case_match
226
- fails "Pattern matching Array pattern supports form Constant[pat, pat, ...]" # Opal::SyntaxError: Unsupported sexp: case_match
227
- fails "Pattern matching Array pattern supports form [pat, pat, ...]" # Opal::SyntaxError: Unsupported sexp: case_match
228
- fails "Pattern matching Array pattern supports form pat, pat, ..." # Opal::SyntaxError: Unsupported sexp: case_match
229
- fails "Pattern matching Array pattern supports splat operator *rest" # Opal::SyntaxError: `rest' is not allowed as a local variable name
230
- fails "Pattern matching Hash pattern binds variables" # Opal::SyntaxError: `x' is not allowed as a local variable name
231
- fails "Pattern matching Hash pattern calls #deconstruct_keys per pattern" # Opal::SyntaxError: Unsupported sexp: case_match
232
- fails "Pattern matching Hash pattern can match partially" # Opal::SyntaxError: Unsupported sexp: case_match
233
- fails "Pattern matching Hash pattern can mix key (a:) and key-value (a: b) declarations" # Opal::SyntaxError: `a' is not allowed as a local variable name
234
- fails "Pattern matching Hash pattern does not match object if #deconstruct_keys method does not return Hash" # Expected TypeError (/deconstruct_keys must return Hash/) but got: Opal::SyntaxError (Unsupported sexp: case_match)
235
- fails "Pattern matching Hash pattern does not match object if #deconstruct_keys method returns Hash with non-symbol keys" # Opal::SyntaxError: Unsupported sexp: case_match
236
- fails "Pattern matching Hash pattern does not match object if Constant === object returns false" # Opal::SyntaxError: Unsupported sexp: case_match
237
- fails "Pattern matching Hash pattern does not match object if elements of Hash returned by #deconstruct_keys method does not match values in pattern" # Opal::SyntaxError: Unsupported sexp: case_match
238
- fails "Pattern matching Hash pattern does not match object without #deconstruct_keys method" # Mock '#<Object:0x78c14>' expected to receive respond_to?("deconstruct_keys") exactly 1 times but received it 0 times
239
- fails "Pattern matching Hash pattern matches an object with #deconstruct_keys method which returns a Hash with equal keys and each value in Hash matches value in pattern" # Opal::SyntaxError: Unsupported sexp: case_match
240
- fails "Pattern matching Hash pattern matches anything with **" # Opal::SyntaxError: Unsupported sexp: case_match
241
- fails "Pattern matching Hash pattern matches {} with {}" # Opal::SyntaxError: Unsupported sexp: case_match
242
- fails "Pattern matching Hash pattern passes keys specified in pattern as arguments to #deconstruct_keys method" # Opal::SyntaxError: Unsupported sexp: case_match
243
- fails "Pattern matching Hash pattern passes keys specified in pattern to #deconstruct_keys method if pattern contains double splat operator **" # Opal::SyntaxError: Unsupported sexp: case_match
244
- fails "Pattern matching Hash pattern passes nil to #deconstruct_keys method if pattern contains double splat operator **rest" # Opal::SyntaxError: `rest' is not allowed as a local variable name
210
+ fails "Pattern matching Array pattern accepts a subclass of Array from #deconstruct" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
211
+ fails "Pattern matching Array pattern calls #deconstruct even on objects that are already an array" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
212
+ fails "Pattern matching Array pattern calls #deconstruct once for multiple patterns, caching the result" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
213
+ fails "Pattern matching Array pattern does not match object if elements of array returned by #deconstruct method does not match elements in pattern" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
214
+ fails "Pattern matching Array pattern does not match object without #deconstruct method" # Mock '#<Object:0x239ca>' expected to receive respond_to?("deconstruct") exactly 1 times but received it 0 times
215
+ fails "Pattern matching Array pattern matches an object with #deconstruct method which returns an array and each element in array matches element in pattern" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
216
+ fails "Pattern matching Array pattern raises TypeError if #deconstruct method does not return array" # Expected TypeError (/deconstruct must return Array/) but got: NoMethodError (undefined method `obj' for #<MSpecEnv:0x1af0a>)
217
+ fails "Pattern matching Hash pattern calls #deconstruct_keys per pattern" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
218
+ fails "Pattern matching Hash pattern does not match object if #deconstruct_keys method does not return Hash" # Expected TypeError (/deconstruct_keys must return Hash/) but got: NoMethodError (undefined method `obj' for #<MSpecEnv:0x1af0a>)
219
+ fails "Pattern matching Hash pattern does not match object if #deconstruct_keys method returns Hash with non-symbol keys" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
220
+ fails "Pattern matching Hash pattern does not match object if elements of Hash returned by #deconstruct_keys method does not match values in pattern" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
221
+ fails "Pattern matching Hash pattern does not match object without #deconstruct_keys method" # Mock '#<Object:0x29382>' expected to receive respond_to?("deconstruct_keys") exactly 1 times but received it 0 times
222
+ fails "Pattern matching Hash pattern matches an object with #deconstruct_keys method which returns a Hash with equal keys and each value in Hash matches value in pattern" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
223
+ fails "Pattern matching Hash pattern passes keys specified in pattern as arguments to #deconstruct_keys method" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
224
+ fails "Pattern matching Hash pattern passes keys specified in pattern to #deconstruct_keys method if pattern contains double splat operator **" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
225
+ fails "Pattern matching Hash pattern passes nil to #deconstruct_keys method if pattern contains double splat operator **rest" # NoMethodError: undefined method `obj' for #<MSpecEnv:0x1af0a>
245
226
  fails "Pattern matching Hash pattern raise SyntaxError when keys duplicate in pattern" # Expected SyntaxError (/duplicated key name/) but got: Opal::SyntaxError (duplicate hash pattern key a)
246
- fails "Pattern matching Hash pattern supports 'string': key literal" # Opal::SyntaxError: Unsupported sexp: case_match
247
- fails "Pattern matching Hash pattern supports a: which means a: a" # Opal::SyntaxError: `a' is not allowed as a local variable name
248
- fails "Pattern matching Hash pattern supports double splat operator **rest" # Opal::SyntaxError: `rest' is not allowed as a local variable name
249
- fails "Pattern matching Hash pattern supports form Constant(id: pat, id: pat, ...)" # Opal::SyntaxError: Unsupported sexp: case_match
250
- fails "Pattern matching Hash pattern supports form Constant[id: pat, id: pat, ...]" # Opal::SyntaxError: Unsupported sexp: case_match
251
- fails "Pattern matching Hash pattern supports form id: pat, id: pat, ..." # Opal::SyntaxError: Unsupported sexp: case_match
252
- fails "Pattern matching Hash pattern supports form {id: pat, id: pat, ...}" # Opal::SyntaxError: Unsupported sexp: case_match
253
- fails "Pattern matching Hash pattern treats **nil like there should not be any other keys in a matched Hash" # Opal::SyntaxError: Unsupported sexp: case_match
254
- fails "Pattern matching allows using then operator" # Opal::SyntaxError: Unsupported sexp: case_match
255
- fails "Pattern matching alternative pattern does not support variable binding" # Expected SyntaxError (/illegal variable in alternative pattern/) but got: Opal::SyntaxError (`a' is not allowed as a local variable name)
256
- fails "Pattern matching alternative pattern matches if any of patterns matches" # Opal::SyntaxError: Unsupported sexp: case_match
257
- fails "Pattern matching alternative pattern support underscore prefixed variables in alternation" # Opal::SyntaxError: `_' is not allowed as a local variable name
258
- fails "Pattern matching binds variables" # Opal::SyntaxError: `a' is not allowed as a local variable name
259
- fails "Pattern matching can be standalone assoc operator that deconstructs value" # Opal::SyntaxError: `a' is not allowed as a local variable name
227
+ fails "Pattern matching alternative pattern does not support variable binding" # Expected SyntaxError (/illegal variable in alternative pattern/) but no exception was raised (nil was returned)
260
228
  fails "Pattern matching cannot mix in and when operators" # Expected SyntaxError (/syntax error, unexpected `in'/) but got: Opal::SyntaxError (unexpected token kIN)
261
- fails "Pattern matching checks patterns until the first matching" # Opal::SyntaxError: Unsupported sexp: case_match
262
- fails "Pattern matching evaluates the case expression once for multiple patterns, caching the result" # Opal::SyntaxError: Unsupported sexp: case_match
263
- fails "Pattern matching executes else clause if no pattern matches" # Opal::SyntaxError: Unsupported sexp: case_match
264
- fails "Pattern matching extends case expression with case/in construction" # Opal::SyntaxError: Unsupported sexp: case_match
265
- fails "Pattern matching guards does not evaluate guard if pattern does not match" # Opal::SyntaxError: Unsupported sexp: case_match
266
- fails "Pattern matching guards executes else clause if no guarded pattern matches" # Opal::SyntaxError: Unsupported sexp: case_match
267
- fails "Pattern matching guards makes bound variables visible in guard" # Opal::SyntaxError: `a' is not allowed as a local variable name
268
- fails "Pattern matching guards raises NoMatchingPatternError if no guarded pattern matches and no else clause" # NameError: uninitialized constant NoMatchingPatternError
269
- fails "Pattern matching guards supports if guard" # Opal::SyntaxError: Unsupported sexp: case_match
270
- fails "Pattern matching guards supports unless guard" # Opal::SyntaxError: Unsupported sexp: case_match
271
- fails "Pattern matching guards takes guards into account when there are several matching patterns" # Opal::SyntaxError: Unsupported sexp: case_match
272
- fails "Pattern matching raises NoMatchingPatternError if no pattern matches and no else clause" # NameError: uninitialized constant NoMatchingPatternError
273
- fails "Pattern matching refinements are used for #=== in constant pattern" # NoMethodError: undefined method `refine' for #<Module:0x79d4c>
274
- fails "Pattern matching refinements are used for #deconstruct" # NoMethodError: undefined method `refine' for #<Module:0x79d50>
275
- fails "Pattern matching refinements are used for #deconstruct_keys" # NoMethodError: undefined method `refine' for #<Module:0x79d54>
276
- fails "Pattern matching value pattern allows string literal with interpolation" # Opal::SyntaxError: Unsupported sexp: case_match
277
- fails "Pattern matching value pattern matches an object such that pattern === object" # Opal::SyntaxError: Unsupported sexp: case_match
278
- fails "Pattern matching variable pattern allow using _ name to drop values" # Opal::SyntaxError: `a' is not allowed as a local variable name
279
- fails "Pattern matching variable pattern allows applying ^ operator to bound variables" # Opal::SyntaxError: `n' is not allowed as a local variable name
280
- fails "Pattern matching variable pattern create local variables even if a pattern doesn't match" # Opal::SyntaxError: `a' is not allowed as a local variable name
281
- fails "Pattern matching variable pattern does not support using variable name (except _) several times" # Expected SyntaxError (/duplicated variable name/) but got: Opal::SyntaxError (`a' is not allowed as a local variable name)
282
- fails "Pattern matching variable pattern makes bounded variable visible outside a case statement scope" # Opal::SyntaxError: `a' is not allowed as a local variable name
283
- fails "Pattern matching variable pattern matches a value and binds variable name to this value" # Opal::SyntaxError: `a' is not allowed as a local variable name
229
+ fails "Pattern matching variable pattern allows applying ^ operator to bound variables" # NoMatchingPatternError: [1, 1]
230
+ fails "Pattern matching variable pattern does not support using variable name (except _) several times" # Expected SyntaxError (/duplicated variable name/) but got: Opal::SyntaxError (duplicate variable name a)
284
231
  fails "Pattern matching variable pattern requires bound variable to be specified in a pattern before ^ operator when it relies on a bound variable" # Expected SyntaxError (/n: no such local variable/) but got: Opal::SyntaxError (no such local variable: `n')
285
232
  fails "Pattern matching variable pattern supports existing variables in a pattern specified with ^ operator" # Opal::SyntaxError: no such local variable: `a'
286
- fails "Pattern matching variable pattern supports using _ in a pattern several times" # Opal::SyntaxError: `_' is not allowed as a local variable name
287
- fails "Pattern matching variable pattern supports using any name with _ at the beginning in a pattern several times" # Opal::SyntaxError: `_x' is not allowed as a local variable name
288
233
  fails "Pattern matching warning warns about pattern matching is experimental feature" # NameError: uninitialized constant Warning
289
234
  fails "Post-args with optional args with a circular argument reference shadows an existing local with the same name as the argument"
290
235
  fails "Post-args with optional args with a circular argument reference shadows an existing method with the same name as the argument"
@@ -318,6 +263,7 @@ opal_filter "language" do
318
263
  fails "Safe navigator allows assignment methods"
319
264
  fails "Safe navigator allows assignment operators"
320
265
  fails "Safe navigator does not call the operator method lazily with an assignment operator"
266
+ fails "Struct#deconstruct_keys requires one argument" # Expected ArgumentError (/wrong number of arguments \(given 0, expected 1\)/) but got: ArgumentError ([#deconstruct_keys] wrong number of arguments(0 for 1))
321
267
  fails "The =~ operator with named captures on syntax of 'string_literal' =~ /regexp/ does not set local variables" # Exception: named captures are not supported in javascript: "(?<matched>foo)(?<unmatched>bar)?"
322
268
  fails "The =~ operator with named captures on syntax of /regexp/ =~ string_variable sets local variables by the captured pairs"
323
269
  fails "The =~ operator with named captures on syntax of regexp_variable =~ string_variable does not set local variables"
@@ -394,6 +340,7 @@ opal_filter "language" do
394
340
  fails "The rescue keyword only accepts Module or Class in rescue clauses" # RuntimeError: error
395
341
  fails "The rescue keyword only accepts Module or Class in splatted rescue clauses" # RuntimeError: error
396
342
  fails "The rescue keyword rescues the exception in the deepest rescue block declared to handle the appropriate exception type" # Expected "StandardError: an error occurred" to include ":in `raise_standard_error'"
343
+ fails "The rescue keyword suppresses exception from block when raises one from rescue expression" # NoMethodError: undefined method `cause' for #<RuntimeError: from rescue expression>
397
344
  fails "The rescue keyword will execute an else block even without rescue and ensure" # Expected warning to match: /else without rescue is useless/ but got: ""
398
345
  fails "The rescue keyword without rescue expression will not rescue exceptions except StandardError" # NameError: uninitialized constant SystemStackError
399
346
  fails "The retry keyword inside a begin block's rescue block causes the begin block to be executed again"
@@ -422,23 +369,13 @@ opal_filter "language" do
422
369
  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
423
370
  fails "The until expression restarts the current iteration without reevaluating condition with redo"
424
371
  fails "The until modifier restarts the current iteration without reevaluating condition with redo"
425
- fails "The until modifier with begin .. end block evaluates condition after block execution"
426
372
  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]
427
- fails "The until modifier with begin .. end block runs block at least once (even if the expression is true)"
428
- fails "The until modifier with begin .. end block skips to end of body with next"
429
373
  fails "The while expression stops running body if interrupted by break in a begin ... end element op-assign value"
430
374
  fails "The while expression stops running body if interrupted by break in a parenthesized element op-assign value"
431
- fails "The while modifier with begin .. end block evaluates condition after block execution"
432
- fails "The while modifier with begin .. end block restarts the current iteration without reevaluating condition with redo" # Expected [1, 1, 1, 2] to equal [0, 0, 0, 1, 2]
433
- fails "The while modifier with begin .. end block runs block at least once (even if the expression is false)"
434
- fails "The while modifier with begin .. end block skips to end of body with next"
435
375
  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)
436
376
  fails "The yield call taking no arguments ignores assignment to the explicit block argument and calls the passed block"
437
377
  fails "a method definition that sets more than one default parameter all to the same value only allows overriding the default value of the first such parameter in each set" # ArgumentError: [MSpecEnv#foo] wrong number of arguments(2 for -1)
438
378
  fails "a method definition that sets more than one default parameter all to the same value treats the argument after the multi-parameter normally" # ArgumentError: [MSpecEnv#bar] wrong number of arguments(3 for -1)
439
- fails "delegation with def(...) delegates block" # Opal::SyntaxError: Unsupported sexp: forward_args
440
- fails "delegation with def(...) delegates rest and kwargs" # Opal::SyntaxError: Unsupported sexp: forward_args
441
- fails "delegation with def(...) parses as open endless Range when brackets are omitted" # Opal::SyntaxError: Unsupported sexp: forward_args
442
379
  fails "self in a metaclass body (class << obj) raises a TypeError for numbers"
443
380
  fails "self in a metaclass body (class << obj) raises a TypeError for symbols"
444
381
  fails "self.send(:block_given?) returns false when a method defined by define_method is called with a block"
@@ -21,6 +21,7 @@ opal_filter "Marshal" do
21
21
  fails "Marshal.load for a Regexp loads a extended_user_regexp having ivar"
22
22
  fails "Marshal.load for a Regexp loads an extended Regexp" # Expected /[a-z]/ == /(?:)/ to be truthy but was false
23
23
  fails "Marshal.load for a String loads a String as BINARY if no encoding is specified at the end" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
24
+ fails "Marshal.load for a String loads a String subclass with custom constructor" # ArgumentError: [UserCustomConstructorString#initialize] wrong number of arguments(1 for 2)
24
25
  fails "Marshal.load for a Struct does not call initialize on the unmarshaled struct"
25
26
  fails "Marshal.load for a Symbol loads a Symbol" # Expected #<Encoding:UTF-16LE> to equal #<Encoding:ASCII-8BIT (dummy)>
26
27
  fails "Marshal.load for a Symbol loads a binary encoded Symbol" # Expected "â\u0086\u0092" to equal "→"
@@ -34,11 +35,8 @@ opal_filter "Marshal" do
34
35
  fails "Marshal.load for an Exception loads a marshalled exception with a message"
35
36
  fails "Marshal.load for an Exception loads a marshalled exception with no message"
36
37
  fails "Marshal.load for an Exception loads an marshalled exception with ivars" # Expected "Exception" == "foo" to be truthy but was false
37
- fails "Marshal.load for an Integer loads an Integer -2361183241434822606847" # Expected -2 == -2.3611832414348226e+21 to be truthy but was false
38
- fails "Marshal.load for an Integer loads an Integer 2361183241434822606847" # Expected 2 == 2.3611832414348226e+21 to be truthy but was false
39
38
  fails "Marshal.load for an Object loads an Object with a non-US-ASCII instance variable" # NameError: '@é' is not allowed as an instance variable name
40
39
  fails "Marshal.load for an Object raises ArgumentError if the object from an 'o' stream is not dumpable as 'o' type user class" # Expected ArgumentError but no exception was raised (#<File:0x3b160> was returned)
41
- fails "Marshal.load loads a Integer 2**90" # Expected 1 == 1.2379400392853803e+27 to be truthy but was false
42
40
  fails "Marshal.load loads a Regexp" # anchors difference
43
41
  fails "Marshal.load loads an array containing objects having _dump method, and with proc"
44
42
  fails "Marshal.load loads an array containing objects having marshal_dump method, and with proc"
@@ -16,6 +16,7 @@ opal_filter "Module" do
16
16
  fails "Module#attr_accessor converts non string/symbol/fixnum names to strings using to_str"
17
17
  fails "Module#attr_accessor not allows creating an attr_accessor on an immediate class"
18
18
  fails "Module#attr_accessor on immediates can read through the accessor" # NoMethodError: undefined method `foobar' for 1
19
+ fails "Module#attr_accessor raises FrozenError if the receiver if frozen" # Expected FrozenError but no exception was raised (42 was returned)
19
20
  fails "Module#attr_accessor raises a TypeError when the given names can't be converted to strings using to_str"
20
21
  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
21
22
  fails "Module#attr_reader applies current visibility to methods created"
@@ -28,6 +29,7 @@ opal_filter "Module" do
28
29
  fails "Module#attr_writer converts non string/symbol names to strings using to_str" # Expected false == true to be truthy but was false
29
30
  fails "Module#attr_writer converts non string/symbol/fixnum names to strings using to_str"
30
31
  fails "Module#attr_writer not allows for adding an attr_writer to an immediate"
32
+ fails "Module#attr_writer raises FrozenError if the receiver if frozen" # Expected FrozenError but no exception was raised (42 was returned)
31
33
  fails "Module#attr_writer raises a TypeError when the given names can't be converted to strings using to_str"
32
34
  fails "Module#attr_writer returns an array of defined method names as symbols" # Expected nil == ["foo=", "bar="] to be truthy but was false
33
35
  fails "Module#autoload (concurrently) blocks a second thread while a first is doing the autoload"
@@ -78,11 +80,13 @@ opal_filter "Module" do
78
80
  fails "Module#class_eval resolves constants in the caller scope ignoring send"
79
81
  fails "Module#class_eval resolves constants in the caller scope" # fails because of the difference between module_eval("Const") and module_eval { Const } (only the second one is supported by Opal)
80
82
  fails "Module#class_eval uses the optional filename and lineno parameters for error messages"
83
+ fails "Module#const_defined? coerces the inherit flag to a boolean" # Expected true to be false
81
84
  fails "Module#const_defined? returns true for toplevel constant when the name begins with '::'"
82
85
  fails "Module#const_defined? returns true or false for the nested name"
83
86
  fails "Module#const_defined? returns true when passed a scoped constant name for a constant in the inheritance hierarchy and the inherited flag is default"
84
87
  fails "Module#const_defined? returns true when passed a scoped constant name for a constant in the inheritance hierarchy and the inherited flag is true"
85
88
  fails "Module#const_defined? returns true when passed a scoped constant name"
89
+ fails "Module#const_get coerces the inherit flag to a boolean" # Expected NameError but no exception was raised ("const1" was returned)
86
90
  fails "Module#const_get does autoload a constant with a toplevel scope qualifier" # NameError: uninitialized constant CSAutoloadB
87
91
  fails "Module#const_get does autoload a constant" # NameError: uninitialized constant CSAutoloadA
88
92
  fails "Module#const_get does autoload a module and resolve a constant within" # NameError: uninitialized constant CSAutoloadC
@@ -130,6 +134,7 @@ opal_filter "Module" do
130
134
  fails "Module#const_source_location with statically assigned constants searches location path the superclass chain" # NoMethodError: undefined method `__dir__' for #<MSpecEnv:0x6efae>
131
135
  fails "Module#constants doesn't returns inherited constants when passed nil"
132
136
  fails "Module#constants returns only public constants"
137
+ fails "Module#define_method passed { |a,| } creates a method that does not destructure the passed argument" # Expected [1, 2] == 1 to be truthy but was false
133
138
  fails "Module#define_method raises a TypeError when a Method from a singleton class is defined on another class"
134
139
  fails "Module#define_method raises a TypeError when a Method from one class is defined on an unrelated class"
135
140
  fails "Module#define_method raises a TypeError when an UnboundMethod from a child class is defined on a parent class"
@@ -180,6 +185,7 @@ opal_filter "Module" do
180
185
  fails "Module#prepend uses only new module when dupping the module" # Expected [#<Module:0x6c37a>] == [#<Module:0x6c38c>, #<Module:0x6c37a>] to be truthy but was false
181
186
  fails "Module#private with argument array as a single argument sets visibility of given method names" # Expected #<Module:0x7b0e0> to have private instance method 'test1' but it does not
182
187
  fails "Module#private with argument one or more arguments sets visibility of given method names" # Expected #<Module:0x2f186> to have private instance method 'test1' but it does not
188
+ fails "Module#private_constant marked constants in a module raises a NameError when accessed directly from modules that include the module" # Expected NameError but no exception was raised (true was returned)
183
189
  fails "Module#private_constant marked constants sends #const_missing to the original class or module" # Expected true == "Foo" to be truthy but was false
184
190
  fails "Module#private_method_defined? raises a TypeError if passed an Integer" # Expected TypeError but no exception was raised (false was returned)
185
191
  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)
@@ -206,7 +212,9 @@ opal_filter "Module" do
206
212
  fails "Module#refine for methods accessed indirectly is honored by &" # NoMethodError: undefined method `refine' for #<Module:0x4b006>
207
213
  fails "Module#refine for methods accessed indirectly is honored by BasicObject#__send__" # NoMethodError: undefined method `refine' for #<Module:0x3aeb2>
208
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>
209
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>
210
218
  fails "Module#refine for methods accessed indirectly is honored by Kernel#public_send" # NoMethodError: undefined method `refine' for #<Module:0x4b00e>
211
219
  fails "Module#refine for methods accessed indirectly is honored by Kernel#respond_to?" # NoMethodError: undefined method `refine' for #<Module:0x4b016>
212
220
  fails "Module#refine for methods accessed indirectly is honored by Kernel#send" # NoMethodError: undefined method `refine' for #<Module:0x3aeae>
@@ -248,6 +256,14 @@ opal_filter "Module" do
248
256
  fails "Module#remove_const calls #to_str to convert the given name to a String"
249
257
  fails "Module#remove_const raises a TypeError if conversion to a String by calling #to_str fails"
250
258
  fails "Module#remove_const returns nil when removing autoloaded constant"
259
+ fails "Module#ruby2_keywords acceps String as well" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x40040>>
260
+ fails "Module#ruby2_keywords marks the final hash argument as keyword hash" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x40036>>
261
+ fails "Module#ruby2_keywords prints warning when a method accepts keyword splat" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x4001e>>
262
+ fails "Module#ruby2_keywords prints warning when a method accepts keywords" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x40048>>
263
+ fails "Module#ruby2_keywords prints warning when a method does not accept argument splat" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x4002e>>
264
+ fails "Module#ruby2_keywords raises NameError when passed not existing method name" # Expected NameError (/undefined method `not_existing'/) but got: NoMethodError (undefined method `ruby2_keywords' for #<Class:#<Object:0x4003a>>)
265
+ fails "Module#ruby2_keywords raises TypeError when passed not Symbol or String" # Expected TypeError (/is not a symbol nor a string/) but got: NoMethodError (undefined method `ruby2_keywords' for #<Class:#<Object:0x40026>>)
266
+ fails "Module#ruby2_keywords returns nil" # NoMethodError: undefined method `ruby2_keywords' for #<Class:#<Object:0x40044>>
251
267
  fails "Module#to_s always show the refinement name, even if the module is named" # NoMethodError: undefined method `refine' for ModuleSpecs::RefinementInspect
252
268
  fails "Module#to_s does not call #inspect or #to_s for singleton classes" # Expected "#<Class:#<:0x25bee>>" =~ /\A#<Class:#<#<Class:0x25bf2>:0x\h+>>\z/ to be truthy but was nil
253
269
  fails "Module#to_s for objects includes class name and object ID" # Expected "#<Class:#<ModuleSpecs::NamedClass:0xa424>>" =~ /^#<Class:#<ModuleSpecs::NamedClass:0x\h+>>$/ to be truthy but was nil
@@ -277,5 +293,4 @@ opal_filter "Module" do
277
293
  fails "Module#using scope of refinement is not active for code defined outside the current scope" # NoMethodError: undefined method `refine' for #<Module:0x2a072>
278
294
  fails "Module#using scope of refinement is not active when class/module reopens" # NoMethodError: undefined method `refine' for #<Module:0x2a056>
279
295
  fails "Module#using works in classes too" # NoMethodError: undefined method `refine' for #<Module:0x2a01c>
280
- fails "Module::Nesting returns the list of Modules nested at the point of call"
281
296
  end