Module: RaaP::Coverage
- Defined in:
- lib/raap/coverage.rb
Defined Under Namespace
Classes: Writer
Class Method Summary collapse
- .cov ⇒ Object
- .log(position) ⇒ Object
- .log_with_type(position, type, &block) ⇒ Object
- .new_type_with_log(position, type) ⇒ Object
- .running? ⇒ Boolean
- .show(io) ⇒ Object
- .start(method_type) ⇒ Object
Class Method Details
.cov ⇒ Object
139 140 141 |
# File 'lib/raap/coverage.rb', line 139 def cov @cov or raise("Coverage is not started") end |
.log(position) ⇒ Object
133 134 135 136 137 |
# File 'lib/raap/coverage.rb', line 133 def log(position) return unless running? cov << position.to_sym end |
.log_with_type(position, type, &block) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/raap/coverage.rb', line 156 def log_with_type(position, type, &block) case type when ::RBS::Types::Tuple # FIXME: Support Union in Tuple type.types.each_with_index do |_t, i| log("#{position}_tuple_#{i}") end block&.call(type) when ::RBS::Types::Union i = Random.rand(type.types.length) log_with_type("#{position}_union_#{i}", type.types[i], &block) when ::RBS::Types::Optional if Random.rand(2).zero? log_with_type("#{position}_optional_left", type.type, &block) else log_with_type("#{position}_optional_right", ::RBS::Types::Bases::Nil.new(location: nil), &block) end else log(position) block&.call(type) end end |
.new_type_with_log(position, type) ⇒ Object
150 151 152 153 154 |
# File 'lib/raap/coverage.rb', line 150 def new_type_with_log(position, type) log_with_type(position, type) do |t| Type.new(t) end end |
.running? ⇒ Boolean
129 130 131 |
# File 'lib/raap/coverage.rb', line 129 def running? !!@cov end |
.show(io) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/raap/coverage.rb', line 143 def show(io) return unless running? writer = Writer.new(@method_type, cov) writer.write(io) end |
.start(method_type) ⇒ Object
124 125 126 127 |
# File 'lib/raap/coverage.rb', line 124 def start(method_type) @cov = Set.new @method_type = method_type end |