-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias #string to #to_s/#to_str #103
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sebyx07
commented
Aug 22, 2024
|
@nobu - but |
nobu
reviewed
Sep 4, 2024
Comment on lines
+1035
to
+1060
def test_to_s_with_interpolation | ||
content = "Hello, StringIO!" | ||
stringio = StringIO.new(content) | ||
|
||
assert_equal "Content: #{content}", "Content: #{stringio}" | ||
|
||
assert_equal "Before #{content} After", "Before #{stringio} After" | ||
|
||
empty_stringio = StringIO.new | ||
assert_equal "Empty: ", "Empty: #{empty_stringio}" | ||
|
||
utf16_content = content.encode("UTF-16LE") | ||
stringio_with_encoding = StringIO.new(utf16_content) | ||
assert_equal "UTF-16LE: #{utf16_content.encode('UTF-8')}", "UTF-16LE: #{stringio_with_encoding.to_s.encode('UTF-8')}" | ||
|
||
assert_equal "UTF-16LE", stringio_with_encoding.to_s.encoding.name | ||
|
||
stringio.pos = 7 | ||
assert_equal "Moved: #{content}", "Moved: #{stringio}" | ||
|
||
stringio.close | ||
assert_equal "Closed: #{content}", "Closed: #{stringio}" | ||
|
||
assert_equal "Start #{content} Middle #{empty_stringio} End", "Start #{stringio} Middle #{empty_stringio} End" | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interpolation is not a feature of StringIO
.
This does not make sense here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix GH-102
imo, a lot of users would rather call
buffer.to_s
instead of the .string method, nobody atm depends on the.to_s
. There already is .inspect that behaves like the current to_sbonus, having
.to_s
, now you can interpolate string io into strings w/o calling .to_s