rbs
rbs copied to clipboard
Update IO instance methods
Phew! This one took awhile :-P. This PR updates IO's instance methods.
More specifically, this makes the following general changes:
- Deprecates
::_ReaderPartial(renamed toIO::_Readpartial) and::_Rewindable(now unused) - Deprecates
String::_EncodeFallbackAref(moved within toEncoding, as it's used for encoding purposes). - Fixes a minor bug in
lib/rbs/unit_test/spy.rbwhere.new()is called instead of.allocate(). This prevents testing instance methods named:initialize. - Removed
test/stdlib/test_helper.rb:ArefFromStringToString, as it's no longer needed - Added in
TestHelper::RUBY_EXE, used when spawning shells (IOneeds it forIO#pid) - Added
test/stdlib/util/small-file.txtas a small file that can be read from fro testing - Redid all the tests in
IO_test.rbto accomodate thewith_xxxforms. However,wait_writableandwait_prioroitycurrently 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:
- The
%a{ruby:since:3.2.0}annotation has been added to methods introduced in ruby 3.2.0 - Moved all of
IO's constant definitions inside of it - Removed constant definitions that
IOinherits fromFile::Constants(APPEND,FNM_CASEFOLD,LOCK_SH, etc.) - Added
IO::EWOULDBLOCKWait{Readable,Writable}constants IO#initialize:modeis nowopen_mode; updated all the options to be the entire list of accepted options (along with the**untypedthat it for some reason accepts)IO#advise: AddedIO::advicetype alias,offsetandlenare nowint?IO#{lineno,autoclose,sync}=: Now returns their argumentsIO#each: Now its own function;each_linealiases it. Also added in the limit-only variant.IO#each_{byte,char,codepoint}: Reordered branches to haveEnumeratorfirstIO#external_encoding: Added in. (weird that it didnt exist, sinceinternal_encodingexisted before...)IO#{fcntl,ioctl}: Now uses implicits,argumentalso acceptsbool | nilas well.IO#{f{data,}sync,rewind}: Always returns0IO#pid: Can now returnnilIO#pos=: Now takesintIO#p{read,write}: Added inIO#{print,puts}: objects are now_ToSnotuntypedIO#printf: format string is nowstringIO#putc: Separated cases out so return values aren't unionedIO#{gets,read}: reordered branches slightlyIO#readline{,s}: Added in limit-only variantIO#readpartial:outbufis now nilableIO#reopen: Changed(IO) -> IOto be(io) -> sef; added in optional keywords to second caseIO#seek:amountis nownil; also added inIO::whencetype alias.IO#set_encoding: Added in optional encoding argumentsIO#sysread: added implicit conversions;outbufis optional and nilable.IO#sysseek: ADded implicitintforamount; usesIO::whence.IO#timeout=: Now returnsselfnotvoid(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 implicitstringand is nilable.IO#ungetc: Argument can now beInteger.IO#write_nonblock: Can no longer returnnilnow
Since Ruby 3.2 moved the wait_* methods into io directly (no need for require 'io/wait'), the methods IO#wait{,_{readable,writable,priority}} have been moved from io/wait.rbs, along with IO::wait_mode and marked as `%a{ruby:since:3.2.0}.
- The
%a{ruby:since:3.2.0}annotation has been added to methods introduced in ruby 3.2.0
We have Ruby 3.3 now (:
- #1674