-
-
Notifications
You must be signed in to change notification settings - Fork 401
Add and update specs for IO methods #1384
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
base: master
Are you sure you want to change the base?
Changes from all commits
4a7d459
976d046
6f9fba9
a8dd789
d91bdf7
40e859f
3a69b22
f0a3b5f
46f9838
538111f
950b6cc
09eb335
18069f9
e1b1972
c9449cb
5694592
7008f3b
0749bb7
40f33d2
b9fa9e5
5309d09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,22 @@ | |
| it "raises an IOError on closed stream" do | ||
| -> { IOSpecs.closed_io.getbyte }.should.raise(IOError) | ||
| end | ||
|
|
||
| it "reads after ungetc without character conversion" do | ||
| @io.set_encoding("utf-8") | ||
| c = @io.getc | ||
| @io.ungetc(c) | ||
| @io.getbyte.should == 86 | ||
| end | ||
|
|
||
| it "raises an exception after ungetc with character conversion" do | ||
| @io.set_encoding("utf-8:utf-16be") | ||
| c = @io.getc | ||
| @io.ungetc(c) | ||
| -> do | ||
| @io.getbyte | ||
| end.should.raise(IOError, "byte oriented read for character buffered IO") | ||
| end | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: this appears to be a CRuby-specific implementation detail (or an intentional design constraint) that other Ruby implementations, such as JRuby, TruffleRuby, or Natalie, might handle differently (e.g., by CRuby already allows mixing byte-oriented and character-oriented read operations on streams with multibyte encodings (such as UTF-16BE). Semantically, calling
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that this project documents the behavior of CRuby, and this is indeed a CRuby behavior. I've not tried it on other implementations. Is that a requirement now?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not exactly, as the README says:
Which notably means avoiding to add specs for things that are bugs in CRuby (and instead report the bug/inconsistency), ask clarification on the CRuby bug tracker for unclear cases and otherwise yes mostly assume CRuby behavior is intended if it looks reasonable. I think this is a case of "unclear, should ask clarification on the CRuby bug tracker". I think for now it's better to not add these specs in ruby/spec, because the effect would be probably unclear semantics and extra overhead for other Ruby implementations, when that behavior might be undesirable anyway (could probably be even seen as a bug by someone trying to do legitimately).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Playing a bit in IRB with this and yeah it's weird, I could maybe understand if byte operations are not allowed with UTF-16/32 (which are the only encodings with min-length > 1 byte), although that would be inconsistent with String which doesn't mind.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah BTW there was already 1 spec about this (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will open tickets as requested, but I've had mixed results getting attention on some of them. This ticket is one such which is being ignored. Is there something else I should do to avoid these new tickets also being ignored? |
||
| end | ||
|
|
||
| describe "IO#getbyte" do | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.