diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-22 19:07:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-22 20:44:46 +0900 |
commit | 1997e10f6caeae49660ceb9342a01a4fd2efc788 (patch) | |
tree | 0406ef453e90a5d4735da9fedabd9ceb3e330a1d /test/ruby/test_syntax.rb | |
parent | 1fe5bffefdf799c24f4a0eed97e1ceefc1dc66d6 (diff) |
Made parentheses mandatory in endless method defition
Even for empty argument list, not to be confusing with a writer
method name.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3051
Diffstat (limited to 'test/ruby/test_syntax.rb')
-rw-r--r-- | test/ruby/test_syntax.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index c471006199..df6c2e383f 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1415,9 +1415,11 @@ eom end def test_methoddef_endless - assert_valid_syntax('private def foo = 42') + assert_syntax_error('private def foo = 42', /unexpected '='/) + assert_valid_syntax('private def foo() = 42') assert_valid_syntax('private def inc(x) = x + 1') - assert_valid_syntax('private def obj.foo = 42') + assert_syntax_error('private def obj.foo = 42', /unexpected '='/) + assert_valid_syntax('private def obj.foo() = 42') assert_valid_syntax('private def obj.inc(x) = x + 1') eval('def self.inc(x) = x + 1 => @x') assert_equal(:inc, @x) |