Project

General

Profile

Feature #13838 ยป Coverage.patch

yui-knk (Kaneko Yuichiro), 08/25/2017 12:30 AM

View differences:

ext/coverage/coverage.c
return ncoverages;
}
/*
* call-seq:
* Coverage.enabled? => true or false
*
* Returns the current status of the Coverage.
*/
static VALUE
rb_coverage_enabled_p(VALUE klass)
{
VALUE coverages = rb_get_coverages();
return RTEST(coverages) ? Qtrue : Qfalse;
}
/* Coverage provides coverage measurement feature for Ruby.
* This feature is experimental, so these APIs may be changed in future.
*
......
rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
rb_define_module_function(rb_mCoverage, "peek_result", rb_coverage_peek_result, 0);
rb_define_module_function(rb_mCoverage, "enabled?", rb_coverage_enabled_p, 0);
}
test/coverage/test_coverage.rb
ensure
$".replace loaded_features
end
def test_enabled
assert_equal false, Coverage.enabled?
Coverage.start
assert_equal true, Coverage.enabled?
Coverage.result
assert_equal false, Coverage.enabled?
end
end unless ENV['COVERAGE']
    (1-1/1)