-
Notifications
You must be signed in to change notification settings - Fork 215
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
Update IO instance methods #1692
base: master
Are you sure you want to change the base?
Conversation
cbadb6e
to
ccfc69f
Compare
@@ -28,6 +28,13 @@ | |||
# useful when you use other ASCII-compatible encodings. | |||
# | |||
class Encoding | |||
# The `_EncodeFallbackAref` is used in functions such as `String::encode` to get the fallback | |||
# value when a charcater can't be converted between encodings. | |||
interface _EncodeFallbackAref |
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 was moved from String
to here
@@ -128,7 +128,7 @@ def wrapped_object | |||
end | |||
end.ruby2_keywords | |||
) | |||
end.new() | |||
end.allocate() |
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 needed because .new
implicitly calls .initialize
; if method_name
is :initialize
, then this will accidentally call it with no arguments. Doing it this way prevents that (and since the parent object is BasicObject
, :initialize
is a no-op anyways)
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.
BTW, why not MiniTest::Mock
?
e75df24
to
e328d88
Compare
e328d88
to
32d4f5b
Compare
45d4635
to
3284d3b
Compare
872d831
to
7fba7c8
Compare
7fba7c8
to
cd13207
Compare
We have Ruby 3.3 now (: |
Co-authored-by: ParadoxV5 <paradox.ver5@gmail.com>
Phew! This one took awhile :-P. This PR updates
IO
's instance methods.More specifically, this makes the following general changes:
::_ReaderPartial
(renamed toIO::_Readpartial
) and::_Rewindable
(now unused)String::_EncodeFallbackAref
(moved within toEncoding
, as it's used for encoding purposes).lib/rbs/unit_test/spy.rb
where.new()
is called instead of.allocate()
. This prevents testing instance methods named:initialize
.test/stdlib/test_helper.rb:ArefFromStringToString
, as it's no longer neededTestHelper::RUBY_EXE
, used when spawning shells (IO
needs it forIO#pid
)test/stdlib/util/small-file.txt
as a small file that can be read from fro testingIO_test.rb
to accomodate thewith_xxx
forms. However,wait_writable
andwait_prioroity
currently don't have any tests associated with them, as I couldn't figure out a good way to test them. (However, their signatures are pretty simple)It also makes the following changes to
io.rbs
:%a{ruby:since:3.2.0}
annotation has been added to methods introduced in ruby 3.2.0IO
's constant definitions inside of itIO
inherits fromFile::Constants
(APPEND
,FNM_CASEFOLD
,LOCK_SH
, etc.)IO::EWOULDBLOCKWait{Readable,Writable}
constantsIO#initialize
:mode
is nowopen_mode
; updated all the options to be the entire list of accepted options (along with the**untyped
that it for some reason accepts)IO#advise
: AddedIO::advice
type alias,offset
andlen
are nowint?
IO#{lineno,autoclose,sync}=
: Now returns their argumentsIO#each
: Now its own function;each_line
aliases it. Also added in the limit-only variant.IO#each_{byte,char,codepoint}
: Reordered branches to haveEnumerator
firstIO#external_encoding
: Added in. (weird that it didnt exist, sinceinternal_encoding
existed before...)IO#{fcntl,ioctl}
: Now uses implicits,argument
also acceptsbool | nil
as well.IO#{f{data,}sync,rewind}
: Always returns0
IO#pid
: Can now returnnil
IO#pos=
: Now takesint
IO#p{read,write}
: Added inIO#{print,puts}
: objects are now_ToS
notuntyped
IO#printf
: format string is nowstring
IO#putc
: Separated cases out so return values aren't unionedIO#{gets,read}
: reordered branches slightlyIO#readline{,s}
: Added in limit-only variantIO#readpartial
:outbuf
is now nilableIO#reopen
: Changed(IO) -> IO
to be(io) -> sef
; added in optional keywords to second caseIO#seek
:amount
is nownil
; also added inIO::whence
type alias.IO#set_encoding
: Added in optional encoding argumentsIO#sysread
: added implicit conversions;outbuf
is optional and nilable.IO#sysseek
: ADded implicitint
foramount
; usesIO::whence
.IO#timeout=
: Now returnsself
notvoid
(which is weird, since almost every other setter in ruby returns its argument...)IO#to_io
: Now marked%a{pure}
IO#to_path
: Added inIO#ungetbyte
: Argument accepts implicitstring
and is nilable.IO#ungetc
: Argument can now beInteger
.IO#write_nonblock
: Can no longer returnnil
nowSince Ruby 3.2 moved the
wait_*
methods intoio
directly (no need forrequire 'io/wait'
), the methodsIO#wait{,_{readable,writable,priority}}
have been moved fromio/wait.rbs
, along withIO::wait_mode
and marked as `%a{ruby:since:3.2.0}.