Skip to content

Ruby 2.3 specs #175

Closed
Closed

Description

@eregon

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
  • safe navigation operator:
    • Add specs for a safe navigator. #274 new method call syntax, object&.foo, method #foo is called on
      object if it is not nil.
      this is similar to try! 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
  • the did_you_mean gem:
    • 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?
  • indented here document:

Core classes updates (outstanding ones only)

Core classes compatibility issues (excluding feature bug fixes)

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 supports exception: false.
  • Socket
    • 600d305 Socket#connect_nonblock, Socket#accept_nonblock,
      TCPServer#accept_nonblock, UNIXServer#accept_nonblock,
      BasicSocket#recv_nonblock, BasicSocket#recvmsg_nonblock,
      BasicSocket#sendmsg_nonblock all support exception: false to 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
  • 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

Stdlib compatibility issues (not pure-Ruby changes as these just depend on existing features)

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

  1. added a commit that references this issue on Jul 12, 2016
  2. added a commit that references this issue on Jul 31, 2016
  3. eregon commented on Oct 2, 2016

    @eregon
    MemberAuthor

    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 #rubyspec on Freenode or just create an issue or PR to discuss.

  4. added a commit that references this issue on Oct 23, 2016
  5. iliabylich commented on Oct 24, 2016

    @iliabylich
    Contributor

    @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 with eval may 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 require happens directly in the test. Does moving to an outer context break anything?

  6. 11 remaining items

  7. eregon commented on Nov 27, 2016

    @eregon
    MemberAuthor

    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.

  8. eregon commented on Nov 27, 2016

    @eregon
    MemberAuthor

    I would like to thank @headius, @mjago, @sgarciac and @iliabylich for the big help on these specs! 🎉
    We would not make it without you!

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