Skip to content

Commit

Permalink
Merge ab9f546 into e5e3f97
Browse files Browse the repository at this point in the history
  • Loading branch information
bbuchalter committed Jan 26, 2021
2 parents e5e3f97 + ab9f546 commit eeaf6a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/zip/ioextras/abstract_output_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def write(data)
end

def print(*params)
self << params.join($OUTPUT_FIELD_SEPARATOR) << $OUTPUT_RECORD_SEPARATOR.to_s
self << params.join << $OUTPUT_RECORD_SEPARATOR.to_s
end

def printf(a_format_string, *params)
Expand Down
13 changes: 5 additions & 8 deletions test/ioextras/abstract_output_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ def <<(data)
def setup
@output_stream = TestOutputStream.new

@save_comma_sep = $OUTPUT_FIELD_SEPARATOR
@save_output_sep = $OUTPUT_RECORD_SEPARATOR
end

def teardown
$, = @save_comma_sep
$\ = @save_output_sep
$OUTPUT_RECORD_SEPARATOR = @save_output_sep
end

def test_write
Expand All @@ -40,7 +38,7 @@ def test_write
end

def test_print
$\ = nil # record separator set to nil
$OUTPUT_RECORD_SEPARATOR = nil # record separator set to nil
@output_stream.print('hello')
assert_equal('hello', @output_stream.buffer)

Expand All @@ -50,19 +48,18 @@ def test_print
@output_stream.print(' You ok ', 'out ', 'there?')
assert_equal('hello world. You ok out there?', @output_stream.buffer)

$\ = "\n"
$OUTPUT_RECORD_SEPARATOR = "\n"
@output_stream.print
assert_equal("hello world. You ok out there?\n", @output_stream.buffer)

@output_stream.print('I sure hope so!')
assert_equal("hello world. You ok out there?\nI sure hope so!\n", @output_stream.buffer)

$, = 'X'
@output_stream.buffer = ''
@output_stream.print('monkey', 'duck', 'zebra')
assert_equal("monkeyXduckXzebra\n", @output_stream.buffer)
assert_equal("monkeyduckzebra\n", @output_stream.buffer)

$\ = nil
$OUTPUT_RECORD_SEPARATOR = nil
@output_stream.buffer = ''
@output_stream.print(20)
assert_equal('20', @output_stream.buffer)
Expand Down

0 comments on commit eeaf6a9

Please sign in to comment.