Skip to content

Commit

Permalink
Alias Set#=== to #include?
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Jan 8, 2018
1 parent 6df79ee commit fef7d0b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ext/set/RubySet.java
Expand Up @@ -466,7 +466,7 @@ public IRubyObject flatten_bang(final ThreadContext context) {
/**
* Returns true if the set contains the given object.
*/
@JRubyMethod(name = "include?", alias = { "member?" })
@JRubyMethod(name = "include?", alias = { "member?", "===" })
public RubyBoolean include_p(final ThreadContext context, IRubyObject obj) {
return context.runtime.newBoolean( containsImpl(obj) );
}
Expand Down Expand Up @@ -1261,4 +1261,4 @@ final IRubyObject toRuby(Object obj) {
return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), obj);
}

}
}
7 changes: 7 additions & 0 deletions spec/ruby/core/set/case_equality_spec.rb
@@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/include', __FILE__)
require 'set'

describe "Set#===" do
it_behaves_like :set_include, :===
end
7 changes: 7 additions & 0 deletions spec/ruby/core/set/sortedset/case_equality_spec.rb
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../shared/include', __FILE__)
require 'set'

describe "SortedSet#===" do
it_behaves_like :sorted_set_include, :===
end
17 changes: 17 additions & 0 deletions test/mri/test_set.rb
Expand Up @@ -200,6 +200,23 @@ def test_include?
assert_equal(false, set.include?(true))
end

def test_eqq
set = Set[1,2,3]

assert_equal(true, set === 1)
assert_equal(true, set === 2)
assert_equal(true, set === 3)
assert_equal(false, set === 0)
assert_equal(false, set === nil)

set = Set["1",nil,"2",nil,"0","1",false]
assert_equal(true, set === nil)
assert_equal(true, set === false)
assert_equal(true, set === "1")
assert_equal(false, set === 0)
assert_equal(false, set === true)
end

def test_superset?
set = Set[1,2,3]

Expand Down

0 comments on commit fef7d0b

Please sign in to comment.