You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(The sources show though that the same behavior should observable with the current master)
Expected Behavior
The Javadoc of java.util.Map.put() defines this:
Returns:
the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
Therefore I would expect these 2 tests to pass:
@Testpublicvoidtest1() {
Rubyruby = Ruby.newInstance();
IRubyObjecthash = ruby.evalScriptlet("{ \"Jane Doe\" => 10, \"Jim Doe\" => 6 }");
assertThat(hash, instanceOf(RubyHash.class));
RubyHashrubyHash = (RubyHash) hash;
// Should return previous value 10, but returns the new value 42assertThat(rubyHash.put("Jane Doe", 42), is((Object) 10));
}
@Testpublicvoidtest2() {
Rubyruby = Ruby.newInstance();
IRubyObjecthash = ruby.evalScriptlet("{ \"Jane Doe\" => 10, \"Jim Doe\" => 6 }");
assertThat(hash, instanceOf(RubyHash.class));
RubyHashrubyHash = (RubyHash) hash;
// Should return null because the key wasn't present before, but returns the new value 42assertThat(rubyHash.put("Robert Panzer", 42), nullValue());
}
Actual Behavior
The tests fail, because RubyHash.put() returns the value passed to this call:
Environment
JRuby 9.1.13.0
OS X
(The sources show though that the same behavior should observable with the current master)
Expected Behavior
The Javadoc of
java.util.Map.put()
defines this:Therefore I would expect these 2 tests to pass:
Actual Behavior
The tests fail, because
RubyHash.put()
returns the value passed to this call:jruby/core/src/main/java/org/jruby/RubyHash.java
Lines 2127 to 2131 in 7bd10a6
The text was updated successfully, but these errors were encountered: