Skip to content

Commit

Permalink
Merge pull request #1672 from ParadoxV5/string
Browse files Browse the repository at this point in the history
A tiny followup for #1641’s oopsies
  • Loading branch information
soutaro authored Dec 13, 2023
2 parents bcf179c + e3bc39d commit 4eb84e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/string.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ class String
# modification made, `self` otherwise.
#
def chomp!: (nil) -> nil
# | (?string separator) -> self? # https://github.com/ruby/rbs/pull/1672#discussion_r1423324796
| (?string? separator) -> self?

# <!--
Expand Down Expand Up @@ -2741,7 +2742,7 @@ class String
# "\x81"
# "\x81"
#
def scrub: (?string replacement) -> String
def scrub: (?string? replacement) -> String
| (?nil) { (String bytes) -> string } -> String

# <!--
Expand Down
10 changes: 10 additions & 0 deletions test/stdlib/String_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,11 @@ def test_scrub
assert_send_type '() -> String',
invalid, :scrub

assert_send_type '(nil) -> String',
valid, :scrub, nil
assert_send_type '(nil) -> String',
invalid, :scrub, nil

with_string '&' do |replacement|
assert_send_type '(string) -> String',
valid, :scrub, replacement
Expand Down Expand Up @@ -1310,6 +1315,11 @@ def test_scrub!
assert_send_type '() -> String',
invalid.dup, :scrub!

assert_send_type '(nil) -> String',
valid.dup, :scrub!, nil
assert_send_type '(nil) -> String',
invalid.dup, :scrub!, nil

with_string '&' do |replacement|
assert_send_type '(string) -> String',
valid.dup, :scrub!, replacement
Expand Down

0 comments on commit 4eb84e2

Please sign in to comment.