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

ruby-changes:48250

From: yui-knk <ko1@a...>
Date: Sun, 22 Oct 2017 22:58:59 +0900 (JST)
Subject: [ruby-changes:48250] yui-knk:r60365 (trunk): Add test cases for branch coverage

yui-knk	2017-10-22 22:58:55 +0900 (Sun, 22 Oct 2017)

  New Revision: 60365

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

  Log:
    Add test cases for branch coverage
    
    * test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement):
      Add test cases for modifier if/unless.

  Modified files:
    trunk/test/coverage/test_coverage.rb
Index: test/coverage/test_coverage.rb
===================================================================
--- test/coverage/test_coverage.rb	(revision 60364)
+++ test/coverage/test_coverage.rb	(revision 60365)
@@ -197,10 +197,12 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L197
   def test_branch_coverage_for_if_statement
     result = {
       :branches => {
-        [:if    , 0,  2, 2] => {[:then,  1,  3, 4]=>2, [:else,  2,  5, 4]=>1},
-        [:unless, 3,  8, 2] => {[:else,  4, 11, 4]=>2, [:then,  5,  9, 4]=>1},
-        [:if    , 6, 14, 2] => {[:then,  7, 15, 4]=>2, [:else,  8, 14, 2]=>1},
-        [:unless, 9, 18, 2] => {[:else, 10, 18, 2]=>2, [:then, 11, 19, 4]=>1},
+        [:if    ,  0,  2, 2] => {[:then,  1,  3, 4]=>2, [:else,  2,  5, 4]=>1},
+        [:unless,  3,  8, 2] => {[:else,  4, 11, 4]=>2, [:then,  5,  9, 4]=>1},
+        [:if    ,  6, 14, 2] => {[:then,  7, 15, 4]=>2, [:else,  8, 14, 2]=>1},
+        [:unless,  9, 18, 2] => {[:else, 10, 18, 2]=>2, [:then, 11, 19, 4]=>1},
+        [:if    , 12, 22, 2] => {[:then, 13, 22, 2]=>2, [:else, 14, 22, 2]=>1},
+        [:unless, 15, 23, 2] => {[:else, 16, 23, 2]=>2, [:then, 17, 23, 2]=>1},
       }
     }
     assert_coverage(<<~"end;", { branches: true }, result)
@@ -224,6 +226,9 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L226
         unless x == 0
           0
         end
+
+        0 if x == 0
+        0 unless x == 0
       end
 
       foo(0)

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

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