ruby-changes:66732
From: Nobuyoshi <ko1@a...>
Date: Thu, 8 Jul 2021 16:48:19 +0900 (JST)
Subject: [ruby-changes:66732] 7a2383b5c1 (master): Split test of Hash.[] and add assertion for default value/proc
https://git.ruby-lang.org/ruby.git/commit/?id=7a2383b5c1 From 7a2383b5c16208dde00de9414001d03422770280 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 8 Jul 2021 16:45:33 +0900 Subject: Split test of Hash.[] and add assertion for default value/proc For a73f13c9070a5189947641638398cbffb8d012d8. --- test/ruby/test_hash.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 23df241..7c83d03 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -142,7 +142,7 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L142 end end - def test_s_AREF + def test_s_AREF_from_hash h = @cls["a" => 100, "b" => 200] assert_equal(100, h['a']) assert_equal(200, h['b']) @@ -153,11 +153,21 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L153 assert_equal(200, h['b']) assert_nil(h['c']) + h = @cls[Hash.new(42)] + assert_nil(h['a']) + + h = @cls[Hash.new {42}] + assert_nil(h['a']) + end + + def test_s_AREF_from_list h = @cls["a", 100, "b", 200] assert_equal(100, h['a']) assert_equal(200, h['b']) assert_nil(h['c']) + end + def test_s_AREF_from_pairs h = @cls[[["a", 100], ["b", 200]]] assert_equal(100, h['a']) assert_equal(200, h['b']) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/