[macruby-changes] [2152] MacRuby/branches/experimental/spec/frozen/library/stringio

source_changes at macosforge.org source_changes at macosforge.org
Sun Aug 2 11:58:20 PDT 2009


Revision: 2152
          http://trac.macosforge.org/projects/ruby/changeset/2152
Author:   mattaimonetti at gmail.com
Date:     2009-08-02 11:58:20 -0700 (Sun, 02 Aug 2009)
Log Message:
-----------
made most of the stringio specs Ruby 1.9 compatible

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/library/stringio/gets_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_copy_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/open_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/readline_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/readlines_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/reopen_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/gets_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/gets_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/gets_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -39,7 +39,12 @@
   
   it "returns the next paragraph when the passed separator is an empty String" do
     io = StringIO.new("this is\n\nan example")
-    io.gets("").should == "this is\n"
+    ruby_version_is "" ... "1.9" do
+      io.gets("").should == "this is\n"
+    end
+    ruby_version_is "1.9" do
+      io.gets("").should == "this is\n\n"
+    end
     io.gets("").should == "an example"
   end
   

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_copy_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_copy_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_copy_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -8,7 +8,12 @@
   end
   
   it "is private" do
-    @io.private_methods.should include("initialize_copy")
+    ruby_version_is "" ... "1.9" do
+      @io.private_methods.should include('initialize_copy')
+    end
+    ruby_version_is "1.9" do
+      @io.private_methods.should include(:initialize_copy)
+    end
   end
   
   it "returns self" do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/initialize_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -109,12 +109,21 @@
     io.closed_read?.should be_false
     io.closed_write?.should be_false
   end
