summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 05:12:34 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 05:12:34 +0000
commit78cf46078e8de57c84807111938173afcb4bcf73 (patch)
tree3a49a247b3763fc9b32264d5f68163282acc14ef /test/coverage/test_coverage.rb
parenta5641cdf7a6ef8ed86209080775fa866a360d346 (diff)
Add method coverage
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index af22d98..7f210c2 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -280,4 +280,29 @@ class TestCoverage < Test::Unit::TestCase
}
}
end
+
+ def test_method_coverage
+ Dir.mktmpdir {|tmp|
+ Dir.chdir(tmp) {
+ File.open("test.rb", "w") do |f|
+ f.puts 'def foo; end'
+ f.puts 'def bar'
+ f.puts 'end'
+ f.puts 'def baz; end'
+ f.puts ''
+ f.puts 'foo'
+ f.puts 'foo'
+ f.puts 'bar'
+ end
+
+ assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:methods=>{[:foo, 0, 1]=>2, [:bar, 1, 2]=>1, [:baz, 2, 4]=>0}}"], [])
+ ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true"
+ Coverage.start(methods: true)
+ tmp = Dir.pwd
+ require tmp + '/test.rb'
+ p Coverage.result[tmp + "/test.rb"]
+ end;
+ }
+ }
+ end
end