-
-
Notifications
You must be signed in to change notification settings - Fork 395
Description
ruby/spec already contains many specs for 2.5, but we should aim to cover all new features and important changes.
This will improve the test coverage of these features (and maybe discover a few bugs along the way), allow other Ruby implementations to implement the changes faster with more confidence and document clearly the new behavior.
The new specs should be within a version guard block:
ruby_version_is "2.5" do
# New specs
endFrom https://github.com/ruby/ruby/blob/trunk/NEWS.
Only relevant items are kept for brevity.
NEWS for Ruby 2.5.0
Changes since the 2.4.0 release
Language changes
-
rescue/else/ensure are allowed inside do/end blocks. Feature #12906
-
Top-level constant look-up is removed. Feature #11547
-
refinements take place in string interpolations. Feature #13812
Core classes updates (outstanding ones only)
Array
- Array#append Feature #12746
- Array#prepend Feature #12746
Data
- Is deprecated. It was a base class for C extensions, and it's not
necessary to expose in Ruby level. Feature #3072
Exception
- Exception#full_message to retrieve a String expression of an exception,
formatted in the same way in which Ruby prints out an uncaught exception.
Feature #14141 [experimental]
Dir
- Dir.glob provides new optional keyword argument, :base. Feature #13056
- Dir.children Feature #11302
- Dir.each_child Feature #11302
Enumerable
- Enumerable#{any?,all?,none?,one?} accept a pattern argument Feature #11286
File
- File.open accepts :newline option to imply text mode. Bug #13350
- File#path raises an IOError for files opened with
File::Constants::TMPFILE option. Feature #13568 - File::Stat#{atime,mtime,ctime} support fractional second timestamps on
Windows 8 and later Feature #13726 - File::Stat#ino and File.indentical? support ReFS 128bit ino on Windows 8.1
and later Feature #13731 - File.lutime Feature #4052
Hash
- Hash#transform_keys Feature #13583
- Hash#transform_keys! Feature #13583
- Hash#slice Feature #8499
IO
- IO#pread Feature #4532
- IO#pwrite Feature #4532
- IO#copy_stream tries copy offload with copy_file_range(2) Feature #13867
- IO#write accepts multiple arguments Feature #9323
IOError
- IO#close might raise an error with message "stream closed",
but it is refined to "stream closed in another thread". The new message
is more clear for user.
Bug #13405
Integer
- Integer#step no longer hides errors from coerce method when
given a step value which cannot be compared with #> to 0.
Feature #7688 - Integer#{round,floor,ceil,truncate} always return an Integer.
Bug #13420 - [Ruby 2.5] Integer#pow accepts modulo argument for calculating modular exponentiation #573 Integer#pow accepts modulo argument for calculating modular
exponentiation. Feature #12508 Feature #11003 - Integer#allbits?, Integer#anybits?, Integer#nobits? Feature #12753
- Integer.sqrt Feature #13219
Kernel
- Kernel#yield_self Feature #6721
- Kernel#pp Feature #14123
- Kernel#warn(..., uplevel:n) Feature #12882
Method
- Method#=== that invokes Method#call, as same as Proc#=== Feature #14142
Module
- Module#{attr,attr_accessor,attr_reader,attr_writer} become public Feature #14132
- Module#{define_method,alias_method,undef_method,remove_method} become public Feature #14133
Numeric
- Numerical comparison operators (<,<=,>=,>) no longer hide exceptions
from #coerce method internally. Return nil in #coerce if the coercion is
impossible. Feature #7688
Process
- Precision of Process.times is improved if getrusage(2) exists. Feature #11952
- Process.last_status as an alias of $? Feature #14043
Range
- Range#initialize no longer hides exceptions when comparing begin and
end with #<=> and raise a "bad value for range" ArgumentError
but instead lets the exception from the #<=> call go through.
Feature #7688
Regexp
- Support absent operator Implement Absent Operator k-takata/Onigmo#82
- Support new 5 emoji-related Unicode character properties
String
- [Ruby 2.5] String#-@ #586 String#-@ deduplicates unfrozen strings. Already-frozen
strings remain unchanged for compatibility. Feature #13077 - -"literal" (String#-@) optimized to return the same object
(same as "literal".freeze in Ruby 2.1+) Feature #13295 - String#{casecmp,casecmp?} return nil for non-string arguments
instead of raising a TypeError. Bug #13312 - [Ruby 2.5] Add spec for String#start_with? supporting regexp #551 String#start_with? accepts a regexp Feature #13712
- String#delete_prefix, String#delete_prefix! Feature #12694
- String#delete_suffix, String#delete_suffix! Feature #13665
- String#each_grapheme_cluster and String#grapheme_clusters to
enumerate grapheme clusters Feature #13780 - String#undump to unescape String#dump'ed string Feature #12275
Struct
-
Struct.new takes
keyword_init: trueoption to initialize members
with keyword arguments. Feature #11925 -
Regexp/String: Update Unicode version from 9.0.0 to 10.0.0 Feature #13685
Thread
- Thread#fetch Feature #13009
- The default of Thread.report_on_exception is now true,
showing unhandled exceptions terminating threads on $stderr.
Feature #14143
Time
- Time#at receives 3rd argument which specifies the unit of 2nd argument.
Feature #13919
KeyError
- Adds coverage for KeyError#receiver / KeyError#key #574 KeyError#receiver Feature #12063
- Adds coverage for KeyError#receiver / KeyError#key #574 KeyError#key Feature #12063
FrozenError
- #557 [Ruby 2.5] Update specs to use frozen_error_class for FrozenError #568 New exception class. Feature #13224
Stdlib updates
Only stdlib which do not have tests are listed.
Many stdlib live in their own projects with their own tests.
RbConfig
- RbConfig::LIMITS is added to provide the limits of C types.
This is available when rbconfig/sizeof is loaded.
Compatibility issues (excluding feature bug fixes)
Socket
- BasicSocket#read_nonblock and BasicSocket#write_nonblock no
longer set the O_NONBLOCK file description flag as side effect
(on Linux only) Feature #13362
Random
- Random.raw_seed renamed to become Random.urandom. It is now
applicable to non-seeding purposes due to Bug #9569.
Stdlib compatibility issues (excluding feature bug fixes)
mathn.rb
- 49cdead 82145c5 Removed from stdlib. Feature #10169