summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 03:36:05 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 03:36:05 +0000
commit16ab236b8814538419f484ccd42387d3f3101141 (patch)
tree44b0d3e955800742f25a4d9f887cd0008c7d161d /test/coverage/test_coverage.rb
parentce570370f0f1e2aaf8c58d4b6629a627b7e7085b (diff)
Add branch coverage for while and until statements
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 5ed838e..3b3c9c3 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -202,4 +202,28 @@ class TestCoverage < Test::Unit::TestCase
}
}
end
+
+ def test_branch_coverage_for_while_statement
+ Dir.mktmpdir {|tmp|
+ Dir.chdir(tmp) {
+ File.open("test.rb", "w") do |f|
+ f.puts 'x = 3'
+ f.puts 'while x > 0'
+ f.puts ' x -= 1'
+ f.puts 'end'
+ f.puts 'until x == 10'
+ f.puts ' x += 1'
+ f.puts 'end'
+ end
+
+ assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:branches=>{[:while, 0, 2]=>{[:body, 1, 3]=>3}, [:until, 2, 5]=>{[:body, 3, 6]=>10}}}"], [])
+ ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true"
+ Coverage.start(branches: true)
+ tmp = Dir.pwd
+ require tmp + '/test.rb'
+ p Coverage.result[tmp + "/test.rb"]
+ end;
+ }
+ }
+ end
end