summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-13 23:33:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-15 01:09:07 +0900
commit9cb33aad55e0a2cded3b09b0509b9c53fb0fa5ae (patch)
treedd7c0bc7780efe838d9fdb865fd087fb0068a36e /test/ruby
parent864bb8680cee48a2bed85703dc2e4070728362d4 (diff)
[Bug #19877] Fix flip-flop in block
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8440
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_parse.rb15
1 files changed, 15 insertions, 0 deletions
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 = []