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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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