diff --git a/test/mri/tests/ruby/test_parse.rb b/test/mri/tests/ruby/test_parse.rb index 6839581a0b71..7c0d5bfa6578 100644 --- a/test/mri/tests/ruby/test_parse.rb +++ b/test/mri/tests/ruby/test_parse.rb @@ -27,7 +27,7 @@ def test_else_without_rescue end def test_alias_backref - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /can't make alias|invalid argument being passed to `alias`/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /can't make alias/) do begin; alias $foo $1 end; @@ -85,7 +85,7 @@ class << o assert_equal([42, 42], [o.Foo, o.Bar]) assert_equal([42, 42], [o::baz, o::qux]) - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /Can't set variable|immutable variable as a write target/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /Can't set variable/) do begin; $1 ||= t.foo 42 end; @@ -193,13 +193,13 @@ def foo end def test_class_module - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /must be CONSTANT|expected a constant name/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /must be CONSTANT/) do begin; class foo; end end; end - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /in method body|unexpected class definition in a method definition/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /in method body/) do begin; def foo class Foo; end @@ -295,7 +295,7 @@ def foo(@@foo); end end; end - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be an instance variable|expected a local variable name in the block parameters/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be an instance variable/) do begin; o.foo {|; @a| @a = 42 } end; @@ -439,13 +439,13 @@ def test_duplicate_argument end; end - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument|repeated parameter name/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument/) do begin; 1.times {|a, a|} end; end - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument|repeated parameter name/) do + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument/) do begin; def foo(a, a); end end; @@ -652,12 +652,12 @@ def test_question def test_percent assert_equal(:foo, eval('%s(foo)')) - assert_syntax_error('%s', /unterminated quoted string|expected a closing delimiter for the dynamic symbol/) - assert_syntax_error('%ss', /unknown type|invalid `%` token/) - assert_syntax_error('%z()', /unknown type|invalid `%` token/) - assert_syntax_error("%\u3042", /unknown type|invalid `%` token/) - assert_syntax_error("%q\u3042", /unknown type|invalid `%` token/) - assert_syntax_error("%", /unterminated quoted string|invalid `%` token/) + assert_syntax_error('%s', /unterminated quoted string/) + assert_syntax_error('%ss', /unknown type/) + assert_syntax_error('%z()', /unknown type/) + assert_syntax_error("%\u3042", /unknown type/) + assert_syntax_error("%q\u3042", /unknown type/) + assert_syntax_error("%", /unterminated quoted string/) end def test_symbol @@ -685,7 +685,7 @@ def test_symbol end def test_parse_string - assert_syntax_error("/\n", /unterminated|expected a closing delimiter for the regular expression/) + assert_syntax_error("/\n", /unterminated/) end def test_here_document @@ -869,7 +869,7 @@ def test_block_dup end def test_set_backref - assert_syntax_error("$& = 1", /Can't set variable|immutable variable as a write target/) + assert_syntax_error("$& = 1", /Can't set variable/) end def test_arg_concat @@ -1278,7 +1278,7 @@ def test_heredoc_unterminated_interpolation end def test_unexpected_token_error - assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected|expected a newline or semicolon after the statement/) + assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected/) end def test_unexpected_token_after_numeric @@ -1298,7 +1298,7 @@ def test_truncated_source_line end def test_unterminated_regexp_error - e = assert_syntax_error("/x", /unterminated regexp meets end of file|expected a closing delimiter for the regular expression/) + e = assert_syntax_error("/x", /unterminated regexp meets end of file/) assert_not_match(/unexpected tSTRING_END/, e.message) end @@ -1330,9 +1330,9 @@ def test_eof end def test_eof_in_def - assert_syntax_error("def m\n\0""end", /unexpected|cannot parse the expression/) - assert_syntax_error("def m\n\C-d""end", /unexpected|cannot parse the expression/) - assert_syntax_error("def m\n\C-z""end", /unexpected|cannot parse the expression/) + assert_syntax_error("def m\n\0""end", /unexpected/) + assert_syntax_error("def m\n\C-d""end", /unexpected/) + assert_syntax_error("def m\n\C-z""end", /unexpected/) end def test_unexpected_eof diff --git a/test/mri/tests/ruby/test_pattern_matching.rb b/test/mri/tests/ruby/test_pattern_matching.rb index 1641b631a5f0..74f039e7b96c 100644 --- a/test/mri/tests/ruby/test_pattern_matching.rb +++ b/test/mri/tests/ruby/test_pattern_matching.rb @@ -1161,8 +1161,7 @@ def test_hash_pattern end end - bug18890 = self.then do # TruffleRuby: keep the test but do not check the warning - # bug18890 = assert_warning(/(?:.*:[47]: warning: possibly useless use of a literal in void context\n){2}/) do + bug18890 = assert_warning(/(?:.*:[47]: warning: possibly useless use of a literal in void context\n){2}/) do eval("#{<<~';;;'}") proc do |i| case i @@ -1248,13 +1247,13 @@ def test_hash_pattern case _ in "#{a}": a end - }, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) + }, /symbol literal with interpolation is not allowed/) assert_syntax_error(%q{ case _ in "#{a}": end - }, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) + }, /symbol literal with interpolation is not allowed/) end def test_paren diff --git a/test/mri/tests/ruby/test_refinement.rb b/test/mri/tests/ruby/test_refinement.rb index 06ff9323402e..8771f8bc98e7 100644 --- a/test/mri/tests/ruby/test_refinement.rb +++ b/test/mri/tests/ruby/test_refinement.rb @@ -2572,15 +2572,11 @@ def test_refine_array_min_max class Bug17822 module Ext refine(Bug17822) do - def foo - :refined - end + def foo = :refined end end - private def foo - :not_refined - end + private(def foo = :not_refined) module Client using Ext diff --git a/test/mri/tests/ruby/test_require.rb b/test/mri/tests/ruby/test_require.rb index 35274ccfc934..871912e4910b 100644 --- a/test/mri/tests/ruby/test_require.rb +++ b/test/mri/tests/ruby/test_require.rb @@ -221,7 +221,7 @@ def assert_syntax_error_backtrace Dir.mktmpdir do |tmp| req = File.join(tmp, "test.rb") File.write(req, ",\n") - e = assert_raise_with_message(SyntaxError, /unexpected|cannot parse the expression/) { + e = assert_raise_with_message(SyntaxError, /unexpected/) { yield req } assert_not_nil(bt = e.backtrace, "no backtrace") @@ -237,7 +237,7 @@ def test_require_syntax_error def test_require_syntax_error_rescued assert_syntax_error_backtrace do |req| - assert_raise_with_message(SyntaxError, /unexpected|cannot parse the expression/) {require req} + assert_raise_with_message(SyntaxError, /unexpected/) {require req} require req end end diff --git a/test/mri/tests/ruby/test_syntax.rb b/test/mri/tests/ruby/test_syntax.rb index 04ab4eb70e11..cd84988efd34 100644 --- a/test/mri/tests/ruby/test_syntax.rb +++ b/test/mri/tests/ruby/test_syntax.rb @@ -600,28 +600,28 @@ def test_cmdarg_kwarg_lvar_clashing_method end def test_duplicated_arg - assert_syntax_error("def foo(a, a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a, a) end", /duplicated argument name/) assert_valid_syntax("def foo(_, _) end") (obj = Object.new).instance_eval("def foo(_, x, _) x end") assert_equal(2, obj.foo(1, 2, 3)) end def test_duplicated_rest - assert_syntax_error("def foo(a, *a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a, *a) end", /duplicated argument name/) assert_valid_syntax("def foo(_, *_) end") (obj = Object.new).instance_eval("def foo(_, x, *_) x end") assert_equal(2, obj.foo(1, 2, 3)) end def test_duplicated_opt - assert_syntax_error("def foo(a, a=1) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a, a=1) end", /duplicated argument name/) assert_valid_syntax("def foo(_, _=1) end") (obj = Object.new).instance_eval("def foo(_, x, _=42) x end") assert_equal(2, obj.foo(1, 2)) end def test_duplicated_opt_rest - assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name/) assert_valid_syntax("def foo(_=1, *_) end") (obj = Object.new).instance_eval("def foo(_, x=42, *_) x end") assert_equal(42, obj.foo(1)) @@ -633,7 +633,7 @@ def test_duplicated_rest_opt end def test_duplicated_rest_post - assert_syntax_error("def foo(*a, a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(*a, a) end", /duplicated argument name/) assert_valid_syntax("def foo(*_, _) end") (obj = Object.new).instance_eval("def foo(*_, x, _) x end") assert_equal(2, obj.foo(1, 2, 3)) @@ -644,7 +644,7 @@ def test_duplicated_rest_post end def test_duplicated_opt_post - assert_syntax_error("def foo(a=1, a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a=1, a) end", /duplicated argument name/) assert_valid_syntax("def foo(_=1, _) end") (obj = Object.new).instance_eval("def foo(_=1, x, _) x end") assert_equal(2, obj.foo(1, 2, 3)) @@ -655,7 +655,7 @@ def test_duplicated_opt_post end def test_duplicated_kw - assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name/) assert_valid_syntax("def foo(_, _: 1) end") (obj = Object.new).instance_eval("def foo(_, x, _: 1) x end") assert_equal(3, obj.foo(2, 3)) @@ -666,7 +666,7 @@ def test_duplicated_kw end def test_duplicated_rest_kw - assert_syntax_error("def foo(*a, a: 1) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(*a, a: 1) end", /duplicated argument name/) assert_nothing_raised {def foo(*_, _: 1) end} (obj = Object.new).instance_eval("def foo(*_, x: 42, _: 1) x end") assert_equal(42, obj.foo(42)) @@ -677,7 +677,7 @@ def test_duplicated_rest_kw end def test_duplicated_opt_kw - assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name/) assert_valid_syntax("def foo(_=1, _: 1) end") (obj = Object.new).instance_eval("def foo(_=42, x, _: 1) x end") assert_equal(0, obj.foo(0)) @@ -685,7 +685,7 @@ def test_duplicated_opt_kw end def test_duplicated_kw_kwrest - assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name/) assert_valid_syntax("def foo(_: 1, **_) end") (obj = Object.new).instance_eval("def foo(_: 1, x: 42, **_) x end") assert_equal(42, obj.foo()) @@ -695,7 +695,7 @@ def test_duplicated_kw_kwrest end def test_duplicated_rest_kwrest - assert_syntax_error("def foo(*a, **a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(*a, **a) end", /duplicated argument name/) assert_valid_syntax("def foo(*_, **_) end") (obj = Object.new).instance_eval("def foo(*_, x, **_) x end") assert_equal(1, obj.foo(1)) @@ -704,7 +704,7 @@ def test_duplicated_rest_kwrest end def test_duplicated_opt_kwrest - assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name|repeated parameter name/) + assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name/) assert_valid_syntax("def foo(_=1, **_) end") (obj = Object.new).instance_eval("def foo(_=42, x, **_) x end") assert_equal(1, obj.foo(1)) @@ -1792,7 +1792,7 @@ def test_numbered_parameter assert_syntax_error('-> {-> {_1}; _2}', /numbered parameter is already used/) assert_syntax_error('proc {_1; _1 = nil}', /Can't assign to numbered parameter _1/) assert_syntax_error('proc {_1 = nil}', /_1 is reserved for numbered parameter/) - # assert_syntax_error('_2=1', /_2 is reserved for numbered parameter/) # GR-30031 + assert_syntax_error('_2=1', /_2 is reserved for numbered parameter/) assert_syntax_error('proc {|_3|}', /_3 is reserved for numbered parameter/) assert_syntax_error('def x(_4) end', /_4 is reserved for numbered parameter/) assert_syntax_error('def _5; end', /_5 is reserved for numbered parameter/)