Use multiple << on a single line

This commit is contained in:
Michael Miller 2021-05-30 14:21:42 -06:00
parent 0a7909fb7a
commit e30d5c1981
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
19 changed files with 34 additions and 85 deletions

View file

@ -36,9 +36,7 @@ module Spectator
# This consists of the label (if one is available) and the value.
def to_s(io)
if (label = @label)
io << label
io << ':'
io << ' '
io << label << ": "
end
raw_value.to_s(io)
end
@ -47,9 +45,7 @@ module Spectator
# This consists of the label (if one is available) and the value.
def inspect(io)
if (label = @label)
io << label
io << ':'
io << ' '
io << label << ": "
end
raw_value.inspect(io)
end

View file

@ -16,9 +16,7 @@ abstract class SpectatorContext
# :ditto:
def inspect(io)
io << "Context<"
io << self.class
io << '>'
io << "Context<" << self.class << '>'
end
end

View file

@ -160,8 +160,7 @@ module Spectator
# Exposes information about the example useful for debugging.
def inspect(io)
super
io << ' '
io << result
io << ' ' << result
end
# Creates the JSON representation of the example,

View file

@ -36,13 +36,11 @@ module Spectator
io << "example group hook"
if (label = @label)
io << ' '
io << label
io << ' ' << label
end
if (location = @location)
io << " @ "
io << location
io << " @ " << location
end
end
end

View file

@ -38,13 +38,11 @@ module Spectator
io << "example hook"
if (label = @label)
io << ' '
io << label
io << ' ' << label
end
if (location = @location)
io << " @ "
io << location
io << " @ " << location
end
end
end

View file

@ -43,13 +43,11 @@ module Spectator
io << "example hook"
if (label = @label)
io << ' '
io << label
io << ' ' << label
end
if (location = @location)
io << " @ "
io << location
io << " @ " << location
end
end
end

View file

@ -17,9 +17,7 @@ module Spectator::Formatting::Components
# Writes the comment to the output.
def to_s(io)
io << '#'
io << ' '
io << @content
io << "# " << @content
end
end
end

View file

@ -55,18 +55,14 @@ module Spectator::Formatting::Components
# Produces the title line.
private def title_line(io)
line(io) do
io << @index
io << ')'
io << ' '
io << title
io << @index << ") " << title
end
end
# Produces the subtitle line.
private def subtitle_line(io)
line(io) do
io << subtitle_label
io << subtitle
io << subtitle_label << subtitle
end
end

View file

@ -35,20 +35,17 @@ module Spectator::Formatting::Components
# Formats for microseconds.
private def format_micro(io, micros)
io << micros.round.to_i
io << " microseconds"
io << micros.round.to_i << " microseconds"
end
# Formats for milliseconds.
private def format_millis(io, millis)
io << millis.round(2)
io << " milliseconds"
io << millis.round(2) << " milliseconds"
end
# Formats for seconds.
private def format_seconds(io, seconds)
io << seconds.round(2)
io << " seconds"
io << seconds.round(2) << " seconds"
end
# Formats for minutes.

View file

@ -32,19 +32,13 @@ module Spectator::Formatting::Components
# Writes the counts to the output.
def to_s(io)
io << @examples
io << " examples, "
io << @failures
io << " failures "
io << @examples << " examples, " << @failures << " failures "
if @errors > 1
io << '('
io << @errors
io << " errors), "
io << '(' << @errors << " errors), "
end
io << @pending
io << " pending"
io << @pending << " pending"
end
end
end

View file

@ -24,27 +24,21 @@ module Spectator::Formatting
# Invoked after an example completes successfully.
def example_passed(notification)
@io << "ok "
@io << @counter
@io << " - "
@io << "ok " << @counter << " - "
@io.puts notification.example
end
# Invoked after an example is skipped or marked as pending.
def example_pending(notification)
@io << "not ok " # TODO: Skipped tests should report ok.
@io << @counter
@io << " - "
@io << notification.example
@io << " # TODO "
# TODO: Skipped tests should report ok.
@io << "not ok " << @counter << " - "
@io << notification.example << " # TODO "
@io.puts "No reason given" # TODO: Get reason from result.
end
# Invoked after an example fails.
def example_failed(notification)
@io << "not ok "
@io << @counter
@io << " - "
@io << "not ok " << @counter << " - "
@io.puts notification.example
end

View file

@ -62,9 +62,7 @@ module Spectator
# FILE:LINE
# ```
def to_s(io)
io << path
io << ':'
io << line
io << path << ':' << line
end
# Creates the JSON representation of the location.

View file

@ -124,9 +124,7 @@ module Spectator::Mocks
end
def to_s(io)
io << "Double("
io << @spectator_double_name
io << ')'
io << "Double(" << @spectator_double_name << ')'
end
end
end

View file

@ -32,8 +32,7 @@ module Spectator::Mocks
end
io << ", " unless @args.empty? || @opts.empty?
@opts.each_with_index do |key, value, i|
io << key
io << ": "
io << key << ": "
value.inspect(io)
io << ", " if i < @opts.size - 1
end

View file

@ -18,14 +18,9 @@ module Spectator::Mocks
def to_s(io)
super(io)
if @args
io << '('
io << @args
io << ')'
io << '(' << @args << ')'
end
io << " : "
io << ReturnType
io << " at "
io << @location
io << " : " << ReturnType << " at " << @location
end
end
end

View file

@ -7,8 +7,7 @@ module Spectator::Mocks
end
def to_s(io)
io << '#'
io << @name
io << '#' << @name
end
end
end

View file

@ -26,8 +26,7 @@ module Spectator::Mocks
end
def to_s(io)
io << '#'
io << @name
io << '#' << @name
end
end
end

View file

@ -100,9 +100,7 @@ module Spectator::Mocks
end
def to_s(io)
io << "Double("
io << T
io << ')'
io << "Double(" << T << ')'
end
end
end

View file

@ -55,14 +55,11 @@ module Spectator
# Exposes information about the node useful for debugging.
def inspect(io)
# Full node name.
io << '"'
to_s(io)
io << '"'
io << '"' << self << '"'
# Add location if it's available.
if (location = self.location)
io << " @ "
io << location
io << " @ " << location
end
end
end