summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-03 14:26:06 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-03 14:26:06 +0000
commitcd6df5fb3c1e9b965071d6a92ed1c7d4a938560f (patch)
treee59051b5cb25f14ca7b6e45368118e083e762c98 /ext
parentc10baca4aec21ed7c44abfb786916c2a38d0fc5a (diff)
Refactor the internal data format for coverage measurement
To prepare new measuring targets: branch and method coverages. So far, iseq->coverage was an array of counts executed for line coverage. Now, it is a three-element array for each measuring target, whose first element is an array for line coverage. The second element is planned for branch coverage, and the third will be for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/coverage/coverage.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index d2077a9..643c245 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -24,7 +24,7 @@ rb_coverage_start(VALUE klass)
if (!RTEST(coverages)) {
coverages = rb_hash_new();
rb_obj_hide(coverages);
- rb_set_coverages(coverages);
+ rb_set_coverages(coverages, COVERAGE_TARGET_LINES);
}
return Qnil;
}
@@ -35,9 +35,12 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h)
VALUE path = (VALUE)key;
VALUE coverage = (VALUE)val;
VALUE coverages = (VALUE)h;
- coverage = rb_ary_dup(coverage);
- rb_ary_freeze(coverage);
- rb_hash_aset(coverages, path, coverage);
+ VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES);
+ if (lines) {
+ lines = rb_ary_dup(lines);
+ rb_ary_freeze(lines);
+ }
+ rb_hash_aset(coverages, path, lines);
return ST_CONTINUE;
}