aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hash.c9
-rw-r--r--spec/ruby/core/hash/constructor_spec.rb4
-rw-r--r--test/ruby/test_hash.rb11
3 files changed, 7 insertions, 17 deletions
diff --git a/hash.c b/hash.c
index b4b0415c84..2982afad9d 100644
--- a/hash.c
+++ b/hash.c
@@ -1656,17 +1656,8 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
VALUE key, val = Qnil;
if (NIL_P(v)) {
-#if 0 /* refix in the next release */
rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)",
rb_builtin_class_name(e), i);
-
-#else
- rb_warn("wrong element type %s at %ld (expected array)",
- rb_builtin_class_name(e), i);
- rb_warn("ignoring wrong elements is deprecated, remove them explicitly");
- rb_warn("this causes ArgumentError in the next release");
- continue;
-#endif
}
switch (RARRAY_LEN(v)) {
default:
diff --git a/spec/ruby/core/hash/constructor_spec.rb b/spec/ruby/core/hash/constructor_spec.rb
index 55681c2a7c..4e02a955bd 100644
--- a/spec/ruby/core/hash/constructor_spec.rb
+++ b/spec/ruby/core/hash/constructor_spec.rb
@@ -45,10 +45,10 @@ describe "Hash.[]" do
it "ignores elements that are not arrays" do
-> {
Hash[[:a]].should == {}
- }.should complain(/ignoring wrong elements/)
+ }.should raise_error(ArgumentError)
-> {
Hash[[:nil]].should == {}
- }.should complain(/ignoring wrong elements/)
+ }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for arrays of more than 2 elements" do
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])