mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Simplify method chains by using #compact_map
This commit is contained in:
parent
3a508cae26
commit
0b06e72f7e
2 changed files with 4 additions and 10 deletions
|
@ -22,7 +22,7 @@ def new_report(successful_count = 5, failed_count = 5, error_count = 5, pending_
|
|||
error_count.times { results << new_failure_result(Spectator::ErroredResult) }
|
||||
pending_count.times { results << new_pending_result }
|
||||
|
||||
example_runtime = results.select(&.is_a?(Spectator::FinishedResult)).map(&.as(Spectator::FinishedResult)).sum(&.elapsed)
|
||||
example_runtime = results.compact_map(&.as?(Spectator::FinishedResult)).sum(&.elapsed)
|
||||
total_runtime = example_runtime + Time::Span.new(nanoseconds: overhead_time)
|
||||
Spectator::Report.new(results, total_runtime)
|
||||
end
|
||||
|
|
|
@ -38,25 +38,19 @@ module Spectator
|
|||
|
||||
# Returns a set of results for all failed examples.
|
||||
def failures
|
||||
@results.select(&.is_a?(FailedResult)).map(&.as(FailedResult))
|
||||
@results.compact_map(&.as?(FailedResult))
|
||||
end
|
||||
|
||||
# Returns a set of results for all errored examples.
|
||||
def errors
|
||||
@results.select(&.is_a?(ErroredResult)).map(&.as(ErroredResult))
|
||||
@results.compact_map(&.as?(ErroredResult))
|
||||
end
|
||||
|
||||
# Length of time it took to run just example code.
|
||||
# This does not include hooks,
|
||||
# but it does include pre- and post-conditions.
|
||||
def example_runtime
|
||||
@results.sum do |result|
|
||||
if result.is_a?(FinishedResult)
|
||||
result.elapsed
|
||||
else
|
||||
Time::Span.zero
|
||||
end
|
||||
end
|
||||
@results.each.compact_map(&.as?(FinishedResult)).sum(&.elapsed)
|
||||
end
|
||||
|
||||
# Length of time spent in framework processes and hooks.
|
||||
|
|
Loading…
Reference in a new issue