diff options
| author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-10-23 12:30:38 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-23 12:30:38 -0300 |
| commit | 296da1a2b8fdcd8d420ced94ab553b7d3fa517d9 (patch) | |
| tree | 1d12b035570807c1f84d830dfb9bcc5f8f4c4058 /test/ruby | |
| parent | f20e91fbf70a28b54bf4bf0f8bb5783572f8dd70 (diff) | |
[PRISM] Add tests for BlockNode, BlockLocalVariableNode, BlockParamet… (#8725)
[PRISM] Add tests for BlockNode, BlockLocalVariableNode, BlockParametersNode
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 26aeecb166..d1bb1ddbf7 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -487,6 +487,12 @@ module Prism # Scopes/statements # ############################################################################ + def test_BlockNode + test_prism_eval("[1, 2, 3].each { |num| num }") + + test_prism_eval("[].tap { _1 }") + end + def test_ClassNode test_prism_eval("class PrismClassA; end") test_prism_eval("class PrismClassA; end; class PrismClassB < PrismClassA; end") @@ -550,6 +556,23 @@ module Prism test_prism_eval("1.then(&:to_s)") end + def test_BlockLocalVariableNode + test_prism_eval(<<-CODE + pm_var = "outer scope variable" + + 1.times { |;pm_var| pm_var = "inner scope variable"; pm_var } + CODE + ) + + test_prism_eval(<<-CODE + pm_var = "outer scope variable" + + 1.times { |;pm_var| pm_var = "inner scope variable"; pm_var } + pm_var + CODE + ) + end + def test_CallNode test_prism_eval("to_s") end @@ -570,6 +593,12 @@ module Prism test_prism_eval("alias :prism_a :to_s") end + def test_BlockParametersNode + test_prism_eval("Object.tap { || }") + test_prism_eval("[1].map { |num| num }") + test_prism_eval("[1].map { |a; b| b = 2; a + b}") + end + def test_OptionalParameterNode test_prism_eval("def prism_test_optional_param_node(bar = nil); end") end |
