module
v2_1_10 -
Show latest stable
-
0 notes
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (38)
- 2_2_9 (0)
- 2_4_6 (-1)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
Coverage provides coverage measurement feature for Ruby. This feature is experimental, so these APIs may be changed in future.
Usage
-
require “coverage.so”
-
require or load Ruby source file
-
Coverage.result will return a hash that contains filename as key and coverage array as value. A coverage array gives, for each line, the number of line execution by the interpreter. A nil value means coverage is disabled for this line (lines like else and end).
Example
[foo.rb] s = 0 10.times do |x| s += x end if s == 45 p :ok else p :ng end [EOF] require "coverage.so" Coverage.start require "foo.rb" p Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}