Ruby 2.5 Adds Support For Branch Coverage |
Written by Kay Ewbank | |||
Wednesday, 03 January 2018 | |||
The first stable release of the Ruby 2.5 series comes with a number of new features and performance improvements, including support for branch coverage and the ability for enumerable predicates to accept pattern arguments. Ruby's massive popularity as a programming language comes partially from the fact that it is fun to use, and useful because of its mix of different programming styles - functional, dynamic and object-oriented. The new features of this first release of the Ruby 2.5 line start with the support for branch coverage and method coverage as new target types of coverage for the coverage measurement library. The branch coverage indicates which branches are executed and which are not. The method coverage indicates which methods are invoked and which are not. By running a test suite with these new features, you will know which branches and methods are executed, and evaluate total coverage of the test suite more strictly. Another improvement to the language is the ability to pass pattern arguments to enumerable predicates. Ruby has sequence predicates such as all? none?, one? and any?, all of which take a block and evaluate it by passing every element of the sequence to it. Ruby 2.5 now supports passing a pattern argument. This returns, in the case of a single argument, whether the block'squery holds when each element is supplied to the argument's #=== method. The feature is based on how Other improvements to Ruby 2.5 include the ability to use rescue/else/ensure directly with do/end blocks, avoiding the need for additional statements when wanting to get out of the block in case of an error. Yield_self has been added as an option to yield. It yields the receiver to the given block and returns the result of the block. Hash#slice and Hash#transform_keys have been added, and Struct.new can create classes that accept keyword arguments. The performance of the new release has been improved by between five and ten percent by removing all trace Other performance improvements see block passing by a block parameter running around three times faster than Ruby 2.4 by use of the “Lazy Proc allocation” technique; and Mutex has been rewritten to be smaller and faster. The new release is available for download.
More InformationRelated ArticlesCommercial Ruby Distro Enters Beta ActiveState Extends to Ruby, Node.js, Go and Lua
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Thursday, 08 March 2018 ) |