From 9cb33aad55e0a2cded3b09b0509b9c53fb0fa5ae Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 13 Sep 2023 23:33:19 +0900 Subject: [Bug #19877] Fix flip-flop in block --- test/ruby/test_parse.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 0f71e11f7e..2f1a522dc2 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -465,6 +465,21 @@ class TestParse < Test::Unit::TestCase assert_parse_error(%q[def (:"#{42}").foo; end], msg) end + def test_flip_flop + [ + '((cond1..cond2))', + '(; cond1..cond2)', + '(1; cond1..cond2)', + '(%s(); cond1..cond2)', + '(%w(); cond1..cond2)', + '(1; (2; (3; 4; cond1..cond2)))', + '(1+1; cond1..cond2)', + ].each do |code| + code = code.sub("cond1", "n==4").sub("cond2", "n==5") + assert_equal([4,5], eval("(1..9).select {|n| true if #{code}}")) + end + end + def test_op_asgn1_with_block t = Object.new a = [] -- cgit v1.2.3