summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/coverage/coverage.c7
-rw-r--r--test/coverage/test_coverage.rb36
2 files changed, 23 insertions, 20 deletions
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index 73aa57791b..a8f6bb5e07 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -128,7 +128,7 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
if (RB_TYPE_P(v, T_IMEMO) && imemo_type(v) == imemo_ment) {
const rb_method_entry_t *me = (rb_method_entry_t *) v;
- VALUE path = Qundef, first_lineno = Qundef;
+ VALUE path, first_lineno, first_column, last_lineno, last_column;
VALUE data[5], ncoverage, methods;
VALUE methods_id = ID2SYM(rb_intern("methods"));
VALUE klass;
@@ -140,6 +140,9 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
}
path = data[0];
first_lineno = data[1];
+ first_column = data[2];
+ last_lineno = data[3];
+ last_column = data[4];
if (FIX2LONG(first_lineno) <= 0) continue;
ncoverage = rb_hash_aref(ncoverages, path);
if (NIL_P(ncoverage)) continue;
@@ -148,7 +151,7 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
{
VALUE method_id = ID2SYM(me->def->original_id);
VALUE rcount = rb_hash_aref(me2counter, (VALUE) me);
- VALUE key = rb_ary_new_from_args(3, klass, method_id, first_lineno);
+ VALUE key = rb_ary_new_from_args(6, klass, method_id, first_lineno, first_column, last_lineno, last_column);
VALUE rcount2 = rb_hash_aref(methods, key);
if (NIL_P(rcount)) rcount = LONG2FIX(0);
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index b361d8bcde..8fdef0d67c 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -340,16 +340,16 @@ class TestCoverage < Test::Unit::TestCase
def test_method_coverage
result = {
:methods => {
- [Object, :bar, 2] => 1,
- [Object, :baz, 4] => 0,
- [Object, :foo, 1] => 2,
+ [Object, :bar, 2, 0, 3, 3] => 1,
+ [Object, :baz, 4, 1, 4, 13] => 0,
+ [Object, :foo, 1, 0, 1, 12] => 2,
}
}
- assert_coverage(<<-"end;", { methods: true }, result)
+ assert_coverage(<<~"end;", { methods: true }, result)
def foo; end
def bar
end
- def baz; end
+ def baz; end
foo
foo
@@ -360,12 +360,12 @@ class TestCoverage < Test::Unit::TestCase
def test_method_coverage_for_define_method
result = {
:methods => {
- [Object, :bar, 2] => 1,
- [Object, :baz, 4] => 0,
- [Object, :foo, 1] => 2,
+ [Object, :bar, 2, 20, 3, 1] => 1,
+ [Object, :baz, 4, 9, 4, 11] => 0,
+ [Object, :foo, 1, 20, 1, 22] => 2,
}
}
- assert_coverage(<<-"end;", { methods: true }, result)
+ assert_coverage(<<~"end;", { methods: true }, result)
define_method(:foo) {}
define_method(:bar) {
}
@@ -387,7 +387,7 @@ class TestCoverage < Test::Unit::TestCase
def test_method_coverage_for_alias
_C = DummyConstant.new("C")
_M = DummyConstant.new("M")
- code = <<-"end;"
+ code = <<~"end;"
module M
def foo
end
@@ -403,19 +403,19 @@ class TestCoverage < Test::Unit::TestCase
result = {
:methods => {
- [_C, :baz, 8] => 0,
- [_M, :foo, 2] => 0,
+ [_C, :baz, 8, 2, 9, 5] => 0,
+ [_M, :foo, 2, 2, 3, 5] => 0,
}
}
assert_coverage(code, { methods: true }, result)
result = {
:methods => {
- [_C, :baz, 8] => 12,
- [_M, :foo, 2] => 3,
+ [_C, :baz, 8, 2, 9, 5] => 12,
+ [_M, :foo, 2, 2, 3, 5] => 3,
}
}
- assert_coverage(code + <<-"end;", { methods: true }, result)
+ assert_coverage(code + <<~"end;", { methods: true }, result)
obj = C.new
1.times { obj.foo }
2.times { obj.bar }
@@ -427,7 +427,7 @@ class TestCoverage < Test::Unit::TestCase
def test_method_coverage_for_singleton_class
_singleton_Foo = DummyConstant.new("#<Class:Foo>")
_Foo = DummyConstant.new("Foo")
- code = <<-"end;"
+ code = <<~"end;"
class Foo
def foo
end
@@ -447,8 +447,8 @@ class TestCoverage < Test::Unit::TestCase
result = {
:methods => {
- [_singleton_Foo, :baz, 5] => 12,
- [_Foo, :foo, 2] => 3,
+ [_singleton_Foo, :baz, 5, 2, 6, 5] => 12,
+ [_Foo, :foo, 2, 2, 3, 5] => 3,
}
}
assert_coverage(code, { methods: true }, result)