Project

General

Profile

Actions

Bug #15475

closed

Branch coverage not including csend of assignations

Added by MaxLap (Maxime Lapointe) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
[ruby-core:90763]

Description

In the following code, only the first conditional call will appear in the result hash of the branch coverage. The second one will not because it is a setter. This appears to be a forgotten case for branch coverage.

require 'tempfile'
f = Tempfile.new(['ruby', '.rb'])
f.write(<<-RUBY)
  a = nil
  a&.just_a_call

  a&.now_a_setter = something
RUBY
f.close

require 'coverage'
Coverage.start(branches: true)
load f.path

puts Coverage.result
# => {"/tmp/ruby20181227-1959-1rb8s2n.rb"
#       => {:branches=>{[:"&.", 0, 2, 2, 2, 16]=>{[:then, 1, 2, 2, 2, 16]=>0, [:else, 2, 2, 2, 2, 16]=>1}}}}

This was there in 2.5 and is still there in 2.6

Actions

Also available in: Atom PDF

Like0
Like0Like0