Project

General

Profile

Bug #15475

Branch coverage not including csend of assignations

Added by MaxLap (Maxime Lapointe) about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
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

#1

Updated by MaxLap (Maxime Lapointe) about 1 year ago

  • ruby -v changed from 2.6.0 to ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
#2

Updated by mame (Yusuke Endoh) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66674.


compile.c: support branch coverage for a&.foo = 1

[Bug #15475]

Also available in: Atom PDF