Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/seeing_is_believing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Options < HashStruct
predicate(:local_cwd) { false }
attribute(:filename) { nil }
attribute(:encoding) { nil }
attribute(:stdin) { "" }
attribute(:stdin) { +"" }
attribute(:require_files) { ['seeing_is_believing/the_matrix'] }
attribute(:load_path_dirs) { [File.realpath(__dir__)] }
attribute(:timeout_seconds) { 0 }
Expand Down
8 changes: 4 additions & 4 deletions lib/seeing_is_believing/binary/annotate_end_of_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def add_stdout_stderr_and_exceptions_to(new_body, results, options)
end

def stdout_ouptut_for(results, options)
return '' unless results.has_stdout?
output = "\n"
return +'' unless results.has_stdout?
output = +"\n"
results.stdout.each_line do |line|
output << FormatComment.call(0, options[:markers][:stdout][:prefix], line.chomp, options) << "\n"
end
Expand All @@ -27,7 +27,7 @@ def stdout_ouptut_for(results, options)

def stderr_ouptut_for(results, options)
return '' unless results.has_stderr?
output = "\n"
output = +"\n"
results.stderr.each_line do |line|
output << FormatComment.call(0, options[:markers][:stderr][:prefix], line.chomp, options) << "\n"
end
Expand All @@ -37,7 +37,7 @@ def stderr_ouptut_for(results, options)
def exception_output_for(results, options)
return '' unless results.has_exception?
exception_marker = options[:markers][:exception][:prefix]
output = ""
output = +""
results.exceptions.each do |exception|
output << "\n"
output << FormatComment.new(0, exception_marker, exception.class_name, options).call << "\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/binary/annotate_every_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def call
end
FormatComment.call(line.size, value_prefix, result, options)
else
''
+''
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/seeing_is_believing/binary/annotate_marked_lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def self.code_rewriter(markers)
if should_inspect && should_pp then "#{pp}#{inspect}"
elsif should_inspect then inspect
elsif should_pp then pp
else ""
else +""
end
},
after_each: -> line_number {
Expand All @@ -74,7 +74,7 @@ def self.code_rewriter(markers)
if should_inspect && should_pp then "#{inspect}#{pp}"
elsif should_inspect then inspect
elsif should_pp then pp
else ""
else +""
end
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/binary/data_structures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.to_regex(string)
}
string =~ %r{\A/(.*)/([mxi]*)\Z}
body = $1 || string
flags = ($2 || "").each_char.inject(0) { |bits, flag| bits | flag_to_bit[flag] }
flags = ($2 || +"").each_char.inject(0) { |bits, flag| bits | flag_to_bit[flag] }
Regexp.new body, flags
end

Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/binary/rewrite_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def self.call(raw_code, options={}, &mapping)
whitespace_col: whitespace_col-line_begin_col,
whitespace: code.raw[whitespace_col...nextline_begin_col]||"",
text_col: nextline_begin_col-line_begin_col,
text: "",
text: +"",
full_range: whitespace_range,
whitespace_range: whitespace_range,
comment_range: comment_range
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module SeeingIsBelieving::Compatibility
refine String do
def scrub(char=nil, &block)
char && block = lambda { |c| char }
each_char.inject("") do |new_str, char|
each_char.inject(+"") do |new_str, char|
if char.valid_encoding?
new_str << char
else
Expand Down
1 change: 1 addition & 0 deletions lib/seeing_is_believing/debugger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Debugger
def initialize(options={})
@coloured = options[:colour]
@stream = options[:stream]
@stream = +@stream if @stream.is_a?(String) && @stream.frozen?
end

Null = new stream: nil
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/event_stream/handlers/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Debug
def initialize(debugger, handler)
@debugger = debugger
@handler = handler
@seen = ""
@seen = +""
@line_width = 150 # debugger is basically for me, so giving it a nice wide width
@name_width = 20
@attr_width = @line_width - @name_width
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/event_stream/producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def build_producer_thread(resultstream)
loop do
to_publish = queue.shift
break if :break == to_publish
resultstream << (to_publish << "\n")
resultstream << to_publish << "\n"
end
rescue IOError, Errno::EPIPE
queue.clear
Expand Down
4 changes: 2 additions & 2 deletions lib/seeing_is_believing/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def has_exception?
end

