Skip to content
Permalink
Browse files

Merge pull request #549 from modcloth/mbh/IO#puts-Kernel#puts

Moving IO#puts into lib-topaz (untag specs)
  • Loading branch information
alex committed Mar 25, 2013
2 parents 8d597cc + 869acb1 commit 63c14fc5f4ee609a23a5940766c70b59539df06c
Showing with 14 additions and 30 deletions.
  1. +14 −0 lib-topaz/io.rb
  2. +0 −11 spec/tags/core/io/puts_tags.txt
  3. +0 −8 spec/tags/core/kernel/puts_tags.txt
  4. +0 −11 topaz/objects/ioobject.py
@@ -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
@@ -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
@@ -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
@@ -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)

0 comments on commit 63c14fc

Please sign in to comment.