From 7fbab01f771dc9fbddb190c1d201e5509c17107b Mon Sep 17 00:00:00 2001 From: yui-knk Date: Thu, 16 Nov 2017 03:36:20 +0000 Subject: Add a last location to branch coverage * compile.c (DECL_BRANCH_BASE, ADD_TRACE_BRANCH_COVERAGE): Add a last location to arguments. * compile.c (compile_if, compile_case, compile_case2, compile_loop, iseq_compile_each0): Pass a last location to macros. * ext/coverage/coverage.c (branch_coverage): Add a last location to a return value. * test/coverage/test_coverage.rb: Follow-up these changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/coverage/coverage.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'ext') diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c index c4070faf56..368f7b1f8c 100644 --- a/ext/coverage/coverage.c +++ b/ext/coverage/coverage.c @@ -81,16 +81,20 @@ branch_coverage(VALUE branches) for (i = 0; i < RARRAY_LEN(structure); i++) { VALUE branches = RARRAY_AREF(structure, i); VALUE base_type = RARRAY_AREF(branches, 0); - VALUE base_lineno = RARRAY_AREF(branches, 1); - VALUE base_column = RARRAY_AREF(branches, 2); + VALUE base_first_lineno = RARRAY_AREF(branches, 1); + VALUE base_first_column = RARRAY_AREF(branches, 2); + VALUE base_last_lineno = RARRAY_AREF(branches, 3); + VALUE base_last_column = RARRAY_AREF(branches, 4); VALUE children = rb_hash_new(); - rb_hash_aset(ret, rb_ary_new_from_args(4, base_type, LONG2FIX(id++), base_lineno, base_column), children); - for (j = 3; j < RARRAY_LEN(branches); j += 4) { + rb_hash_aset(ret, rb_ary_new_from_args(6, base_type, LONG2FIX(id++), base_first_lineno, base_first_column, base_last_lineno, base_last_column), children); + for (j = 5; j < RARRAY_LEN(branches); j += 6) { VALUE target_label = RARRAY_AREF(branches, j); - VALUE target_lineno = RARRAY_AREF(branches, j + 1); - VALUE target_column = RARRAY_AREF(branches, j + 2); - int idx = FIX2INT(RARRAY_AREF(branches, j + 3)); - rb_hash_aset(children, rb_ary_new_from_args(4, target_label, LONG2FIX(id++), target_lineno, target_column), RARRAY_AREF(counters, idx)); + VALUE target_first_lineno = RARRAY_AREF(branches, j + 1); + VALUE target_first_column = RARRAY_AREF(branches, j + 2); + VALUE target_last_lineno = RARRAY_AREF(branches, j + 3); + VALUE target_last_column = RARRAY_AREF(branches, j + 4); + int idx = FIX2INT(RARRAY_AREF(branches, j + 5)); + rb_hash_aset(children, rb_ary_new_from_args(6, target_label, LONG2FIX(id++), target_first_lineno, target_first_column, target_last_lineno, target_last_column), RARRAY_AREF(counters, idx)); } } -- cgit v1.2.3