summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTSUYUSATO Kitsune <make.just.on@gmail.com>2023-12-27 12:05:04 +0900
committergit <svn-admin@ruby-lang.org>2024-01-02 19:08:15 +0000
commit0ee625ceae004f2ca53ebe234310ff2d44f7388c (patch)
tree80528bc06409335ad289d7ce09d1135e81b23973 /test
parent165deec5fef5076bca99c038caf8c9da34abe0fd (diff)
[ruby/prism] Fix to check multiple block arguments for forwarding arg
Fix https://github.com/ruby/prism/pull/2111 https://github.com/ruby/prism/commit/21ca243d0a
Diffstat (limited to 'test')
-rw-r--r--test/prism/errors_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index 57c0719aa7..7648875691 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -2046,6 +2046,20 @@ module Prism
]
end
+ def test_block_arg_and_block
+ source = 'foo(&1) { }'
+ assert_errors expression(source), source, [
+ ['multiple block arguments; only one block is allowed', 8..11]
+ ], compare_ripper: false # Ripper does not check 'both block arg and actual block given'.
+ end
+
+ def test_forwarding_arg_and_block
+ source = 'def foo(...) = foo(...) { }'
+ assert_errors expression(source), source, [
+ ['both a block argument and a forwarding argument; only one block is allowed', 24..27]
+ ], compare_ripper: false # Ripper does not check 'both block arg and actual block given'.
+ end
+
private
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")