summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-06 14:29:17 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-06 14:29:17 +0000
commit4225b29df96182f259289ed32a7ce40128b9a835 (patch)
tree5e5a17a195b10cfa7e0db26034fb3f68b40da4cf /test/coverage/test_coverage.rb
parent6a79276eddaafb5d80252b173c535e63f9d5c620 (diff)
* ext/coverage/coverage.c: Fully reset coverage to not persist global state.
It was returning old file coverages as empty arrays to the user. [ruby-core:74596] [Bug #12220] * ext/coverage/coverage.c (rb_coverages): remove unused static state. * thread.c: Moved and renamed coverage_clear_result_i to reset_coverage_i. * test/coverage/test_coverage.rb: improve precision of tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 1611e17..49b64eb 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -63,28 +63,27 @@ class TestCoverage < Test::Unit::TestCase
File.open("test2.rb", "w") do |f|
f.puts <<-EOS
- def coverage_test_method2
- :ok
- :ok
- end
+ 1 + 2
EOS
end
Coverage.start
require tmp + '/test.rb'
- assert_equal 3, Coverage.result[tmp + '/test.rb'].size
+ cov = { "#{tmp}/test.rb" => [1, 0, nil] }
+ assert_equal cov, Coverage.result
# Restart coverage but '/test.rb' is required before restart,
# so coverage is not recorded.
Coverage.start
coverage_test_method
- assert_equal 0, Coverage.result[tmp + '/test.rb'].size
+ assert_equal({}, Coverage.result)
# Restart coverage and '/test2.rb' is required after restart,
# so coverage is recorded.
Coverage.start
require tmp + '/test2.rb'
- assert_equal 4, Coverage.result[tmp + '/test2.rb'].size
+ cov = { "#{tmp}/test2.rb" => [1] }
+ assert_equal cov, Coverage.result
}
}
ensure