Actions
Bug #15475
closedBranch coverage not including csend of assignations
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
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
Like0
Like0Like0