def initialize
self.stdout = ''
self.stderr = ''
self.stdout = +''
self.stderr = +''
self.exceptions = []
end

Expand Down
1 change: 1 addition & 0 deletions spec/binary/comment_lines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
RSpec.describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentable line and the line number, and adds the returned text (whitespace+comment) to the end' do
def call(code, &block)
return described_class.call(code, &block) if code.end_with? "\n"
code = +code
code << "\n"
described_class.call(code, &block).chomp
end
Expand Down
2 changes: 1 addition & 1 deletion spec/binary/format_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def result_for(line_length, separator, result, options={})
end

def assert_printed(c, printed)
c = c.force_encoding 'utf-8'
c = (+c).force_encoding 'utf-8'
result = result_for 0, '', c
expect(result).to eq printed
expect(result.encoding).to eq Encoding::UTF_8
Expand Down
8 changes: 4 additions & 4 deletions spec/event_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def has_message?(io)
end

def ascii8bit(str)
str.force_encoding Encoding::ASCII_8BIT
(+str).force_encoding Encoding::ASCII_8BIT
end

it 'force encodes the message to UTF8 when it can\'t validly transcode' do
Expand Down Expand Up @@ -307,7 +307,7 @@ def obj.inspect
end

it 'can deal with results of inspect that have singleton methods' do
str = "a string"
str = +"a string"
def str.inspect() self end
producer.record_result :type, 1, str
expect(consumer.call.inspected).to eq str
Expand Down Expand Up @@ -684,7 +684,7 @@ def bad_bool.!(*) raise; end
require 'seeing_is_believing/event_stream/handlers/stream_json_events'
describe Handlers::StreamJsonEvents do
it 'writes each event\'s json representation to the stream' do
stream = ""
stream = +"" # TODO: push unfreezing upstream but fix final expect
handler = described_class.new stream

handler.call Events::Stdout.new(value: "abc")
Expand Down Expand Up @@ -712,7 +712,7 @@ def bad_bool.!(*) raise; end
end

describe Handlers::Debug do
let(:stream) { "" }
let(:stream) { +"" }
let(:events_seen) { [] }
let(:debugger) { SeeingIsBelieving::Debugger.new stream: stream }
let(:parent_observer) { lambda { |event| events_seen << event } }
Expand Down
6 changes: 3 additions & 3 deletions spec/hash_struct_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def ninclude!(needle, haystack)
end

specify 'the block value is not cached' do
klass.attribute(:a, "a" ).new.a << "-modified"
klass.attribute(:a, +"a" ).new.a << "-modified"
eq! "a-modified", klass.new.a

klass.attribute(:b) { "b" }.new.b << "-modified"
klass.attribute(:b) { +"b" }.new.b << "-modified"
eq! "b", klass.new.b
end

Expand Down Expand Up @@ -405,7 +405,7 @@ class EmptySubclass < SeeingIsBelieving::HashStruct
it 'is enumerable, iterating over each attribute(as symbol)/value pair' do
klass.attributes(a: 1, b: 2)
eq! [[:a, 1], [:b, 2]], klass.new.to_a
eq! "a1b2", klass.new.each.with_object("") { |(k, v), s| s << "#{k}#{v}" }
eq! "a1b2", klass.new.each.with_object(+"") { |(k, v), s| s << "#{k}#{v}" }
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/seeing_is_believing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def values_for(input, options={})
end

it 'records the value immediately, so that it is correct even if the result is mutated' do
expect(values_for("a = 'a'\na << 'b'")).to eq [['"a"'], ['"ab"']]
expect(values_for("a = +'a'\na << 'b'")).to eq [['"a"'], ['"ab"']]
end

it 'records each value when a line is evaluated multiple times' do
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def executes_without_error!(code)
result = executes_without_error!('
# producer
Hash = "fake Hash"
String = "fake String"
String = +"fake String"
class << String
undef ===
end
Expand Down
Loading