diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2024-01-12 09:12:43 -0800 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-01-17 17:47:33 +0000 |
| commit | 603f2ca730cc62818a7a9852291f5877cbadd55d (patch) | |
| tree | 2892e2da616f40b51cb3e6fe97341562cfb45762 /test/prism | |
| parent | cd4290910c7f3f63118567101bf6cec4df90361a (diff) | |
[ruby/prism] Parse `it` default parameter
https://github.com/ruby/prism/commit/a0c5361b9f
Diffstat (limited to 'test/prism')
| -rw-r--r-- | test/prism/errors_test.rb | 7 | ||||
| -rw-r--r-- | test/prism/location_test.rb | 6 |
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 |
