mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add type annotations to to_s and inspect
This commit is contained in:
parent
12eb2e9357
commit
6e7d215f69
24 changed files with 30 additions and 30 deletions
|
@ -34,7 +34,7 @@ module Spectator
|
|||
|
||||
# Produces a string representation of the expression.
|
||||
# This consists of the label (if one is available) and the value.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
if (label = @label)
|
||||
io << label << ": "
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ module Spectator
|
|||
|
||||
# Produces a detailed string representation of the expression.
|
||||
# This consists of the label (if one is available) and the value.
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
if (label = @label)
|
||||
io << label << ": "
|
||||
end
|
||||
|
|
|
@ -13,12 +13,12 @@ module Spectator
|
|||
end
|
||||
|
||||
# Displays "anything".
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "anything"
|
||||
end
|
||||
|
||||
# Displays "<anything>".
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
io << "<anything>"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ abstract class SpectatorContext
|
|||
# and that the Crystal compiler instantiates a `#to_s` and/or `#inspect` for each of those types,
|
||||
# an explosion in method instances can be created.
|
||||
# The compile time is drastically reduced by using a dummy string instead.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "Context"
|
||||
end
|
||||
|
||||
# :ditto:
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
io << "Context<" << self.class << '>'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# One-word description of the result.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "error"
|
||||
end
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ module Spectator
|
|||
|
||||
# Constructs the full name or description of the example.
|
||||
# This prepends names of groups this example is part of.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
name = @name
|
||||
|
||||
# Prefix with group's full name if the node belongs to a group.
|
||||
|
@ -210,7 +210,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Exposes information about the example useful for debugging.
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
super
|
||||
io << ' ' << result
|
||||
end
|
||||
|
@ -286,7 +286,7 @@ module Spectator
|
|||
|
||||
# Constructs the full name or description of the example.
|
||||
# This prepends names of groups this example is part of.
|
||||
def to_s(io) : Nil
|
||||
def to_s(io : IO) : Nil
|
||||
@example.to_s(io)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,7 +112,7 @@ module Spectator
|
|||
|
||||
# Constructs the full name or description of the example group.
|
||||
# This prepends names of groups this group is part of.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
# Prefix with group's full name if the node belongs to a group.
|
||||
return unless parent = @group
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ module Spectator
|
|||
|
||||
# Produces the string representation of the hook.
|
||||
# Includes the location and label if they're not nil.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "example group hook"
|
||||
|
||||
if (label = @label)
|
||||
|
|
|
@ -37,7 +37,7 @@ module Spectator
|
|||
|
||||
# Produces the string representation of the hook.
|
||||
# Includes the location and label if they're not nil.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "example hook"
|
||||
|
||||
if (label = @label)
|
||||
|
|
|
@ -39,7 +39,7 @@ module Spectator
|
|||
|
||||
# Produces the string representation of the hook.
|
||||
# Includes the location and label if they're not nil.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "example hook"
|
||||
|
||||
if (label = @label)
|
||||
|
|
|
@ -55,7 +55,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# One-word description of the result.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "fail"
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Writes the comment to the output.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "# " << @content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Produces output for running the previously specified example.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "crystal spec "
|
||||
|
||||
# Use location for argument if it's available, since it's simpler.
|
||||
|
|
|
@ -10,7 +10,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Produces the list of commands to run failed examples.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io.puts "Failed examples:"
|
||||
io.puts
|
||||
@failures.each do |failure|
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Produces the output containing the profiling information.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "Top "
|
||||
io << @profile.size
|
||||
io << " slowest examples ("
|
||||
|
|
|
@ -41,7 +41,7 @@ module Spectator::Formatting::Components
|
|||
private abstract def content(io)
|
||||
|
||||
# Writes the component's output to the specified stream.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
title_line(io)
|
||||
# Ident over to align with the spacing used by the index.
|
||||
indent(index_digit_count + 2) do
|
||||
|
|
|
@ -15,7 +15,7 @@ module Spectator::Formatting::Components
|
|||
# #:##:##
|
||||
# # days #:##:##
|
||||
# ```
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
millis = @span.total_milliseconds
|
||||
return format_micro(io, millis * 1000) if millis < 1
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Displays the stats.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
runtime(io)
|
||||
totals(io)
|
||||
if seed = @report.random_seed?
|
||||
|
|
|
@ -10,7 +10,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Produces the output containing the profiling information.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "# Top "
|
||||
io << @profile.size
|
||||
io << " slowest examples ("
|
||||
|
|
|
@ -31,7 +31,7 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
# Writes the counts to the output.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << @examples << " examples, " << @failures << " failures"
|
||||
|
||||
if @errors > 0
|
||||
|
|
|
@ -59,7 +59,7 @@ module Spectator
|
|||
# ```text
|
||||
# FILE:LINE
|
||||
# ```
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << path << ':' << line
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Spectator::Matchers
|
|||
extend self
|
||||
|
||||
# Text displayed when a method is undefined.
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
io << "<Method undefined>"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -66,12 +66,12 @@ module Spectator
|
|||
|
||||
# Constructs the full name or description of the node.
|
||||
# This prepends names of groups this node is part of.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
display_name.to_s(io)
|
||||
end
|
||||
|
||||
# Exposes information about the node useful for debugging.
|
||||
def inspect(io)
|
||||
def inspect(io : IO) : Nil
|
||||
# Full node name.
|
||||
io << '"' << self << '"'
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# One-word description of the result.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "pass"
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# One-word description of the result.
|
||||
def to_s(io)
|
||||
def to_s(io : IO) : Nil
|
||||
io << "pending"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue