From 78cf46078e8de57c84807111938173afcb4bcf73 Mon Sep 17 00:00:00 2001 From: mame Date: Thu, 14 Sep 2017 05:12:34 +0000 Subject: Add method coverage git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/coverage/coverage.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'ext') 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); -- cgit v1.2.3