summaryrefslogtreecommitdiff
path: root/test/ruby/test_enum.rb
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2024-07-11 11:46:23 +0900
committerYusuke Endoh <[email protected]>2024-07-11 12:28:23 +0900
commite1238a1faba5cbb7975d08963bf0bfa50a96d2b0 (patch)
treea8a3c6bb29397840c339226e74838b183a18f582 /test/ruby/test_enum.rb
parent724d95a713f47ff7a6f1907b63cd02710824ba76 (diff)
Enumerable#all?: Stop optimizing when a given block is not optimizable
This is a follow up to 182822683f86c8f8d63b05765addf5a04d112aa2. Co-Authored-By: Aaron Patterson <[email protected]>
Diffstat (limited to 'test/ruby/test_enum.rb')
-rw-r--r--test/ruby/test_enum.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 7503e06272..237bdc8a4d 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -1348,4 +1348,12 @@ class TestEnumerable < Test::Unit::TestCase
klass.new.grep(/(b.)/) { svars << $1 }
assert_equal(["ba", "ba"], svars)
end
+
+ def test_all_fast
+ data = { "key" => { "key2" => 1 } }
+ kk = vv = nil
+ data.all? { |(k, v)| kk, vv = k, v }
+ assert_equal(kk, "key")
+ assert_equal(vv, { "key2" => 1 })
+ end
end