Sha256: 458d38e892338b321af858af90556dc8c1238dc4381cd3778cf2f4517efcc424

Contents?: true

Size: 1.72 KB

Versions: 20

Compression:

Stored size: 1.72 KB

Contents

# Coverage provides coverage measurement feature for Ruby. This feature is
# experimental, so these APIs may be changed in future.
#
# # Usage
#
# 1.  require "coverage"
# 2.  do Coverage.start
# 3.  require or load Ruby source file
# 4.  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"
#     Coverage.start
#     require "foo.rb"
#     p Coverage.result  #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
#
module Coverage
  def self.line_stub: () -> Array[Integer?]

  # Returns a hash that contains filename as key and coverage array as value. This
  # is the same as `Coverage.result(stop: false, clear: false)`.
  #
  #     {
  #       "file.rb" => [1, 2, nil],
  #       ...
  #     }
  #
  def self.peek_result: () -> Hash[String, untyped]

  # Returns a hash that contains filename as key and coverage array as value. If
  # `clear` is true, it clears the counters to zero. If `stop` is true, it
  # disables coverage measurement.
  #
  def self.result: (?stop: bool, ?clear: bool) -> Hash[String, untyped]

  # Returns true if coverage stats are currently being collected (after
  # Coverage.start call, but before Coverage.result call)
  #
  def self.running?: () -> bool

  # Enables coverage measurement.
  #
  def self.start: (?lines: bool, ?branches: bool, ?methods: bool, ?oneshot_lines: bool) -> nil
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
rbs-0.14.0 stdlib/coverage/coverage.rbs
rbs-0.13.1 stdlib/coverage/coverage.rbs
rbs-0.13.0 stdlib/coverage/coverage.rbs
rbs-0.12.2 stdlib/coverage/coverage.rbs
rbs-0.12.1 stdlib/coverage/coverage.rbs
rbs-0.12.0 stdlib/coverage/coverage.rbs
rbs-0.11.0 stdlib/coverage/coverage.rbs
rbs-0.10.0 stdlib/coverage/coverage.rbs
rbs-0.9.1 stdlib/coverage/coverage.rbs
rbs-0.9.0 stdlib/coverage/coverage.rbs
rbs-0.8.0 stdlib/coverage/coverage.rbs
rbs-0.7.0 stdlib/coverage/coverage.rbs
rbs-0.6.0 stdlib/coverage/coverage.rbs
rbs-0.5.0 stdlib/coverage/coverage.rbs
rbs-0.4.0 stdlib/coverage/coverage.rbs
rbs-0.3.1 stdlib/coverage/coverage.rbs
rbs-0.3.0 stdlib/coverage/coverage.rbs
rbs-0.2.0 stdlib/coverage/coverage.rbs
steep-0.16.0 vendor/ruby-signature/stdlib/coverage/coverage.rbs
steep-0.15.0 vendor/ruby-signature/stdlib/coverage/coverage.rbs