Skip to content

Commit

Permalink
untyped versions for Symbol updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sampersand authored and soutaro committed Jul 25, 2024
1 parent 736268b commit bc628bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
8 changes: 3 additions & 5 deletions core/symbol.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Symbol
# Related: String#<=>.
#
def <=>: (Symbol object) -> (-1 | 0 | 1)
| (untyped) -> nil
| (untyped) -> (-1 | 0 | 1)?

# <!--
# rdoc-file=string.c
Expand Down Expand Up @@ -236,8 +236,7 @@ class Symbol
#
# Related: Symbol#casecmp?, String#casecmp.
#
def casecmp: (Symbol object) -> (-1 | 0 | 1)?
| (untyped) -> nil
def casecmp: (untyped object) -> (-1 | 0 | 1)?

# <!--
# rdoc-file=string.c
Expand Down Expand Up @@ -270,8 +269,7 @@ class Symbol
#
# Related: Symbol#casecmp, String#casecmp?.
#
def casecmp?: (Symbol object) -> bool?
| (untyped) -> nil
def casecmp?: (untyped object) -> bool?

# <!--
# rdoc-file=string.c
Expand Down
18 changes: 6 additions & 12 deletions test/stdlib/Symbol_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ def test_op_cmp
:s, :<=>, other
end

with_untyped do |untyped|
next if Symbol === untyped

assert_send_type '(untyped) -> nil',
with_untyped.and :sym do |untyped|
assert_send_type '(untyped) -> Integer?',
:a, :<=>, untyped
end
end
Expand Down Expand Up @@ -127,10 +125,8 @@ def test_casecmp
assert_send_type '(Symbol) -> nil',
"\u{e4 f6 fc}".encode('ISO-8859-1').to_sym, :casecmp, :"\u{c4 d6 dc}"

with_untyped do |other|
next if Symbol === other

assert_send_type '(untyped) -> nil',
with_untyped.and :sym do |other|
assert_send_type '(untyped) -> (-1 | 0 | 1)?',
:a, :casecmp, other
end
end
Expand All @@ -145,10 +141,8 @@ def test_casecmp?
assert_send_type '(Symbol) -> nil',
'\u{e4 f6 fc}'.encode('ISO-8859-1').to_sym, :casecmp?, :'\u{c4 d6 dc}'

with_untyped do |other|
next if Symbol === other

assert_send_type '(untyped) -> nil',
with_untyped.and :sym do |other|
assert_send_type '(untyped) -> bool?',
:a, :casecmp?, other
end
end
Expand Down

0 comments on commit bc628bd

Please sign in to comment.