[前][次][番号順一覧][スレッド一覧]

ruby-changes:43436

From: nobu <ko1@a...>
Date: Mon, 27 Jun 2016 08:57:21 +0900 (JST)
Subject: [ruby-changes:43436] nobu:r55509 (trunk): Coverage on non-positive lines

nobu	2016-06-27 08:56:57 +0900 (Mon, 27 Jun 2016)

  New Revision: 55509

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55509

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/parse.y
    trunk/test/coverage/test_coverage.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55508)
+++ ChangeLog	(revision 55509)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 27 08:56:55 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* ext/win32/lib/Win32API.rb (Win32API#initialize): Cygwin
Index: compile.c
===================================================================
--- compile.c	(revision 55508)
+++ compile.c	(revision 55509)
@@ -253,6 +253,7 @@ r_value(VALUE value) https://github.com/ruby/ruby/blob/trunk/compile.c#L253
 #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); \
Index: parse.y
===================================================================
--- parse.y	(revision 55508)
+++ parse.y	(revision 55509)
@@ -5493,7 +5493,7 @@ coverage(VALUE fname, int n) https://github.com/ruby/ruby/blob/trunk/parse.y#L5493
 {
     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;
     }
Index: test/coverage/test_coverage.rb
===================================================================
--- test/coverage/test_coverage.rb	(revision 55508)
+++ test/coverage/test_coverage.rb	(revision 55509)
@@ -110,4 +110,13 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L110
   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']

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]