Repository navigation
Closed
Labels
Description
We should aim to write specs for all new features, as usually the coverage is rather limited and it would greatly help other implementations to get the behavior right and faster.
From https://github.com/ruby/ruby/blob/v2_3_0/NEWS:
Only relevant items are kept for brevity.
Changes since the 2.2.0 release
Language changes
- frozen-string-literal pragma:
- 8a76900 new pragma, frozen-string-literal has been experimentally introduced.
Feature #8976 - b9c349e besides, --enable/--disable=frozen-string-literal options also have
been introduced. Feature #8976 - a0e55db command line options --debug or --debug=frozen-string-literal enable
additional debugging mode which shows created location with at frozen
object error (RuntimeError).
Feature #11725
- 8a76900 new pragma, frozen-string-literal has been experimentally introduced.
- safe navigation operator:
- Add specs for a safe navigator. #274 new method call syntax,
object&.foo, method #foo is called on
objectif it is not nil.
this is similar totry!in Active Support, except:- method name is syntactically required
obj.try! {}# valid
obj&. {}# syntax error - arguments are evaluated only if a call is made:
obj.try!(:foo, bar()) # bar() is always evaluated
obj&.foo(bar()) # bar() is conditionally evaluated - attribute assignment is valid
obj&.attr += 1
Feature #11537
- method name is syntactically required
- Add specs for a safe navigator. #274 new method call syntax,
- the
did_you_meangem:- DidYouMean specs for ruby 2.3 #351 When a NameError or NoMethodError occurs because of a typo in the name,
the did_you_mean gem automatically suggests other names similar to the
method name."Yuki".starts_with?("Y") # => NoMethodError: undefined method `starts_with?' for "Yuki":String # Did you mean? start_with?
- DidYouMean specs for ruby 2.3 #351 When a NameError or NoMethodError occurs because of a typo in the name,
- indented here document:
- 57c69fc More specs for "squiggly" heredoc. #340 new string literal, here document starts with
<<~.
refer doc/syntax/literals.rdoc for more details.
Feature #9098
- 57c69fc More specs for "squiggly" heredoc. #340 new string literal, here document starts with
Core classes updates (outstanding ones only)
- ARGF
- 0938149 ARGF.read_nonblock supports
exception: falselike IO#read_nonblock.
Feature #11358
- 0938149 ARGF.read_nonblock supports
- Array
- Comparable
- f59a862 Comparable#== no longer rescues exceptions Feature #7688
- Enumerable
- 3543656 Enumerable#grep_v is added as inverse version of Enumerable#grep.
Feature #11049 - [ruby-2.3 core/enumerable] - Add specs for Enumerable#chunk_while #168 Enumerable#chunk_while Feature #10769
- 3543656 Enumerable#grep_v is added as inverse version of Enumerable#grep.
- Enumerator::Lazy
- 59b2043 Enumerator::Lazy#grep_v Feature #11773
- File
- 48060b6 File.mkfifo Feature #11536
- Add spec for File::TMPFILE #356 Add File::TMPFILE corresponding to O_TMPFILE
- Hash
- 66e5c08 Hash#fetch_values Feature #10017
- Ruby 2.3's #dig #161 Hash#dig Feature #11643
- [Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3 #160 Hash#<=, Hash#<, Hash#>=, Hash#> Feature #10984
- Write Hash#to_proc specs #159 Hash#to_proc Feature #11653
- IO
- Add spec for File::SHARE_DELETE #357 new mode flag File::SHARE_DELETE is available.
this flag means to permit deleting opened file on Windows, but currently
this affect only files opened as binary. Feature #11218 - 4cb0765 new option parameter
flagsis added.
this parameter is bitwise-ORed to oflags generated by normal mode argument.
Feature #11253
- Add spec for File::SHARE_DELETE #357 new mode flag File::SHARE_DELETE is available.
- Kernel
- ba17b3d Kernel#loop, when stopped by a StopIteration exception, returns
what the enumerator has returned instead of nil. Feature #11498
- ba17b3d Kernel#loop, when stopped by a StopIteration exception, returns
- Module
- 3e9505b Module#deprecate_constant Feature #11398
- NameError
- Add spec for NameError#name #177 Add spec for NameError#receiver #178 NameError#receiver is added to take the receiver object. Feature #10881
- Numeric
- 6e164b0 45c334e Numeric#positive? and Numeric#negative? are added, which return
true when the receiver is positive and negative respectively.
Feature #11151
- 6e164b0 45c334e Numeric#positive? and Numeric#negative? are added, which return
- Queue (Thread::Queue)
- 5885e2b Queue#close is added to notice a termination. Feature #10600
- String
- 9d7f072 0391aea String#+@ and String#-@ are added to get mutable/frozen strings.
Feature #11782 - 214cf9e String.new now accepts new option parameter
encoding.
Feature #11785
- 9d7f072 0391aea String#+@ and String#-@ are added to get mutable/frozen strings.
- Struct
- 065e422 Struct#dig Feature #11688
- Thread
- [ruby-2.3 core/thread] - Add specs for Thread#name and Thread#name= #165 Thread#name, Thread#name= are added to handle thread names Feature #11251
Core classes compatibility issues (excluding feature bug fixes)
- Array
- Add specs for Array#reject!, delete_if 2.3 change #273 Array#select!, Array#keep_if, Array#reject!, and Array#delete_if
no longer changes the receiver array instantly every time the
block is called. Feature #10714 - spec for "no longer try to call #to_ary method on elements beyond the given level." #307 Array#flatten and Array#flatten! no longer try to call #to_ary
method on elements beyond the given level. Bug #10748 - spec for "no longer try to call #to_ary method on elements beyond the given level." #307 Array#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. Feature #11801
- Add specs for Array#reject!, delete_if 2.3 change #273 Array#select!, Array#keep_if, Array#reject!, and Array#delete_if
- Enumerable
- 376c9ea 8b118fd Enumerable#chunk and Enumerable#slice_before no longer takes the
initial_state argument. Feature #10958
Use a local variable instead to maintain a state.
- 376c9ea 8b118fd Enumerable#chunk and Enumerable#slice_before no longer takes the
- File::Stat
- 67f285b On Windows File::Stat#ino always returned 0, but now returns
BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low. Feature #11216
- 67f285b On Windows File::Stat#ino always returned 0, but now returns
- Hash
- spec for "no longer try to call #to_ary method on elements beyond the given level." #307 Hash#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. Feature #11801
- spec for "no longer try to call #to_ary method on elements beyond the given level." #307 Hash#inspect doesn't raise error even if its content returns
- IO
- adfd6bd IO#close doesn't raise when the IO object is closed. Feature #10718
- 292f31f IO#each_codepoint raises an exception at incomplete character
before EOF when conversion takes place. Bug #11444
- Module
- e1ea963 Module#define_method and Object.define_singleton_method now
require method body, Proc, Method, or a block, and raise
ArgumentError if no block is given directly. Bug #11283
- e1ea963 Module#define_method and Object.define_singleton_method now
- pack/unpack (Array/String)
- Add specs for unpack options J and j #331 j and J directives for pointer width integer type. Feature #11215
Stdlib updates (not pure-Ruby changes as these just depend on existing features)
- OpenSSL
- (no specs) OpenSSL::SSL::SSLSocket#accept_nonblock and
OpenSSL::SSL::SSLSocket#connect_nonblock supportsexception: false.
- (no specs) OpenSSL::SSL::SSLSocket#accept_nonblock and
- Socket
- 600d305 Socket#connect_nonblock, Socket#accept_nonblock,
TCPServer#accept_nonblock, UNIXServer#accept_nonblock,
BasicSocket#recv_nonblock, BasicSocket#recvmsg_nonblock,
BasicSocket#sendmsg_nonblock all supportexception: falseto return
:wait_readable or :wait_writable symbols instead of raising
IO::WaitReadable or IO::WaitWritable exceptions
[Feature #10532] Feature #11229 - e000de6 BasicSocket#recv and BasicSocket#recv_nonblock allow an output
String buffer argument like IO#read and IO#read_nonblock to reduce
GC overhead Feature #11242
- 600d305 Socket#connect_nonblock, Socket#accept_nonblock,
- StringIO
- 2a0bcb8 In read-only mode, StringIO#set_encoding no longer sets the encoding
of its buffer string. Setting the encoding of the string directly
without StringIO#set_encoding may cause unpredictable behavior now.
Bug #11827
- 2a0bcb8 In read-only mode, StringIO#set_encoding no longer sets the encoding
Stdlib compatibility issues (not pure-Ruby changes as these just depend on existing features)
- lib/base64.rb
- Tests Base64#urlsafe_encode64 and Base64#urlsafe_decode64 #315 Base64.urlsafe_encode64: added a "padding" option to suppress
the padding character ("="). Feature #10740 - Tests Base64#urlsafe_encode64 and Base64#urlsafe_decode64 #315 Base64.urlsafe_decode64: now it accepts not only correctly-padded
input but also unpadded input. Feature #10740
- Tests Base64#urlsafe_encode64 and Base64#urlsafe_decode64 #315 Base64.urlsafe_encode64: added a "padding" option to suppress
- ext/coverage/coverage.c
- Started adding spec for coverage #217 Coverage.peek_result: new method to allow coverage to be captured without
stopping the coverage tool. Feature #10816
- Started adding spec for coverage #217 Coverage.peek_result: new method to allow coverage to be captured without
- Net::FTP
- 8126e53 Set Net::FTP.default_passive to false. #158 Connections are in passive mode per default now. The default mode can
be changed by Net::FTP.default_passive=. Feature #11612
- 8126e53 Set Net::FTP.default_passive to false. #158 Connections are in passive mode per default now. The default mode can
C API updates
- 1b4d6a2 rb_define_class_id_under() now raises a TypeError exception when the
class is already defined but its superclass does not match the given
superclass, as well as definitions in ruby level. - ed92645 rb_timespec_now() is added to fetch current datetime as struct timespec.
Feature #11558 - e976989 rb_time_timespec_new() is added to create a time object with epoch,
nanosecond, and UTC/localtime/time offset arguments. Feature #11558
Activity
Combine duplicated stack resources
Add specs for Array#reject!, delete_if 2.3 change
Add specs for Array#reject!, delete_if 2.3 change
Combine duplicated stack resources
eregon commentedon Oct 2, 2016
About Hacktoberfest: any PR with specs covering one of those points would greatly help Ruby implementations and help to specify Ruby's 2.3 behavior!
There are plenty of existing specs to take inspiration from.
Find me on
#rubyspecon Freenode or just create an issue or PR to discuss.Add spec for Net::FTP being passive by default from 2.3+
Improve spec description from changelog
IO#each_codepoint raises an exception at incomplete character before
Array pack with format J and j specs (#320)
tests squiggly heredoc
Add specs for unpack options J and j
iliabylich commentedon Oct 24, 2016
@eregon Working on adding specs for "squiggly heredoc" from opal/opal#1397. I guess all specs must be wrapped with
eval, right? Is it possible to exclude the whole file from the test suite by specifying required ruby version? I just feel that wrapping all those heredocs withevalmay look scary.Or can we extract all examples to a separate file and required it in a context of
ruby_version_is "2.3"?In #318
requirehappens directly in the test. Does moving to an outer context break anything?11 remaining items
Add spec for File::TMPFILE
Add spec for define_method and define_singleton_method requiring an e…
Add spec for File::TMPFILE
Add spec for File::SHARE_DELETE
Add spec for define_method and define_singleton_method requiring an e…
Add spec for File::TMPFILE
Add spec for File::SHARE_DELETE
Add spec for File::SHARE_DELETE
Add spec for the new :flags keyword argument for File.open
Add spec for rb_timespec_now
Specify exception: false behavior on existing _nonblock specs
Spec the new output buffer argument for recv/recv_nonblock
eregon commentedon Nov 27, 2016
All new features of 2.3 are now finally properly specified in ruby/spec!
We need a better way to deal with this, it's too time consuming.
Ideally, people implementing the features would also contribute a spec.
MRI tests are often not optimal due to testing many different aspects together, making it very likely to fail for reasons unrelated to the new feature on alternative Ruby implementations.
eregon commentedon Nov 27, 2016
I would like to thank @headius, @mjago, @sgarciac and @iliabylich for the big help on these specs! 🎉
We would not make it without you!