Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2577528b7554
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8a5fcf0d8102
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 23, 2015

  1. Copy the full SHA
    1a4b466 View commit details
  2. Copy the full SHA
    8a5fcf0 View commit details
Showing with 17 additions and 11 deletions.
  1. +6 −5 core/src/main/java/org/jruby/RubyHash.java
  2. +0 −1 test/mri/excludes/TestHash.rb
  3. +11 −5 test/mri/ruby/test_hash.rb
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -703,13 +703,15 @@ public IRubyObject default_value_get(ThreadContext context, IRubyObject[] args)
throw context.runtime.newArgumentError(args.length, 1);
}
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return getRuntime().getNil();
return context.nil;
}
return ifNone;
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
@@ -1533,16 +1535,15 @@ public IRubyObject shift(ThreadContext context) {

RubyHashEntry entry = head.nextAdded;
if (entry != head) {
RubyArray result = RubyArray.newArray(getRuntime(), entry.key, entry.value);
RubyArray result = RubyArray.newArray(context.runtime, entry.key, entry.value);
internalDeleteEntry(entry);
return result;
}

if ((flags & PROCDEFAULT_HASH_F) != 0) {
return Helpers.invoke(context, ifNone, "call", this, getRuntime().getNil());
} else {
return ifNone;
return this.callMethod(context, "default", context.nil);
}
return ifNone;
}

public final boolean fastDelete(IRubyObject key) {
1 change: 0 additions & 1 deletion test/mri/excludes/TestHash.rb
Original file line number Diff line number Diff line change
@@ -12,6 +12,5 @@
exclude :test_NEWHASH_fstring_key, "needs investigation"
exclude :test_recursive_hash_value_struct, "needs investigation"
exclude :test_reject, "needs investigation"
exclude :test_shift_none, "needs investigation"
exclude :test_AREF_fstring_key, "Depends on MRI-specific GC.stat key"
exclude :test_ASET_fstring_key, "due https://github.com/jruby/jruby/commit/f3f0091da7d98c5df285"
16 changes: 11 additions & 5 deletions test/mri/ruby/test_hash.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: us-ascii -*-
require 'test/unit'
require 'continuation'
require_relative 'envutil'
EnvUtil.suppress_warning {require 'continuation'}

class TestHash < Test::Unit::TestCase

@@ -1265,8 +1265,14 @@ def eql?(other)
end
end

hash = {5 => bug9381}
assert_equal(bug9381, hash[wrapper.new(5)])
bad = [
5, true, false, nil,
0.0, 1.72723e-77,
].select do |x|
hash = {x => bug9381}
hash[wrapper.new(x)] != bug9381
end
assert_empty(bad, bug9381)
end

def test_label_syntax
@@ -1275,9 +1281,9 @@ def test_label_syntax
feature4935 = '[ruby-core:37553] [Feature #4935]'
x = 'world'
hash = assert_nothing_raised(SyntaxError) do
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4}))
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4, 'bar': {}}))
end
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4}, hash)
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4, :bar => {}}, hash)
end

class TestSubHash < TestHash