summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2024-01-12 09:12:43 -0800
committergit <svn-admin@ruby-lang.org>2024-01-17 17:47:33 +0000
commit603f2ca730cc62818a7a9852291f5877cbadd55d (patch)
tree2892e2da616f40b51cb3e6fe97341562cfb45762 /test
parentcd4290910c7f3f63118567101bf6cec4df90361a (diff)
[ruby/prism] Parse `it` default parameter
https://github.com/ruby/prism/commit/a0c5361b9f
Diffstat (limited to 'test')
-rw-r--r--test/prism/errors_test.rb7
-rw-r--r--test/prism/location_test.rb6
2 files changed, 13 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index d1af9a5dae..60322585f0 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -2069,6 +2069,13 @@ module Prism
], compare_ripper: false # Ripper does not check 'both block arg and actual block given'.
end
+ def test_it_with_ordinary_parameter
+ source = "proc { || it }"
+ errors = [["`it` is not allowed when an ordinary parameter is defined", 10..12]]
+
+ assert_errors expression(source), source, errors, compare_ripper: false
+ end
+
private
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")
diff --git a/test/prism/location_test.rb b/test/prism/location_test.rb
index e5b7546925..a36f5fe011 100644
--- a/test/prism/location_test.rb
+++ b/test/prism/location_test.rb
@@ -570,6 +570,12 @@ module Prism
def test_LocalVariableReadNode
assert_location(LocalVariableReadNode, "foo = 1; foo", 9...12)
+ assert_location(LocalVariableReadNode, "-> { it }", 5...7) do |node|
+ node.body.body.first
+ end
+ assert_location(LocalVariableReadNode, "foo { it }", 6...8) do |node|
+ node.block.body.body.first
+ end
end
def test_LocalVariableTargetNode