Introduce NODE_UNLESS for branch coverage

`unless` statement was a syntactic sugar for `if` statement,
which made the result of branch coverage hard to understand.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2017-09-14 05:27:02 +00:00
parent 78cf46078e
commit 3c8c17d30d
5 changed files with 43 additions and 10 deletions

View file

@ -186,13 +186,19 @@ class TestCoverage < Test::Unit::TestCase
f.puts ' else'
f.puts ' 1'
f.puts ' end'
f.puts ''
f.puts ' unless x == 0'
f.puts ' 0'
f.puts ' else'
f.puts ' 1'
f.puts ' end'
f.puts 'end'
f.puts 'foo(0)'
f.puts 'foo(0)'
f.puts 'foo(1)'
end
assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:branches=>{[:if, 0, 2]=>{[:then, 1, 3]=>2, [:else, 2, 5]=>1}}}"], [])
assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:branches=>{[:if, 0, 2]=>{[:then, 1, 3]=>2, [:else, 2, 5]=>1}, [:unless, 3, 8]=>{[:else, 4, 11]=>2, [:then, 5, 9]=>1}}}"], [])
ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true"
Coverage.start(branches: true)
tmp = Dir.pwd