From 296da1a2b8fdcd8d420ced94ab553b7d3fa517d9 Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Mon, 23 Oct 2023 12:30:38 -0300 Subject: =?UTF-8?q?[PRISM]=20Add=20tests=20for=20BlockNode,=20BlockLocalVa?= =?UTF-8?q?riableNode,=20BlockParamet=E2=80=A6=20(#8725)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [PRISM] Add tests for BlockNode, BlockLocalVariableNode, BlockParametersNode --- test/ruby/test_compile_prism.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/ruby') 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 -- cgit v1.2.3