diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-05-23 00:15:55 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-05-23 00:19:56 +0900 |
commit | d3f1c615c5b81319e422e9c92e1cb8ba82209fba (patch) | |
tree | 66cf55c8efbc4c606d50d186b6d5f990ff928a88 /test/ruby/test_hash.rb | |
parent | 4d62296948c36615e73b99d592253256d0ea0d4a (diff) | |
download | ruby-d3f1c615c5b81319e422e9c92e1cb8ba82209fba.tar.gz |
hash.c (rb_hash_s_create): Reject `Hash[[nil]]`
The behavior of `Hash[[nil]] #=> {}` was a bug until 1.9.3, but had been
remained with a warning because some programs depended upon it.
Now, six years passed. We can remove the compatibility behavior.
[Bug #7300]
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c934d1015e..243cad8d43 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -149,10 +149,9 @@ class TestHash < Test::Unit::TestCase assert_equal(nil, h['b']) assert_equal(300, h['c']) - h = @cls[[["a", 100], "b", ["c", 300]]] - assert_equal(100, h['a']) - assert_equal(nil, h['b']) - assert_equal(300, h['c']) + assert_raise(ArgumentError) do + @cls[[["a", 100], "b", ["c", 300]]] + end end def test_s_AREF_duplicated_key @@ -944,8 +943,8 @@ class TestHash < Test::Unit::TestCase def test_create assert_equal({1=>2, 3=>4}, @cls[[[1,2],[3,4]]]) - assert_raise(ArgumentError) { Hash[0, 1, 2] } - assert_warning(/wrong element type Integer at 1 /) {@cls[[[1, 2], 3]]} + assert_raise(ArgumentError) { @cls[0, 1, 2] } + assert_raise(ArgumentError) { @cls[[[0, 1], 2]] } bug5406 = '[ruby-core:39945]' assert_raise(ArgumentError, bug5406) { @cls[[[1, 2], [3, 4, 5]]] } assert_equal({1=>2, 3=>4}, @cls[1,2,3,4]) |