Project

General

Profile

Feature #13838 ยป Coverage.patch

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

View differences:

ext/coverage/coverage.c
75 75
    return ncoverages;
76 76
}
77 77

  
78
/*
79
 *  call-seq:
80
 *     Coverage.enabled?  => true or false
81
 *
82
 * Returns the current status of the Coverage.
83
 */
84
static VALUE
85
rb_coverage_enabled_p(VALUE klass)
86
{
87
    VALUE coverages = rb_get_coverages();
88
    return RTEST(coverages) ? Qtrue : Qfalse;
89
}
90

  
78 91
/* Coverage provides coverage measurement feature for Ruby.
79 92
 * This feature is experimental, so these APIs may be changed in future.
80 93
 *
......
115 128
    rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
116 129
    rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
117 130
    rb_define_module_function(rb_mCoverage, "peek_result", rb_coverage_peek_result, 0);
131
    rb_define_module_function(rb_mCoverage, "enabled?", rb_coverage_enabled_p, 0);
118 132
}
test/coverage/test_coverage.rb
154 154
  ensure
155 155
    $".replace loaded_features
156 156
  end
157

  
158
  def test_enabled
159
    assert_equal false, Coverage.enabled?
160

  
161
    Coverage.start
162
    assert_equal true, Coverage.enabled?
163

  
164
    Coverage.result
165
    assert_equal false, Coverage.enabled?
166
  end
167

  
157 168
end unless ENV['COVERAGE']