Coverage on non-positive lines

* compile.c (ADD_TRACE): ignore trace instruction on non-positive
  line.
* parse.y (coverage): get rid of ArgumentError when the starting
  line number is not positive.  [ruby-core:76141] [Bug #12517]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-06-26 23:56:57 +00:00
parent 06c5796870
commit f540475134
4 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,11 @@
Mon Jun 27 08:56:55 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (ADD_TRACE): ignore trace instruction on non-positive
line.
* parse.y (coverage): get rid of ArgumentError when the starting
line number is not positive. [ruby-core:76141] [Bug #12517]
Sun Jun 26 10:20:25 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/win32/lib/Win32API.rb (Win32API#initialize): Cygwin

View File

@ -253,6 +253,7 @@ r_value(VALUE value)
#define ADD_TRACE(seq, line, event) \
do { \
if ((event) == RUBY_EVENT_LINE && ISEQ_COVERAGE(iseq) && \
(line) > 0 && \
(line) != ISEQ_COMPILE_DATA(iseq)->last_coverable_line) { \
RARRAY_ASET(ISEQ_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \
ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \

View File

@ -5493,7 +5493,7 @@ coverage(VALUE fname, int n)
{
VALUE coverages = rb_get_coverages();
if (RTEST(coverages) && RBASIC(coverages)->klass == 0) {
VALUE lines = rb_ary_tmp_new_fill(n);
VALUE lines = n > 0 ? rb_ary_tmp_new_fill(n) : rb_ary_tmp_new(0);
rb_hash_aset(coverages, fname, lines);
return lines;
}

View File

@ -110,4 +110,13 @@ class TestCoverage < Test::Unit::TestCase
ensure
$".replace loaded_features
end
def test_nonpositive_linenumber
bug12517 = '[ruby-core:76141] [Bug #12517]'
Coverage.start
assert_nothing_raised(ArgumentError, bug12517) do
RubyVM::InstructionSequence.compile(":ok", nil, "<compiled>", 0)
end
assert_include Coverage.result, "<compiled>"
end
end unless ENV['COVERAGE']