diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 05:12:34 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 05:12:34 +0000 |
commit | 78cf46078e8de57c84807111938173afcb4bcf73 (patch) | |
tree | 3a49a247b3763fc9b32264d5f68163282acc14ef /ext | |
parent | a5641cdf7a6ef8ed86209080775fa866a360d346 (diff) | |
download | ruby-78cf46078e8de57c84807111938173afcb4bcf73.tar.gz |
Add method coverage
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/coverage/coverage.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c index 5bf85631b4..dd3819cb56 100644 --- a/ext/coverage/coverage.c +++ b/ext/coverage/coverage.c @@ -92,6 +92,22 @@ branch_coverage(VALUE branches) return ret; } +static VALUE +method_coverage(VALUE methods) +{ + VALUE ret = rb_hash_new(); + int i, id; + + for (i = 0; i < RARRAY_LEN(methods); ) { + VALUE method_name = RARRAY_AREF(methods, i++); + VALUE lineno = RARRAY_AREF(methods, i++); + VALUE counter = RARRAY_AREF(methods, i++); + rb_hash_aset(ret, rb_ary_new_from_args(3, method_name, INT2FIX(id++), lineno), counter); + } + + return ret; +} + static int coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h) { @@ -121,7 +137,7 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h) } if (methods) { - rb_hash_aset(h, ID2SYM(rb_intern("methods")), methods); + rb_hash_aset(h, ID2SYM(rb_intern("methods")), method_coverage(methods)); } rb_hash_freeze(h); |