Ruby Adds Support For Branch Coverage
Ruby 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.


rubylogo2a

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 Enumerable#grep works. If grep is given a regular expression as an argument, it returns an array containing the items in the original array that match the given regular expression.

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 instructions from the overall bytecode (instruction sequences). The developers say that trace was added to support the TracePoint, but isn't used in the majority of cases, so the trace instructions represent an overhead. Where the facility is needed, the new version uses a dynamic instrumentation technique.

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.

 rubylogo2a

 

More Information

Ruby Official Site

Related Articles

Commercial Ruby Distro Enters Beta

Ruby On Rails Reaches 5.0

Ruby 2.3 Released

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, FacebookGoogle+ or Linkedin.

 

Banner


MIT Self-Driving Car - Do The Free Course, Purchase the T-Shirt
18/01/2018

MIT has made an intensive short course on the practice of deep learning freely available to all - both in person on campus and online. It even has a course t-shirt, but hurry to claim one as the  [ ... ]



Supercomputing MOOC on Future Learn
16/01/2018

A free Supercomputing MOOC designed for anyone interested in leading-edge computing technology or the role that computer simulation takes in modern science and engineering restarted on Future Learn on [ ... ]


More News

 

 
 

 

blog comments powered by Disqus

Last Updated ( Wednesday, 03 January 2018 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.