Skip to content

Commit

Permalink
Fix #210 Recreate Ruby's line breaks in Puts
Browse files Browse the repository at this point in the history
Without TestUp `puts [1,2,3]` outputs as:
```
1
2
3
```
Without TestUp it outputs as `[1, 2, 3]`.

This fix restores the default Ruby behavior to puts for Arrays.
  • Loading branch information
Eneroth3 committed Aug 25, 2023
1 parent e32a68c commit caa3165
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/testup/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ def puts(*args)
if args.empty?
write $/
else
for arg in args
line = arg.to_s
write(line)
if line.empty? || !line.end_with?($/)
write($/)
for arg in args # Why not 'args.each do |arg|' ?
if arg.is_a?(Array)
arg.each { |e| puts(e) }
else
line = arg.to_s
write(line)
if line.empty? || !line.end_with?($/)
write($/)
end
end
end
end
Expand Down

0 comments on commit caa3165

Please sign in to comment.