summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-14 11:39:58 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-14 11:39:58 +0000
commit3c96f9c76a82907d0201cd3af5f5f2d1c2c48850 (patch)
tree5237bedb5d8191d95c7cb41579f1b0856b0adaec /test/coverage/test_coverage.rb
parent3651c0aa00747c584fadeeae2d9bf50da4ed675a (diff)
Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]
There is an invariant that ISEQ_COVERAGE(iseq) must be Qnil if and only if option->coverage_enabled is false. This invariant was broken by NODE_PRELUDE which updates option->coverage_enabled but not ISEQ_COVERAGE(iseq). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 0753ccd..0fa8f9b 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -119,4 +119,34 @@ class TestCoverage < Test::Unit::TestCase
end
assert_include Coverage.result, "<compiled>"
end
+
+ def test_eval
+ bug13305 = '[ruby-core:80079] [Bug #13305]'
+ loaded_features = $".dup
+
+ Dir.mktmpdir {|tmp|
+ Dir.chdir(tmp) {
+ File.open("test.rb", "w") do |f|
+ f.puts 'REPEATS = 400'
+ f.puts 'def add_method(target)'
+ f.puts ' REPEATS.times do'
+ f.puts ' target.class_eval(<<~RUBY, __FILE__, __LINE__ + 1)'
+ f.puts ' def foo'
+ f.puts ' #{"\n" * rand(REPEATS)}'
+ f.puts ' end'
+ f.puts ' 1'
+ f.puts ' RUBY'
+ f.puts ' end'
+ f.puts 'end'
+ end
+
+ Coverage.start
+ require tmp + '/test.rb'
+ add_method(Class.new)
+ assert_equal Coverage.result[tmp + "/test.rb"], [1, 1, 1, 400, nil, nil, nil, nil, nil, nil, nil], bug13305
+ }
+ }
+ ensure
+ $".replace loaded_features
+ end
end unless ENV['COVERAGE']