Skip to content

Write specs for new Ruby 2.5 features and changes #565

Closed

Description

@eregon

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
end

From 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

Core classes updates (outstanding ones only)

Array

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

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

IO

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

Kernel

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

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

String

Struct

  • Struct.new takes keyword_init: true option 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

FrozenError

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

Activity

  1. eregon commented on Dec 15, 2017

    @eregon
    MemberAuthor

    @marcandre @andrykonchin Could you tick the checkboxes of features you added specs for?
    Unfortunately clicking on the checkbox is not enough,
    instead you need to edit the issue and add x inside the [ ].
    Please also do the same when adding new specs, first tick it to avoid conflicts :)

    For contributors without commit access, please write here when you start working on a spec, to avoid having multiple people working on the same specs.

  2. added a commit that references this issue on Dec 15, 2017
  3. cadwallion commented on Dec 28, 2017

    @cadwallion
    Contributor

    Just a heads-up, but it appears you fixed Integer#floor/truncate/ceil/round in October, but it hasn't been checked off yet. :)

  4. eregon commented on Dec 28, 2017

    @eregon
    MemberAuthor

    @cadwallion Thanks, I checked it now :)

  5. cadwallion commented on Dec 28, 2017

    @cadwallion
    Contributor

    Working on FrozenError, PR should be up shortly.

  6. eregon commented on Dec 28, 2017

    @eregon
    MemberAuthor

    For ruby/spec committers: I made the checkboxes all top-level, which allows to just tick them.

  7. eregon commented on Dec 28, 2017

    @eregon
    MemberAuthor

    @cadwallion I think FrozenError is already done in #568.

  8. cadwallion commented on Dec 28, 2017

    @cadwallion
    Contributor

    Why yes, yes it is. And much more thoroughly than mine. Thanks for the heads up!

  9. eregon commented on Dec 28, 2017

    @eregon
    MemberAuthor

    Process.last_status as an alias of $?, Thread#fetch and KeyError should all be mostly straightforward and afaik not yet done.

  10. cadwallion commented on Dec 28, 2017

    @cadwallion
    Contributor

    I'll start in on both KeyError features.

  11. znz commented on Jan 1, 2018

    @znz
    Member

    Pathname.glob with base: and Pathname#glob are missing?

  12. eregon commented on Jan 2, 2018

    @eregon
    MemberAuthor

    @znz I did not add the stdlib NEWS here since it seems more important to focus on language & core changes.

    The standard library is almost like gems nowadays, and we can't possibly spec all gems, it's the responsibility of their maintainers to test them properly.
    That said, specs for stdlib are welcome in ruby/spec.
    But full coverage of stdlib seems an unrealistic goal, which ruby/spec was never close to, so I think it's better to focus on language & core for now.

  13. nilsding commented on Oct 3, 2018

    @nilsding
    Contributor

    @eregon Unless I'm missing something I guess the Regexp/Support absent operator part is done already (was apparently part of 2.4 already): https://github.com/ruby/spec/blob/master/language/regexp/modifiers_spec.rb#L42

  14. eregon commented on Oct 4, 2018

    @eregon
    MemberAuthor

    @nilsding Looks like it indeed, not sure why it's listed in 2.5 changes but I marked it as done, thanks for noticing.

  15. Efesto commented on Oct 25, 2019

    @Efesto

    Hello everyone, I'm working on Kernel#pp Feature #14123 it's already tested

  16. eregon commented on Oct 25, 2019

    @eregon
    MemberAuthor

    @Efesto Right, Kernel#pp already has specs, I marked it as done.

  17. eregon commented on Nov 3, 2019

    @eregon
    MemberAuthor

    I wrote the specs for the final missing pieces, thank you everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions