diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-12-25 15:38:12 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-12-25 18:28:21 +0900 |
commit | 596db9c1f486d6609a4e97d82c8c71b54609fb6f (patch) | |
tree | 9697785982d539e2fa9383d2050a5c1a42bdcf73 /test/ruby/test_syntax.rb | |
parent | 6e13cde457cbf9b678191e7a7b8684fc83bf392c (diff) |
[Feature #19370] Blocks without anonymous parameters should not affect
Diffstat (limited to 'test/ruby/test_syntax.rb')
-rw-r--r-- | test/ruby/test_syntax.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index e53e2a2e61..5d8d40605e 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -77,6 +77,7 @@ class TestSyntax < Test::Unit::TestCase def test_anonymous_block_forwarding assert_syntax_error("def b; c(&); end", /no anonymous block parameter/) assert_syntax_error("def b(&) ->(&) {c(&)} end", /anonymous block parameter is also used/) + assert_valid_syntax("def b(&) ->() {c(&)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(&); c(&) end @@ -147,6 +148,9 @@ class TestSyntax < Test::Unit::TestCase assert_syntax_error("def b(*) ->(*) {c(*)} end", /anonymous rest parameter is also used/) assert_syntax_error("def b(a, *) ->(*) {c(1, *)} end", /anonymous rest parameter is also used/) assert_syntax_error("def b(*) ->(a, *) {c(*)} end", /anonymous rest parameter is also used/) + assert_valid_syntax("def b(*) ->() {c(*)} end") + assert_valid_syntax("def b(a, *) ->() {c(1, *)} end") + assert_valid_syntax("def b(*) ->(a) {c(*)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(*); c(*) end @@ -163,6 +167,9 @@ class TestSyntax < Test::Unit::TestCase assert_syntax_error("def b(**) ->(**) {c(**)} end", /anonymous keyword rest parameter is also used/) assert_syntax_error("def b(k:, **) ->(**) {c(k: 1, **)} end", /anonymous keyword rest parameter is also used/) assert_syntax_error("def b(**) ->(k:, **) {c(**)} end", /anonymous keyword rest parameter is also used/) + assert_valid_syntax("def b(**) ->() {c(**)} end") + assert_valid_syntax("def b(k:, **) ->() {c(k: 1, **)} end") + assert_valid_syntax("def b(**) ->(k:) {c(**)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(**); c(**) end |