1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c (update_coverage): skip coverage count up if the current

line is out of the way.  rb_sourceline() is unreliable when source
  code is big.  [ruby-dev:44413]

* test/coverage/test_coverage.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2011-08-23 15:44:26 +00:00
parent a14e13b23b
commit 54163e2b52
3 changed files with 32 additions and 3 deletions

View file

@ -31,10 +31,31 @@ class TestCoverage < Test::Unit::TestCase
Coverage.start
require tmp + '/test.rb'
Coverage.result
assert_equal 3, Coverage.result[tmp + '/test.rb'].size
Coverage.start
coverage_test_method
assert_equal 1, Coverage.result.size
assert_equal 0, Coverage.result[tmp + '/test.rb'].size
}
}
ensure
$".replace loaded_features
end
def test_big_code
loaded_features = $".dup
Dir.mktmpdir {|tmp|
Dir.chdir(tmp) {
File.open("test.rb", "w") do |f|
f.puts "p\n" * 10000
f.puts "def ignore(x); end"
f.puts "ignore([1"
f.puts "])"
end
Coverage.start
require tmp + '/test.rb'
assert_equal 10003, Coverage.result[tmp + '/test.rb'].size
}
}
ensure