Skip to content
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
8 changes: 7 additions & 1 deletion core/src/main/java/org/jruby/ext/set/RubySet.java
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
return context.runtime.getFalse();
}

@JRubyMethod(name = "reset")
public IRubyObject reset(ThreadContext context) {
this.hash.rehash();
return this;
}

@JRubyMethod(name = "eql?")
public IRubyObject op_eql(ThreadContext context, IRubyObject other) {
if ( other instanceof RubySet ) {
Expand Down Expand Up @@ -1261,4 +1267,4 @@ final IRubyObject toRuby(Object obj) {
return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), obj);
}

}
}
13 changes: 13 additions & 0 deletions test/mri/test_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,19 @@ def test_compare_by_identity
assert_equal(3, set.size)
assert_equal(array.uniq.sort, set.sort)
end

def test_reset
[Set, Class.new(Set)].each { |klass|
a = [1, 2]
b = [1]
set = klass.new([a, b])

b << 2
set.reset

assert_equal(klass.new([a]), set, klass.name)
}
end
end

class TC_SortedSet < Test::Unit::TestCase
Expand Down