Skip to content

Commit

Permalink
Merge pull request topazproject#549 from modcloth/mbh/IO#puts-Kernel#…
Browse files Browse the repository at this point in the history
…puts

Moving IO#puts into lib-topaz (untag specs)
  • Loading branch information
alex committed Mar 25, 2013
2 parents 8d597cc + 869acb1 commit 63c14fc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
14 changes: 14 additions & 0 deletions lib-topaz/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ def <<(s)
return self
end

def puts(*args)
if args.empty?
write("\n")
return nil
end

args.flatten.each do |string|
string = string.to_s unless string.is_a?(String)
write(string)
write("\n") unless string[-1] == "\n"
end
nil
end

def pos=(i)
seek(i, IO::SEEK_SET)
end
Expand Down
11 changes: 0 additions & 11 deletions spec/tags/core/io/puts_tags.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
fails:IO#puts writes just a newline when given no args
fails:IO#puts writes just a newline when given just a newline
fails:IO#puts writes empty string with a newline when given nil as an arg
fails:IO#puts writes empty string with a newline when when given nil as multiple args
fails:IO#puts calls to_s before writing non-string objects
fails:IO#puts writes each arg if given several
fails:IO#puts flattens a nested array before writing it
fails:IO#puts writes nothing for an empty array
fails:IO#puts writes [...] for a recursive array arg
fails:IO#puts writes a newline after objects that do not end in newlines
fails:IO#puts does not write a newline after objects that end in newlines
fails:IO#puts ignores the $/ separator global
fails:IO#puts raises IOError on closed stream
8 changes: 0 additions & 8 deletions spec/tags/core/kernel/puts_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
fails:Kernel#puts is a private method
fails:Kernel#puts writes just a newline when given no args
fails:Kernel#puts writes a newline when given nil as an arg
fails:Kernel#puts calls to_s before writing non-string objects
fails:Kernel#puts writes each arg if given several
fails:Kernel#puts flattens a nested array before writing it
fails:Kernel#puts writes [...] for a recursive array arg
fails:Kernel#puts writes a newline after objects that do not end in newlines
fails:Kernel#puts does not write a newline after objects that end in newlines
fails:Kernel#puts ignores the $/ separator global
11 changes: 0 additions & 11 deletions topaz/objects/ioobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,6 @@ def method_print(self, space, args_w):
os.write(self.fd, end)
return space.w_nil

@classdef.method("puts")
@jit.look_inside_iff(lambda self, space, args_w: jit.isconstant(len(args_w)))
def method_puts(self, space, args_w):
self.ensure_not_closed(space)
for w_arg in args_w:
string = space.str_w(space.send(w_arg, space.newsymbol("to_s")))
os.write(self.fd, string)
if not string.endswith("\n"):
os.write(self.fd, "\n")
return space.w_nil

@classdef.method("getc")
def method_getc(self, space):
self.ensure_not_closed(space)
Expand Down

0 comments on commit 63c14fc

Please sign in to comment.