Skip to content

Commit

Permalink
Merge pull request #1110 from ruby/set
Browse files Browse the repository at this point in the history
Fix set type
  • Loading branch information
soutaro committed Sep 18, 2022
2 parents 7ab3cc8 + ebcfeb4 commit 082b420
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stdlib/set/0/set.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ class Set[unchecked out A]
#
def reject!: () { (A) -> untyped } -> self

# <!--
# rdoc-file=lib/set.rb
# - compare_by_identity()
# -->
# Makes the set compare its elements by their identity and returns
# self. This method may not be supported by all subclasses of Set.
#
def compare_by_identity: () -> self

# <!--
# rdoc-file=lib/set.rb
# - disjoint?(set)
Expand Down Expand Up @@ -467,6 +476,7 @@ class Set[unchecked out A]
# given.
#
def each: () { (A) -> void } -> self
| () -> Enumerator[A, self]

# <!--
# rdoc-file=lib/set.rb
Expand Down
29 changes: 29 additions & 0 deletions test/stdlib/set/Set_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative "../test_helper"

require "set"

class SetTest < Test::Unit::TestCase
include TypeAssertions

library "set"
testing "::Set[::Integer]"

def test_each
assert_send_type(
"() -> ::Enumerator[::Integer, ::Set[::Integer]]",
Set[1], :each
)

assert_send_type(
"() { (::Integer) -> ::Integer } -> ::Set[::Integer]",
Set[1], :each
) do |x| x+1 end
end

def test_compare_by_identity
assert_send_type(
"() -> ::Set[::Integer]",
Set[1], :compare_by_identity
)
end
end

0 comments on commit 082b420

Please sign in to comment.