aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-31 08:39:20 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-31 12:11:45 +0900
commit20a8425aa0f9a947e72b06cbd3a2afe9674dd18f (patch)
treea6f86987877303b2ae99be64334265377f7fa453 /test
parentb2030d4dae3142e3fe6ad79ac1202de5a9f34a5a (diff)
downloadruby-20a8425aa0f9a947e72b06cbd3a2afe9674dd18f.tar.gz
Make any hash values fixable [Bug #17488]
As hnum is an unsigned st_index_t, the result of RSHIFT may not be in the fixable range. Co-authored-by: NeoCat <neocat@neocat.jp>
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index c4b93836c6..62d8b3f836 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1865,4 +1865,30 @@ class TestHash < Test::Unit::TestCase
{a: 1}.each(&->(k, v) {})
end
end
+
+ def test_any_hash_fixable
+ 20.times do
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ require "delegate"
+ typename = DelegateClass(String)
+
+ hash = {
+ "Int" => true,
+ "Float" => true,
+ "String" => true,
+ "Boolean" => true,
+ "WidgetFilter" => true,
+ "WidgetAggregation" => true,
+ "WidgetEdge" => true,
+ "WidgetSortOrder" => true,
+ "WidgetGrouping" => true,
+ }
+
+ hash.each_key do |key|
+ assert_send([hash, :key?, typename.new(key)])
+ end
+ end;
+ end
+ end
end