Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RubyHash to pass #test_create #4947

Merged
merged 3 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,20 @@ public static IRubyObject create(ThreadContext context, IRubyObject recv, IRubyO
hash = (RubyHash)klass.allocate();
RubyArray arr = (RubyArray)tmp;
for(int i = 0, j = arr.getLength(); i<j; i++) {
IRubyObject v = TypeConverter.convertToTypeWithCheck(arr.entry(i), runtime.getArray(), "to_ary");
IRubyObject e = arr.entry(i);
IRubyObject v = TypeConverter.convertToTypeWithCheck(e, runtime.getArray(), "to_ary");
IRubyObject key;
IRubyObject val = runtime.getNil();
if(v.isNil()) {
runtime.getWarnings().warn("wrong element type " + e.getMetaClass() + " at " + i + " (expected array)");
runtime.getWarnings().warn("ignoring wrong elements is deprecated, remove them explicitly");
runtime.getWarnings().warn("this causes ArgumentError in the next release");
continue;
}
switch(((RubyArray)v).getLength()) {
case 2:
default:
throw runtime.newArgumentError("invalid number of elements (" + ((RubyArray)v).getLength() + " for 1..2)");
case 2:
val = ((RubyArray)v).entry(1);
case 1:
key = ((RubyArray)v).entry(0);
Expand Down
1 change: 0 additions & 1 deletion test/mri/excludes/TestHash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
exclude :test_callcc_escape, "needs investigation"
exclude :test_callcc_iter_level, "needs investigation"
exclude :test_callcc_reenter, "needs investigation"
exclude :test_create, "needs investigation"
exclude :test_eql, "needs investigation"
exclude :test_exception_in_rehash, "needs investigation"
exclude :test_fetch_error, "needs investigation"
Expand Down