-
-  it "raises a TypeError when passed a frozen String in truncate mode as StringIO backend" do
-    io = StringIO.allocate
-    lambda { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(TypeError)
+  
+  ruby_version_is "" ... "1.9" do
+     it "raises a TypeError when passed a frozen String in truncate mode as StringIO backend" do
+      io = StringIO.allocate
+      lambda { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(TypeError)
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "raises a RuntimeError when passed a frozen String in truncate mode as StringIO backend" do
+      io = StringIO.allocate
+      lambda { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(RuntimeError)
+    end
+  end 
+
   it "tries to convert the passed mode to a String using #to_str" do
     obj = mock('to_str')
     obj.should_receive(:to_str).and_return("r")
@@ -169,7 +178,12 @@
   end
 
   it "is private" do
-    @io.private_methods.should include("initialize")
+    ruby_version_is "" ... "1.9" do
+      @io.private_methods.should include('initialize')
+    end
+    ruby_version_is "1.9" do
+      @io.private_methods.should include(:initialize)
+    end
   end
 
   it "sets the mode to read-write" do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/open_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/open_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/open_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -133,9 +133,17 @@
     io.closed_read?.should be_false
     io.closed_write?.should be_false
   end
-
-  it "raises a TypeError when passed a frozen String in truncate mode as StringIO backend" do
-    lambda { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(TypeError)
+  
+  ruby_version_is "" ... "1.9" do
+    it "raises a TypeError when passed a frozen String in truncate mode as StringIO backend" do
+      lambda { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(TypeError)
+    end
+  end                            
+  
+  ruby_version_is "1.9" do
+    it "raises a RuntimeError when passed a frozen String in truncate mode as StringIO backend" do
+      lambda { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(RuntimeError)
+    end 
   end
 
   it "tries to convert the passed mode to a String using #to_str" do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/readline_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/readline_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/readline_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -39,8 +39,13 @@
   end
   
   it "returns the next paragraph when the passed separator is an empty String" do
-    io = StringIO.new("this is\n\nan example")
-    io.readline("").should == "this is\n"
+    io = StringIO.new("this is\n\nan example") 
+    ruby_version_is "" ... "1.9" do
+      io.readline("").should == "this is\n"
+    end
+    ruby_version_is "1.9" do
+      io.readline("").should == "this is\n\n"
+    end
     io.readline("").should == "an example"
   end
   

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/readlines_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/readlines_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/readlines_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -28,7 +28,12 @@
 
   it "returns an Array containing all paragraphs when the passed separator is an empty String" do
     io = StringIO.new("this is\n\nan example")
-    io.readlines("").should == ["this is\n", "an example"]
+    ruby_version_is "" ... "1.9" do
+      io.readlines("").should == ["this is\n", "an example"]
+    end
+    ruby_version_is "1.9" do
+      io.readlines("").should == ["this is\n\n", "an example"]
+    end
   end
   
   it "returns the remaining content as one line starting at the current position when passed nil" do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/reopen_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/reopen_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/reopen_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -47,10 +47,18 @@
     lambda { @io.reopen("burn".freeze, IO::WRONLY) }.should raise_error(Errno::EACCES)
     lambda { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES)
   end
-
-  it "raises a TypeError when trying to reopen self with a frozen String in truncate-mode" do
-    lambda { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(TypeError)
+  
+  ruby_version_is "" ... "1.9" do
+    it "raises a TypeError when trying to reopen self with a frozen String in truncate-mode" do
+      lambda { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(TypeError)
+    end
   end
+  
+  ruby_version_is "1.9" do
+    it "raises a RuntimeError when trying to reopen self with a frozen String in truncate-mode" do
+      lambda { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(RuntimeError)
+    end
+  end 
 
   it "does not raise IOError when passed a frozen String in read-mode" do
     @io.reopen("burn".freeze, IO::RDONLY)

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -35,13 +35,24 @@
     io.send(@method, nil) {|s| seen << s}
     seen.should == ["2 1 2 1 2"]
   end
-
-  it "yields each paragraph when passed an empty String as separator" do
-    seen = []
-    io = StringIO.new("para1\n\npara2\n\n\npara3")
-    io.send(@method, "") {|s| seen << s}
-    seen.should == ["para1\n", "para2\n", "para3"]
+  
+  ruby_version_is "" ... "1.9" do
+   it "yields each paragraph when passed an empty String as separator" do
+      seen = []
+      io = StringIO.new("para1\n\npara2\n\n\npara3")
+      io.send(@method, "") {|s| seen << s}
+      seen.should == ["para1\n", "para2\n", "para3"]
+    end
   end
+  
+  ruby_version_is "1.9" do
+    it "yields each paragraph when passed an empty String as separator" do
+      seen = []
+      io = StringIO.new("para1\n\npara2\n\n\npara3")
+      io.send(@method, "") {|s| seen << s}
+      seen.should == ["para1\n\n", "para2\n\n", "para3"]
+    end
+  end 
 end
 
 describe :stringio_each_no_arguments, :shared => true do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -26,10 +26,18 @@
   it "raises a TypeError when the passed buffer Object can't be converted to a String" do
     lambda { @io.send(@method, 7, Object.new) }.should raise_error(TypeError)
   end
-
-  it "raises an error when passed a frozen String as buffer" do
-    lambda { @io.send(@method, 7, "".freeze) }.should raise_error(TypeError)
+  
+  ruby_version_is "" ... "1.9" do
+    it "raises an error when passed a frozen String as buffer" do
+      lambda { @io.send(@method, 7, "".freeze) }.should raise_error(TypeError)
+    end
   end
+  
+  ruby_version_is "1.9" do  
+    it "raises an error when passed a frozen String as buffer" do
+      lambda { @io.send(@method, 7, "".freeze) }.should raise_error(RuntimeError)
+    end 
+  end
 end
 
 describe :stringio_read_length, :shared => true do

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb	2009-08-02 13:15:43 UTC (rev 2151)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb	2009-08-02 18:58:20 UTC (rev 2152)
@@ -44,11 +44,21 @@
     @io.ungetc(obj)
     @io.string.should == "A234"
   end
-
-  it "raises a TypeError when the passed length can't be converted to an Integer" do
-    lambda { @io.ungetc(Object.new) }.should raise_error(TypeError)
-    lambda { @io.ungetc("A") }.should raise_error(TypeError)
+  
+  ruby_version_is "" ... "1.9" do
+    it "raises a TypeError when the passed length can't be converted to an Integer" do
+      lambda { @io.ungetc(Object.new) }.should raise_error(TypeError)
+      lambda { @io.ungetc("A") }.should raise_error(TypeError)
+    end 
   end
+  
+  ruby_version_is "1.9" do
+    it "raises a TypeError when the passed length can't be converted to an Integer" do
+      lambda { @io.ungetc(Object.new) }.should raise_error(TypeError)
+      @io.ungetc("A").should be_nil
+    end
+  end
+  
 end
 
 describe "StringIO#ungetc when self is not readable" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090802/91a1aaba/attachment-0001.html>


More information about the macruby-changes mailing list