-
-
Notifications
You must be signed in to change notification settings - Fork 395
Add initial specs for IO::Buffer #1297
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
Open
trinistr
wants to merge
6
commits into
ruby:master
Choose a base branch
from
trinistr:add-io-buffer-spec
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or 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
e0188af to
4ce76f1
Compare
trinistr
commented
Nov 8, 2025
core/io/buffer/initialize_spec.rb
Outdated
Comment on lines
75
to
82
| # This looks like a bug to me, these should be different memory models? | ||
| # Definitely looks like a bug, created issue: https://bugs.ruby-lang.org/issues/21672 | ||
| it "creates internal-mapped buffer if INTERNAL and MAPPED are both specified" do | ||
| @buffer = IO::Buffer.new(10, IO::Buffer::INTERNAL | IO::Buffer::MAPPED) | ||
| @buffer.should.internal? | ||
| @buffer.should.mapped? | ||
| @buffer.should_not.empty? | ||
| end |
Contributor
Author
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.
This is very clearly a bug, so I filed it as such. Not sure if the test needs to be here. Probably not? This does not seem like behavior that should be replicated. I will delete it for now.
4ce76f1 to
0e6e4e6
Compare
0e6e4e6 to
8d1ae07
Compare
c307df9 to
840258b
Compare
840258b to
e6fcb41
Compare
e6fcb41 to
d80c785
Compare
d80c785 to
001bdd5
Compare
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.
This class currently has no specs at all. This PR adds specs for the following methods:
.new,#free,#resize,#transfer,.map,.for,.stringsand some instance methods.Special remarks:
#valid?is somewhat incomplete, as garbage-collecting a string is non-trivial (I don't know how to);#resizedoes not have tests for slices as currently it seems to be an undefined behavior, and it's not clear if it should be reproduced (yes, ruby/spec is all about reproducing even weird behavior, but bugs are a gray area still).Weird things discovered so far so I don't forget:
.newallows any and all flags (https://bugs.ruby-lang.org/issues/21672)..map, for example, has very early text).INTERNALandEXTERNALare unclear, not being opposites (both can be false at the same time) and not even forming an exclusive tri-state withMAPPED.READONLY.#to_s(or call all predicate methods to check for all-false).#freeeven safe on a slice? (io_buffer_free seems to work fine only because no flags are copied, not actually checking "is this a slice?").#freeon the source buffer is not safe (https://bugs.ruby-lang.org/issues/21212).#lockeding does not propagate in either direction.#freeing a String-backed buffer does not invalidate its slice (shouldn't slices always become invalid without a source buffer?).SHAREDintended to be used manually or not?PRIVATEmapping neither INTERNAL or EXTERNAL?.forand.stringwith a block are supposed to nullify buffer at the end, but buffer can be#transferred outside, is this intentional? (this creates a run-away buffer, able to change the string from wherever (but not a frozen string, at least)).#resizeon a MAPPED buffer changes it to INTERNAL on macOS and Windows.