[macruby-changes] [1778] MacRuby/branches/experimental/spec/frozen

source_changes at macosforge.org source_changes at macosforge.org
Sat Jun 6 06:09:09 PDT 2009


Revision: 1778
          http://trac.macosforge.org/projects/ruby/changeset/1778
Author:   eloy.de.enige at gmail.com
Date:     2009-06-06 06:09:07 -0700 (Sat, 06 Jun 2009)
Log Message:
-----------
Updated RubySpec to dbbd5f2ad63092b640b7b211a25dd913aee36422 and tagged failing examples.

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/Array_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/block_given_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/equal_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/shared/object_id.rb
    MacRuby/branches/experimental/spec/frozen/core/process/times_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/at_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/fixtures/methods.rb
    MacRuby/branches/experimental/spec/frozen/core/time/hash_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/minus_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/shared/gm.rb
    MacRuby/branches/experimental/spec/frozen/core/time/shared/local.rb
    MacRuby/branches/experimental/spec/frozen/core/time/shared/time_params.rb
    MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/initialize_copy_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/merge_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/replace_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/update_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Float_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Integer_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/String_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/block_given_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/numeric/coerce_tags.txt
    MacRuby/branches/experimental/spec/frozen/upstream

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/core/dir/home_spec.rb
    MacRuby/branches/experimental/spec/frozen/shared/process/
    MacRuby/branches/experimental/spec/frozen/shared/process/times.rb
    MacRuby/branches/experimental/spec/frozen/tags/macruby/core/time/minus_tags.txt

Removed Paths:
-------------
    MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/hash/reject_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/at_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/gm_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/hash_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/local_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/mktime_tags.txt
    MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/utc_tags.txt

Added: MacRuby/branches/experimental/spec/frozen/core/dir/home_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/home_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/home_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/common'
+
+ruby_version_is "1.9.2" do
+  describe "Dir.home" do
+    it "returns the current user's home directory as a string if called without arguments" do
+      Dir.home.should == home_directory
+    end
+
+    it "returns the named user's home directory as a string if called with an argument" do
+      Dir.home(ENV['USER']).should == home_directory
+    end
+
+    it "raises an ArgumentError if the named user doesn't exist" do
+      lambda { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError)
+    end  
+  end  
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -80,9 +80,11 @@
   end
 
   ruby_version_is "1.9" do
-    it "raises a RuntimeError if called on a frozen instance" do
-      lambda { HashSpecs.frozen_hash.reject! { false } }.should raise_error(RuntimeError)
-      lambda { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(RuntimeError)
+    ruby_bug "#1571", "1.9.2" do
+      it "raises a RuntimeError if called on a frozen instance" do
+        lambda { HashSpecs.frozen_hash.reject! { false } }.should raise_error(RuntimeError)
+        lambda { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(RuntimeError)
+      end
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -46,10 +46,13 @@
   end
 
   ruby_version_is "1.9" do
-    it "raises a RuntimeError if called on a frozen instance" do
-      HashSpecs.frozen_hash.send(@method, HashSpecs.frozen_hash) # ok, nothing changed
-      block = lambda { HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash) }
-      block.should raise_error(RuntimeError)
+    ruby_bug "#1571", "1.9.2" do
+      it "raises a RuntimeError if called on a frozen instance" do
+        lambda { HashSpecs.frozen_hash.send(@method, HashSpecs.frozen_hash) }.
+          should raise_error(RuntimeError)
+        lambda { HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash) }.
+          should raise_error(RuntimeError)
+      end
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -41,10 +41,13 @@
     end
   end
   ruby_version_is "1.9" do
-    it "raises a RuntimeError if called on a non-empty, frozen instance" do
-      HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash) # ok, empty
-      lambda { HashSpecs.frozen_hash.send(@method, 1 => 2) }.
-        should raise_error(RuntimeError)
+    ruby_bug "#1571", "1.9.2" do
+      it "raises a RuntimeError if called on a frozen instance" do
+        lambda { HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash) }.
+          should raise_error(RuntimeError)
+        lambda { HashSpecs.frozen_hash.send(@method, 1 => 2) }.
+          should raise_error(RuntimeError)
+      end
     end
   end
 end

Deleted: MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,56 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
-
-describe "Integer()" do
-  it "returns a Fixnum or Bignum object" do
-    Integer(2).should be_an_instance_of(Fixnum)
-    Integer(9**99).should be_an_instance_of(Bignum)
-  end
-  
-  it "calls to_i on a non-numeric argument" do
-    nine = mock('9')
-    nine.should_receive(:to_i).and_return(9)
-    Integer(nine).should == 9
-    Integer('200').should == 200
-  end
-  
-  it "truncates Floats" do
-    Integer(3.14).should == 3
-    Integer(90.8).should == 90
-  end
-    
-  it "calls to_i on Rationals" do
-    Integer(Rational(8,3)).should == 2
-    Integer(3.quo(2)).should == 1
-  end
-
-  it "passes through Bignums as-is" do
-    bignum = 99**99
-    bignum.should be_an_instance_of(Bignum)
-    Integer(bignum).should == bignum
-    Integer(bignum).should be_an_instance_of(Bignum)
-  end
-
-  it "passes through Fixnums as-is" do
-    fixnum = 99
-    fixnum.should be_an_instance_of(Fixnum)
-    Integer(fixnum).should == fixnum
-    Integer(fixnum).should be_an_instance_of(Fixnum)
-  end
-
-  ruby_version_is "1.9" do
-    it "raises a TypeError when passed nil" do
-      lambda { Integer(nil) }.should raise_error(TypeError)
-    end
-  end
-  
-  ruby_version_is ""..."1.9" do
-    it "returns 0 when passed nil" do
-      Integer(nil).should == 0
-    end
-  end
-
-  it "raises a FloatDomainError when passed NaN" do
-    lambda { Integer(0.0/0.0) }.should raise_error(FloatDomainError)
-  end  
-end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/Array_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/Array_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/Array_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -6,13 +6,27 @@
     Kernel.should have_private_instance_method(:Array)
   end
   
-  it "first tries to call #to_ary on the given argument" do
+  it "does not call #to_ary on an Array" do
+    obj = [1,2,3]
+    obj.should_not_receive(:to_ary)
+
+    Array(obj).should == [1, 2, 3]
+  end
+
+  it "tries to call #to_ary on the given argument if it's not an Array" do
     (obj = mock('[1,2,3]')).should_receive(:to_ary).and_return([1, 2, 3])
     obj.should_not_receive(:to_a)
-    
+
     Array(obj).should == [1, 2, 3]
   end
-  
+
+  it "does not call #to_a on an Array" do
+    obj = [1,2,3]
+    obj.should_not_receive(:to_a)
+
+    Array(obj).should == [1, 2, 3]
+  end
+
   it "tries to call #to_a on the given argument if #to_ary is not provided" do
     (obj = mock('[4,5,6]')).should_receive(:to_a).and_return([4, 5, 6])
     Array(obj).should == [4, 5, 6]
@@ -35,7 +49,3 @@
     lambda { Array(obj) }.should raise_error(TypeError)
   end
 end
-
-describe "Kernel.Array" do
-  it "needs to be reviewed for spec completeness"
-end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,44 +1,246 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-describe "Kernel.Float when passed a String" do
-  it "raises a TypeError when the given String can't be fully converted to a Float" do
-    lambda { Float('0.0.0')  }.should raise_error(ArgumentError)
-    lambda { Float('float')  }.should raise_error(ArgumentError)
-    lambda { Float('10.0:D') }.should raise_error(ArgumentError)
-    lambda { Float('D10')    }.should raise_error(ArgumentError)
+describe :kernel_float, :shared => true do
+  it "returns the identical Float for numeric Floats" do
+    float = 1.12
+    float2 = @object.send(:Float, float)
+    float2.should == float
+    float2.object_id.should == float.object_id
   end
-end
 
-describe "Kernel.Float" do
-  it "is a private method" do
-    Kernel.should have_private_instance_method(:Float)
+  it "returns a Float for Fixnums" do
+    @object.send(:Float, 1).should == 1.0
   end
+
+  it "returns a Float for Bignums" do
+    @object.send(:Float, 1000000000000).should == 1000000000000.0    
+  end
+
+  it "raises an ArgumentError for nil" do
+    lambda { @object.send(:Float, nil) }.should raise_error(TypeError)
+  end
   
-  it "converts the given argument to a Float by calling #to_f" do
-    Kernel.Float(1).should == 1.0
-    Kernel.Float(1.12).should == 1.12
-    Kernel.Float(1000000000000).should == 1000000000000.0
-    Kernel.Float("10").should == 10.0
+  it "returns the identical NaN for NaN" do
+    nan = 0.0/0.0
+    nan.nan?.should be_true
+    nan2 = @object.send(:Float, nan)
+    nan2.nan?.should be_true
+    nan2.should equal(nan)
+  end
+
+  it "returns the same Infinity for Infinity" do
+    infinity = 1.0/0.0
+    infinity2 = @object.send(:Float, infinity)
+    infinity2.should == (1.0/0.0)
+    infinity.should equal(infinity2)
+  end
+
+  it "converts Strings to floats without calling #to_f" do
+    string = "10"
+    string.should_not_receive(:to_f)
+    @object.send(:Float, string).should == 10.0
+  end
+
+  it "converts Strings with decimal points into Floats" do
+    @object.send(:Float, "10.0").should == 10.0
+  end
+
+  it "raises and ArgumentError for a String of word characters" do
+    lambda { @object.send(:Float, "float") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there are two decimal points in the String" do
+    lambda { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises and ArgumentError for a String of numbers followed by word characters" do
+    lambda { @object.send(:Float, "10D") }.should raise_error(ArgumentError)
+  end
+
+  it "raises and ArgumentError for a String of word characters followed by numbers" do
+    lambda { @object.send(:Float, "D10") }.should raise_error(ArgumentError)
+  end
+
+  it "converts String subclasses to floats without calling #to_f" do
+    my_string = Class.new(String) do
+      def to_f() 1.2 end
+    end
+
+    @object.send(:Float, my_string.new("10")).should == 10.0
+  end
+
+  it "returns a positive Float if the string is prefixed with +" do
+    @object.send(:Float, "+10").should == 10.0
+    @object.send(:Float, " +10").should == 10.0
+  end
+
+  it "returns a negative Float if the string is prefixed with +" do
+    @object.send(:Float, "-10").should == -10.0
+    @object.send(:Float, " -10").should == -10.0
+  end
+
+  it "raises an ArgumentError if a + or - is embedded in a String" do
+    lambda { @object.send(:Float, "1+1") }.should raise_error(ArgumentError)
+    lambda { @object.send(:Float, "1-1") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if a String has a trailing + or -" do
+    lambda { @object.send(:Float, "11+") }.should raise_error(ArgumentError)
+    lambda { @object.send(:Float, "11-") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String with a leading _" do
+    lambda { @object.send(:Float, "_1") }.should raise_error(ArgumentError)
+  end
+
+  it "returns a value for a String with an embedded _" do
+    @object.send(:Float, "1_000").should == 1000.0
+  end
+
+  it "raises an ArgumentError for a String with a trailing _" do
+    lambda { @object.send(:Float, "10_") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String of \\0" do
+    lambda { @object.send(:Float, "\0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String with a leading \\0" do
+    lambda { @object.send(:Float, "\01") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String with an embedded \\0" do
+    lambda { @object.send(:Float, "1\01") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String with a trailing \\0" do
+    lambda { @object.send(:Float, "1\0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String that is just an empty space" do
+    lambda { @object.send(:Float, " ") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for a String that with an embedded space" do
+    lambda { @object.send(:Float, "1 2") }.should raise_error(ArgumentError)
+  end
+
+  it "returns a value for a String with a leading space" do
+    @object.send(:Float, " 1").should == 1.0
+  end
+
+  it "returns a value for a String with a trailing space" do
+    @object.send(:Float, "1 ").should == 1.0
+  end
+  
+  %w(e E).each do |e|
+    it "raises an ArgumentError if #{e} is the trailing character" do
+      lambda { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError)
+    end
+
+    it "raises an ArgumentError if #{e} is the leading character" do
+      lambda { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError)
+    end
     
-    (obj = mock('1.2')).should_receive(:to_f).any_number_of_times.and_return(1.2)
+    it "returns Infinity for '2#{e}1000'" do
+      @object.send(:Float, "2#{e}1000").should == (1.0/0)
+    end
+
+    it "returns 0 for '2#{e}-1000'" do
+      @object.send(:Float, "2#{e}-1000").should == 0
+    end
+
+    it "allows embedded _ in a number on either side of the #{e}" do
+      @object.send(:Float, "2_0#{e}100").should == 20e100
+      @object.send(:Float, "20#{e}1_00").should == 20e100
+      @object.send(:Float, "2_0#{e}1_00").should == 20e100
+    end
+
+    it "raises an exception if a space is embedded on either side of the '#{e}'" do
+      lambda { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError)
+      lambda { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError)
+    end
+
+    it "raises an exception if there's a leading _ on either side of the '#{e}'" do
+      lambda { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError)
+      lambda { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError)
+    end
+
+    it "raises an exception if there's a trailing _ on either side of the '#{e}'" do
+      lambda { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError)    
+      lambda { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError)
+    end
+
+    it "allows decimal points on the left side of the '#{e}'" do
+      @object.send(:Float, "2.0#{e}2").should == 2e2
+    end
+
+    it "raises an ArgumentError if there's a decimal point on the right side of the '#{e}'" do
+      lambda { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError)
+    end
+  end
+
+  it "returns a Float that can be a parameter to #Float again" do
+    float = @object.send(:Float, "10")
+    @object.send(:Float, float).should == 10.0
+  end
+
+  it "otherwise, converts the given argument to a Float by calling #to_f" do
+    (obj = mock('1.2')).should_receive(:to_f).once.and_return(1.2)
     obj.should_not_receive(:to_i)
-    Kernel.Float(obj).should == 1.2
+    @object.send(:Float, obj).should == 1.2
   end
+
+  ruby_version_is '' ... '1.9' do
+    it "raises an Argument Error if to_f is called and it returns NaN" do
+      (nan = mock('NaN')).should_receive(:to_f).once.and_return(0.0/0.0)
+      lambda { @object.send(:Float, nan) }.should raise_error(ArgumentError)
+    end
+  end
+
+  ruby_version_is '1.9' do
+    it "returns the identical NaN if to_f is called and it returns NaN" do
+      nan = 0.0/0.0
+      (nan_to_f = mock('NaN')).should_receive(:to_f).once.and_return(nan)
+      nan2 = @object.send(:Float, nan_to_f)
+      nan2.nan?.should be_true
+      nan2.should equal(nan)
+    end
+  end
+
+  it "returns the identical Infinity if to_f is called and it returns Infinity" do
+    infinity = 1.0/0.0
+    (infinity_to_f = mock('Infinity')).should_receive(:to_f).once.and_return(infinity)
+    infinity2 = @object.send(:Float, infinity_to_f)
+    infinity2.should equal(infinity)
+  end
+
+  it "raises a TypeError if #to_f is not provided" do
+    lambda { @object.send(:Float, mock('x')) }.should raise_error(TypeError)
+  end
   
-  it "raises a TypeError of #to_f is not provided" do
-    lambda { Kernel.Float(mock('x')) }.should raise_error(TypeError)
+  it "raises a TypeError if #to_f returns a String" do
+    (obj = mock('ha!')).should_receive(:to_f).once.and_return('ha!')
+    lambda { @object.send(:Float, obj) }.should raise_error(TypeError)
   end
   
-  it "raises a TypeError if #to_f does not return a Float" do
-    (obj = mock('ha!')).should_receive(:to_f).any_number_of_times.and_return('ha!')
-    lambda { Kernel.Float(obj) }.should raise_error(TypeError)
-
-    (obj = mock('123')).should_receive(:to_f).any_number_of_times.and_return(123)
-    lambda { Kernel.Float(obj) }.should raise_error(TypeError)
+  it "raises a TypeError if #to_f returns an Integer" do
+    (obj = mock('123')).should_receive(:to_f).once.and_return(123)
+    lambda { @object.send(:Float, obj) }.should raise_error(TypeError)    
   end
 end
 
+describe "Kernel.Float" do
+  it_behaves_like :kernel_float, :Float, Kernel
+end
+
 describe "Kernel#Float" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like :kernel_float, :Float, mock("receiver for Float()")
 end
+
+describe "Kernel#Float" do
+  it "is a private method" do
+    Kernel.should have_private_instance_method(:Float)
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,67 +1,289 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require "rational"
 
-describe "Kernel.Integer when given a String" do
-  it "does not call #to_i on the given String" do
-    (obj = "2").should_not_receive(:to_i)
-    Integer(obj).should == 2
-    (obj = "0").should_not_receive(:to_i)
-    Integer(obj).should == 0
+describe :kernel_integer, :shared => true do
+  it "returns a Bignum for a Bignum" do
+    Integer(2e100).should == 2e100
   end
   
-  it "ignores whitespaces" do
-    Integer("  2  ").should == 2
-    Integer("  22222  ").should == 22222
+  it "returns a Fixnum for a Fixnum" do
+    Integer(100).should == 100
   end
+
+  it "uncritically return the value of to_int even if it is not an Integer" do
+    obj = mock("object")
+    obj.should_receive(:to_int).and_return("1")
+    obj.should_not_receive(:to_i)
+    Integer(obj).should == "1"
+  end
   
-  it "raises an ArgumentError if the given String has no valid Integer representation" do
-    [ "", "--2", "-+2", "++2", "a2", "2a", "__2",
-      " _2", "2__", "2 _", "2 a"].each do |str|
-      lambda { Integer(str) }.should raise_error(ArgumentError)
+  ruby_version_is "1.9" do
+    it "raises a TypeError when passed nil" do
+      lambda { Integer(nil) }.should raise_error(TypeError)
     end
   end
-end
+  
+  ruby_version_is ""..."1.9" do
+    it "returns 0 when passed nil" do
+      Integer(nil).should == 0
+    end
+  end
 
-describe "Kernel.Integer" do
-  it "is a private method" do
-    Kernel.should have_private_instance_method(:Integer)
+  it "returns a Fixnum or Bignum object" do
+    Integer(2).should be_an_instance_of(Fixnum)
+    Integer(9**99).should be_an_instance_of(Bignum)
   end
   
-  it "calls #to_int if the given object responds to it" do
-    obj = mock('1')
+  it "truncates Floats" do
+    Integer(3.14).should == 3
+    Integer(90.8).should == 90
+  end
+    
+  it "calls to_i on Rationals" do
+    Integer(Rational(8,3)).should == 2
+    Integer(3.quo(2)).should == 1
+  end
+
+  it "returns the value of to_int if the result is a Fixnum" do
+    obj = mock("object")
     obj.should_receive(:to_int).and_return(1)
     obj.should_not_receive(:to_i)
-    
     Integer(obj).should == 1
   end
-  
-  it "calls to_i to convert any arbitrary argument to an Integer" do
-    (obj = mock('7')).should_receive(:to_i).and_return(7)
-    Integer(obj).should == 7
+
+  it "returns the value of to_int if the result is a Bignum" do
+    obj = mock("object")
+    obj.should_receive(:to_int).and_return(2e100)
+    obj.should_not_receive(:to_i)
+    Integer(obj).should == 2e100
   end
 
-  it "raises a TypeError if there is no to_i method on an object" do
-    lambda { Integer(mock('x')) }.should raise_error(TypeError)
+  it "calls to_i on an object whose to_int returns nil" do
+    obj = mock("object")
+    obj.should_receive(:to_int).and_return(nil)
+    obj.should_receive(:to_i).and_return(1)
+    Integer(obj).should == 1
   end
 
-  ruby_version_is ""..."1.9" do
-    it "returns 0 when passed nil" do
-      Integer(nil).should == 0
+  it "uncritically return the value of to_int even if it is not an Integer" do
+    obj = mock("object")
+    obj.should_receive(:to_int).and_return("1")
+    obj.should_not_receive(:to_i)
+    Integer(obj).should == "1"
+  end
+
+  it "raises a TypeError if to_i returns a value that is not an Integer" do
+    obj = mock("object")
+    obj.should_receive(:to_i).and_return("1")
+    lambda { Integer(obj) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError if no to_int or to_i methods exist" do
+    obj = mock("object")
+    lambda { Integer(obj) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError if to_int returns nil and no to_i exists" do
+    obj = mock("object")
+    obj.should_receive(:to_i).and_return(nil)
+    lambda { Integer(obj) }.should raise_error(TypeError)
+  end
+
+  it "raises a FloatDomainError when passed NaN" do
+    lambda { Integer(0.0/0.0) }.should raise_error(FloatDomainError)
+  end
+
+  it "raises a FloatDomainError when passed Infinity" do
+    lambda { Integer(1.0/0.0) }.should raise_error(FloatDomainError)
+  end
+end
+
+describe "Integer() given a String", :shared => true do
+  it "raises an ArgumentError if the String is a null byte" do
+    lambda { Integer("\0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if the String starts with a null byte" do
+    lambda { Integer("\01") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if the String ends with a null byte" do
+    lambda { Integer("1\0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if the String contains a null byte" do
+    lambda { Integer("1\01") }.should raise_error(ArgumentError)
+  end
+
+  it "ignores leading whitespace" do
+    Integer(" 1").should == 1
+    Integer("   1").should == 1
+  end
+
+  it "ignores trailing whitespace" do
+    Integer("1 ").should == 1
+    Integer("1   ").should == 1
+  end
+
+  it "raises an ArgumentError if there are leading _s" do
+    lambda { Integer("_1") }.should raise_error(ArgumentError)
+    lambda { Integer("___1") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there are trailing _s" do
+    lambda { Integer("1_") }.should raise_error(ArgumentError)
+    lambda { Integer("1___") }.should raise_error(ArgumentError)
+  end
+
+  it "ignores an embedded _" do
+    Integer("1_1").should == 11
+  end
+
+  it "raises an ArgumentError if there are multiple embedded _s" do
+    lambda { Integer("1__1") }.should raise_error(ArgumentError)
+    lambda { Integer("1___1") }.should raise_error(ArgumentError)
+  end
+
+  it "ignores a single leading +" do
+    Integer("+1").should == 1
+  end
+
+  it "raises an ArgumentError if there is a space between the + and number" do
+    lambda { Integer("+ 1") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there are multiple leading +s" do
+    lambda { Integer("++1") }.should raise_error(ArgumentError)
+    lambda { Integer("+++1") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there are trailing +s" do
+    lambda { Integer("1+") }.should raise_error(ArgumentError)
+    lambda { Integer("1+++") }.should raise_error(ArgumentError)
+  end
+
+  it "makes the number negative if there's a leading -" do
+    Integer("-1").should == -1
+  end
+
+  it "raises an ArgumentError if there are multiple leading -s" do
+    lambda { Integer("--1") }.should raise_error(ArgumentError)
+    lambda { Integer("---1") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there are trailing -s" do
+    lambda { Integer("1-") }.should raise_error(ArgumentError)
+    lambda { Integer("1---") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError if there is a period" do
+    lambda { Integer("0.0") }.should raise_error(ArgumentError)
+  end
+
+  it "raises an ArgumentError for an empty String" do
+    lambda { Integer("") }.should raise_error(ArgumentError)
+  end
+
+  %w(x X).each do |x|
+    it "parses the value as a hex number if there's a leading 0#{x}" do
+      Integer("0#{x}1").should == 0x1
+      Integer("0#{x}dd").should == 0xdd
     end
+
+    it "is a positive hex number if there's a leading +0#{x}" do
+      Integer("+0#{x}1").should == 0x1
+      Integer("+0#{x}dd").should == 0xdd
+    end
+
+    it "is a negative hex number if there's a leading -0#{x}" do
+      Integer("-0#{x}1").should == -0x1
+      Integer("-0#{x}dd").should == -0xdd
+    end
+
+    it "raises an ArgumentError if the number cannot be parsed as hex" do
+      lambda { Integer("0#{x}g") }.should raise_error(ArgumentError)
+    end
   end
 
-  ruby_version_is "1.9" do
-    it "raises a TypeError when passed nil" do
-      lambda { Integer(nil) }.should raise_error(TypeError)
+  %w(b B).each do |b|
+    it "parses the value as a binary number if there's a leading 0#{b}" do
+      Integer("0#{b}1").should == 0b1
+      Integer("0#{b}10").should == 0b10
     end
+
+    it "is a positive binary number if there's a leading +0#{b}" do
+      Integer("+0#{b}1").should == 0b1
+      Integer("+0#{b}10").should == 0b10
+    end
+
+    it "is a negative binary number if there's a leading -0#{b}" do
+      Integer("-0#{b}1").should == -0b1
+      Integer("-0#{b}10").should == -0b10
+    end
+
+    it "raises an ArgumentError if the number cannot be parsed as binary" do
+      lambda { Integer("0#{b}2") }.should raise_error(ArgumentError)
+    end
   end
 
-  it "raises a TypeError if to_i doesn't return an Integer" do
-    (obj = mock('ha!')).should_receive(:to_i).and_return("ha!")
-    lambda { Integer(obj) }.should raise_error(TypeError)
+  ["o", "O", ""].each do |o|
+    it "parses the value as an octal number if there's a leading 0#{o}" do
+      Integer("0#{o}1").should == 0O1
+      Integer("0#{o}10").should == 0O10
+    end
+
+    it "is a positive octal number if there's a leading +0#{o}" do
+      Integer("+0#{o}1").should == 0O1
+      Integer("+0#{o}10").should == 0O10
+    end
+
+    it "is a negative octal number if there's a leading -0#{o}" do
+      Integer("-0#{o}1").should == -0O1
+      Integer("-0#{o}10").should == -0O10
+    end
+
+    it "raises an ArgumentError if the number cannot be parsed as octal" do
+      lambda { Integer("0#{o}9") }.should raise_error(ArgumentError)
+    end
   end
+
+  %w(D d).each do |d|
+    it "parses the value as a decimal number if there's a leading 0#{d}" do
+      Integer("0#{d}1").should == 1
+      Integer("0#{d}10").should == 10
+    end
+
+    it "is a positive decimal number if there's a leading +0#{d}" do
+      Integer("+0#{d}1").should == 1
+      Integer("+0#{d}10").should == 10
+    end
+
+    it "is a negative decimal number if there's a leading -0#{d}" do
+      Integer("-0#{d}1").should == -1
+      Integer("-0#{d}10").should == -10
+    end
+
+    it "raises an ArgumentError if the number cannot be parsed as decimal" do
+      lambda { Integer("0#{d}a") }.should raise_error(ArgumentError)
+    end
+  end
 end
 
+describe "Kernel.Integer" do
+  it_behaves_like :kernel_integer, :Integer, Kernel
+  it_behaves_like "Integer() given a String", :Integer
+
+  it "is a public method" do
+    Kernel.Integer(10).should == 10
+  end
+end
+
 describe "Kernel#Integer" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like :kernel_integer, :Integer, mock("receiver for Integer()")
+  it_behaves_like "Integer() given a String", :Integer
+
+  it "is a private method" do
+    Kernel.should have_private_instance_method(:Integer)
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,40 +1,75 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-describe "Kernel.String" do
-  it "is a private method" do
-    Kernel.should have_private_instance_method(:String)
-  end
-  
+describe :kernel_String, :shared => true do
   it "converts the given argument to a String by calling #to_s" do
-    Kernel.String(nil).should == ""
-    Kernel.String("10").should == "10"
-    Kernel.String(1.12).should == "1.12"
-    Kernel.String(false).should == "false"
-    Kernel.String(Object).should == "Object"
+    @object.send(@method, nil).should == ""
+    @object.send(@method, 1.12).should == "1.12"
+    @object.send(@method, false).should == "false"
+    @object.send(@method, Object).should == "Object"
 
     (obj = mock('test')).should_receive(:to_s).and_return("test")
-    Kernel.String(obj).should == "test"
+    @object.send(@method, obj).should == "test"
   end
 
-# TODO: does not work yet because of undef_method
-#
-#  it "raises a TypeError of #to_s is not provided" do
-#    class << (obj = mock('to_s'))
-#      undef_method :to_s
-#    end
-#    
-#    lambda {
-#      Kernel.String(obj)
-#    }.should raise_error(TypeError)
-#  end
+  it "raises a TypeError if #to_s is not provided" do
+    class << (obj = mock('to_s'))
+      undef_method :to_s
+    end
+
+    lambda { Kernel.String(obj) }.should raise_error(TypeError)
+  end
   
+  it "raises a TypeError if respond_to? returns false for to_s" do
+    obj = mock("to_s")
+    def obj.respond_to?(meth, *)
+      meth.to_s == "to_s" ? false : super
+    end
+
+    lambda { String(obj) }.should raise_error(TypeError)
+  end
+
+  it "tries to call the to_s method if respond_to? returns true for to_s" do
+    class << (obj = mock('to_s'))
+      undef_method :to_s
+    end
+
+    def obj.respond_to?(meth, *)
+      meth.to_s == "to_s" ? true : super
+    end
+
+    lambda { @object.send(@method, obj) }.should raise_error(NoMethodError)
+  end
+
   it "raises a TypeError if #to_s does not return a String" do
     (obj = mock('123')).should_receive(:to_s).and_return(123)
-    lambda { Kernel.String(obj) }.should raise_error(TypeError)
+    lambda { @object.send(@method, obj) }.should raise_error(TypeError)
   end
+
+  it "returns the same object if it already a String" do
+    string = "Hello"
+    string.should_not_receive(:to_s)
+    string2 = @object.send(@method, string)
+    string.should equal(string2)
+  end
+
+  it "returns the same object if it is an instance of a String subclass" do
+    subklass = Class.new(String)
+    string = subklass.new("Hello")
+    string.should_not_receive(:to_s)
+    string2 = @object.send(@method, string)
+    string.should equal(string2)
+  end
 end
 
+describe "Kernel.String" do
+  it_behaves_like :kernel_String, :String, Kernel
+end
+
 describe "Kernel#String" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like :kernel_String, :String, mock("receiver for String()")
+
+  it "is a private method" do
+    Kernel.should have_private_instance_method(:String)
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/block_given_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/block_given_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/block_given_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,16 +1,50 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
+describe :kernel_block_given, :shared => true do
+  it "returns true if and only if a block is supplied" do
+    @object.accept_block {}.should_not == false
+    @object.accept_block_as_argument {}.should_not == false
+    @object.accept_block.should_not == true
+    @object.accept_block_as_argument.should_not == true
+  end
+
+  # Clarify: Based on http://www.ruby-forum.com/topic/137822 it appears
+  # that Matz wanted this to be true in 1.9.
+  it "returns false when a method defined by define_method is called with a block" do
+    @object.defined_block {}.should == false
+  end
+end
+
 describe "Kernel#block_given?" do
+  it_behaves_like :kernel_block_given, :block_given?, KernelSpecs::BlockGiven
+
+  it "returns false outside of a method" do
+    block_given?.should == false
+  end
+
   it "is a private method" do
     Kernel.should have_private_instance_method(:block_given?)
   end
+end
+
+describe "Kernel.block_given?" do
+  it_behaves_like :kernel_block_given, :block_given?, KernelSpecs::KernelBlockGiven
+end
+
+describe "self.send(:block_given?)" do
+  ruby_version_is ""..."1.9" do
+    it "always returns false" do
+      KernelSpecs::SelfBlockGiven.accept_block {}.should == false
+      KernelSpecs::SelfBlockGiven.accept_block_as_argument {}.should == false
+      KernelSpecs::SelfBlockGiven.accept_block.should == false
+      KernelSpecs::SelfBlockGiven.accept_block_as_argument.should == false
+      KernelSpecs::SelfBlockGiven.defined_block {}.should == false
+    end
+  end
   
-  it "returns true if and only if a block is supplied" do
-    KernelSpecs::BlockGiven::accept_block {}.should_not == false
-    KernelSpecs::BlockGiven::accept_block_as_argument {}.should_not == false
-    KernelSpecs::BlockGiven::accept_block.should_not == true
-    KernelSpecs::BlockGiven::accept_block_as_argument.should_not == true
+  ruby_version_is "1.9" do
+    it_behaves_like :kernel_block_given, :block_given?, KernelSpecs::SelfBlockGiven
   end
 end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/equal_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/equal_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/equal_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -12,12 +12,28 @@
     (o1.equal?  nil).should== false
     (nil.equal?  o2).should== false
   end  
-  
-  it "returns true if obj and anObject have the same value." do 
+
+  it "returns true if obj and anObject have the same value." do
     o1 = 1
     o2 = :hola
     (:hola.equal? o1).should == false
     (1.equal? o1).should == true
     (:hola.equal? o2).should == true
   end
+
+  it "is unaffected by overriding object_id" do
+    o1 = mock("object")
+    o1.stub!(:object_id).and_return(10)
+    o2 = mock("object")
+    o2.stub!(:object_id).and_return(10)
+    o1.equal?(o2).should be_false
+  end
+
+  it "is unaffected by overriding __id__" do
+    o1 = mock("object")
+    o1.stub!(:__id__).and_return(10)
+    o2 = mock("object")
+    o2.stub!(:__id__).and_return(10)
+    o1.equal?(o2).should be_false
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -138,8 +138,62 @@
     def self.accept_block_as_argument(&block)
       block_given?
     end
+
+    class << self
+      define_method(:defined_block) do
+        block_given?
+      end
+    end
   end
 
+  module KernelBlockGiven
+    def self.accept_block
+      Kernel.block_given?
+    end
+
+    def self.accept_block_as_argument(&block)
+      Kernel.block_given?
+    end
+
+    class << self
+      define_method(:defined_block) do
+        Kernel.block_given?
+      end
+    end
+  end
+
+  module SelfBlockGiven
+    def self.accept_block
+      self.send(:block_given?)
+    end
+
+    def self.accept_block_as_argument(&block)
+      self.send(:block_given?)
+    end
+
+    class << self
+      define_method(:defined_block) do
+        self.send(:block_given?)
+      end
+    end
+  end
+
+  module KernelBlockGiven
+    def self.accept_block
+      Kernel.block_given?
+    end
+
+    def self.accept_block_as_argument(&block)
+      Kernel.block_given?
+    end
+
+    class << self
+      define_method(:defined_block) do
+        Kernel.block_given?
+      end
+    end
+  end
+
   def self.before_and_after
     i = "before"
     cont = callcc { |c| c }

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/shared/object_id.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/shared/object_id.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/shared/object_id.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -16,4 +16,58 @@
     o2 = mock('o2')
     o1.send(@method).should_not == o2.send(@method)
   end
+
+  it "returns the same value for two Fixnums with the same value" do
+    o1 = 1
+    o2 = 1
+    o1.send(@method).should == o2.send(@method)
+  end
+
+  it "returns the same value for two Symbol literals" do
+    o1 = :hello
+    o2 = :hello
+    o1.send(@method).should == o2.send(@method)
+  end
+
+  it "returns the same value for two true literals" do
+    o1 = true
+    o2 = true
+    o1.send(@method).should == o2.send(@method)
+  end
+
+  it "returns the same value for two false literals" do
+    o1 = false
+    o2 = false
+    o1.send(@method).should == o2.send(@method)
+  end
+
+  it "returns the same value for two nil literals" do
+    o1 = nil
+    o2 = nil
+    o1.send(@method).should == o2.send(@method)
+  end
+
+  it "returns a different value for two Bignum literals" do
+    o1 = 2e100.to_i
+    o2 = 2e100.to_i
+    o1.send(@method).should_not == o2.send(@method)
+  end
+
+  it "returns a different value for two Float literals" do
+    o1 = 1.0
+    o2 = 1.0
+    o1.send(@method).should_not == o2.send(@method)
+  end
+
+  it "returns a different value for two String literals" do
+    o1 = "hello"
+    o2 = "hello"
+    o1.send(@method).should_not == o2.send(@method)
+  end
+
+  it "returns a different value for an object and its dup" do
+    o1 = mock("object")
+    o2 = o1.dup
+    o1.send(@method).should_not == o2.send(@method)
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/process/times_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/process/times_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/process/times_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,29 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/../../shared/process/times'
 
 describe "Process.times" do
-  it "returns a Struct::Tms" do
-    Process::times.class.should == Struct::Tms
-  end
-
-  it "returns current cpu times" do
-
-    t = Process::times
-
-    # Stall for 1 second, but do work instead of sleeping
-    # because process times won't increase.
-    start = Time.now
-    1 until (Time.now - start) > 1.2
-
-    # Ensure times is larger. NOTE that there is no 
-    # guarantee of an upper bound since anything may be 
-    # happening at the OS level, so we ONLY check that at 
-    # least an interval has elapsed. Also, we are assuming 
-    # there is a correlation between wall clock time and 
-    # process time. In practice, there is an observed 
-    # discrepancy often 10% or greater. In other words, 
-    # this is a very fuzzy test.
-    t2 = Process::times
-    diff = (t2.utime + t2.stime) - (t.utime + t.stime)
-    diff.should > 0
-  end
+  it_behaves_like :process_times, :times, Process
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -14,7 +14,6 @@
       str = ori_str
       256.times do |i|
         str = str.chop
-        p str
         str.should == ori_str[0, 255 - i]
       end
     end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/at_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/at_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/at_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -2,11 +2,20 @@
 require File.dirname(__FILE__) + '/fixtures/methods'
 
 describe "Time.at" do
-  it "converts to time object" do
-    # the #chomp calls are necessary because of RSpec
-    Time.at(1168475924).inspect.chomp.should == localtime(1168475924).chomp
+  ruby_version_is ""..."1.9" do
+    it "converts to time object" do
+      # the #chomp calls are necessary because of RSpec
+      Time.at(1168475924).inspect.chomp.should == localtime_18(1168475924).chomp
+    end
   end
   
+  ruby_version_is "1.9" do
+    it "converts to time object" do
+      # the #chomp calls are necessary because of RSpec
+      Time.at(1168475924).inspect.chomp.should == localtime_19(1168475924).chomp
+    end
+  end
+
   it "creates a new time object with the value given by time" do
     t = Time.now
     Time.at(t).inspect.should == t.inspect

Modified: MacRuby/branches/experimental/spec/frozen/core/time/fixtures/methods.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/fixtures/methods.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/fixtures/methods.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -20,7 +20,9 @@
   end
 end
 
-def localtime(seconds)
+# Returns the given time in the same format as returned by
+# Time.at(seconds).inspect on MRI 1.8
+def localtime_18(seconds)
   platform_is :os => [:darwin, :bsd] do
     return `LC_ALL=C date -r #{seconds} +'%a %b %d %H:%M:%S %z %Y'`.chomp
   end
@@ -31,3 +33,17 @@
 
   return `LC_ALL=C date -j -f "%s" #{seconds} "+%a %b %d %H:%M:%S %z %Y"`.chomp
 end
+
+# Returns the given time in the same format as returned by
+# Time.at(seconds).inspect on MRI 1.9
+def localtime_19(seconds)
+  platform_is :os => [:darwin, :bsd] do
+    return `LC_ALL=C date -r #{seconds} +'%F %H:%M:%S %z'`.chomp
+  end
+
+  platform_is :os => :linux do
+    return `LC_ALL=C date -d @#{seconds} +'%F %H:%M:%S %z'`.chomp
+  end
+
+  return `LC_ALL=C date -j -f "%s" #{seconds} "+%F %H:%M:%S %z"`.chomp
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/hash_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/hash_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -2,9 +2,11 @@
 require File.dirname(__FILE__) + '/fixtures/methods'
 
 describe "Time#hash" do
-  it "returns a unique integer for each time" do
-    Time.at(100).hash.should == 100
-    Time.at(100, 123456).hash.should == 123428
-    Time.gm(1980).hash.should == 315532800
-  end
+  it "returns a Fixnum" do
+    Time.at(100).hash.should be_kind_of(Fixnum)
+  end  
+  
+  it "is stable" do
+    Time.at(1234).hash.should == Time.at(1234).hash
+  end  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/minus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/minus_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/minus_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,32 +1,73 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/methods'
 
-describe "Time#-" do
-  it "decrements the time by the specified amount" do
-    (Time.at(100) - 100).should == Time.at(0)
-    (Time.at(100) - Time.at(99)).should == 1.0
-    (Time.at(1.1) - 0.2).should == Time.at(0.9)
-  end
+# MRI 1.9 broke this test, so we use a combination of version guards and bug
+# guards to indicate that it is expected to pass on versions < 1.9, and,
+# currently, expected to fail on 1.9. Once this bug is fixed and backported,
+# these guards can be removed, along with the duplicate describe block.
 
-  it "accepts arguments that can be coerced into Float" do
-    (obj = mock('9.5')).should_receive(:to_f).and_return(9.5)
-    (Time.at(100) - obj).should == Time.at(90.5)    
-  end
+ruby_version_is ""..."1.9" do
+  describe "Time#-" do
+    it "decrements the time by the specified amount" do
+      (Time.at(100) - 100).should == Time.at(0)
+      (Time.at(100) - Time.at(99)).should == 1.0
+      (Time.at(1.1) - 0.2).should == Time.at(0.9)
+    end
 
-  it "raises TypeError on argument that can't be coerced into Float" do
-    lambda { Time.now - Object.new }.should raise_error(TypeError)
-    lambda { Time.now - "stuff" }.should raise_error(TypeError)
-  end
+    it "accepts arguments that can be coerced into Float" do
+      (obj = mock('9.5')).should_receive(:to_f).and_return(9.5)
+      (Time.at(100) - obj).should == Time.at(90.5)    
+    end
 
-  it "raises TypeError on nil argument" do
-    lambda { Time.now - nil }.should raise_error(TypeError)
+    it "raises TypeError on argument that can't be coerced into Float" do
+      lambda { Time.now - Object.new }.should raise_error(TypeError)
+      lambda { Time.now - "stuff" }.should raise_error(TypeError)
+    end
+
+    it "raises TypeError on nil argument" do
+      lambda { Time.now - nil }.should raise_error(TypeError)
+    end
+
+    it "tracks microseconds" do
+      time = Time.at(0.777777)
+      time -= 0.654321
+      time.usec.should == 123456
+      time -= 0.123456
+      time.usec.should == 0
+    end
   end
+end
 
-  it "tracks microseconds" do
-    time = Time.at(0.777777)
-    time -= 0.654321
-    time.usec.should == 123456
-    time -= 0.123456
-    time.usec.should == 0
+ruby_version_is "1.9" do
+  ruby_bug "[ruby-dev:38446]", "1.9.2" do
+    describe "Time#-" do
+      it "decrements the time by the specified amount" do
+        (Time.at(100) - 100).should == Time.at(0)
+        (Time.at(100) - Time.at(99)).should == 1.0
+        (Time.at(1.1) - 0.2).should == Time.at(0.9)
+      end
+
+      it "accepts arguments that can be coerced into Float" do
+        (obj = mock('9.5')).should_receive(:to_f).and_return(9.5)
+        (Time.at(100) - obj).should == Time.at(90.5)    
+      end
+
+      it "raises TypeError on argument that can't be coerced into Float" do
+        lambda { Time.now - Object.new }.should raise_error(TypeError)
+        lambda { Time.now - "stuff" }.should raise_error(TypeError)
+      end
+
+      it "raises TypeError on nil argument" do
+        lambda { Time.now - nil }.should raise_error(TypeError)
+      end
+
+      it "tracks microseconds" do
+        time = Time.at(0.777777)
+        time -= 0.654321
+        time.usec.should == 123456
+        time -= 0.123456
+        time.usec.should == 0
+      end
+    end
   end
-end
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -14,24 +14,37 @@
     it "increments the time by the specified amount as float numbers" do
       (Time.at(1.1) + 0.9).should == Time.at(2)
     end
+
+    it "accepts arguments that can be coerced into Float" do
+      (obj = mock('10.5')).should_receive(:to_f).and_return(10.5)
+      (Time.at(100) + obj).should == Time.at(110.5)
+    end
+
+    it "raises TypeError on argument that can't be coerced into Float" do
+      lambda { Time.now + Object.new }.should raise_error(TypeError)
+      lambda { Time.now + "stuff" }.should raise_error(TypeError)
+    end
   end
 
-  ruby_version_is "1.9" do
+  ruby_version_is "1.9.2" do
     it "increments the time by the specified amount as rational numbers" do
       (Time.at(1.1) + 0.9).should_not == Time.at(2)
     end
-  end
 
-  it "accepts arguments that can be coerced into Float" do
-    (obj = mock('10.5')).should_receive(:to_f).and_return(10.5)
-    (Time.at(100) + obj).should == Time.at(110.5)
-  end
+    it "accepts arguments that can be coerced into Rational" do
+      (obj = mock('10')).should_receive(:to_r).and_return(Rational(10))
+      (Time.at(100) + obj).should == Time.at(110)
+    end
 
-  it "raises TypeError on argument that can't be coerced into Float" do
-    lambda { Time.now + Object.new }.should raise_error(TypeError)
-    lambda { Time.now + "stuff" }.should raise_error(TypeError)
+    ruby_bug "#1583", "1.9.2" do
+      it "raises TypeError on argument that can't be coerced into Rational" do
+        lambda { Time.now + Object.new }.should raise_error(TypeError)
+        lambda { Time.now + "stuff" }.should raise_error(TypeError)
+      end
+    end
   end
 
+
   it "raises TypeError on Time argument" do
     lambda { Time.now + Time.now }.should raise_error(TypeError)
   end
@@ -40,11 +53,13 @@
     lambda { Time.now + nil }.should raise_error(TypeError)
   end
 
-  it "tracks microseconds" do
-    time = Time.at(0)
-    time += 0.123456
-    time.usec.should == 123456
-    time += 0.654321
-    time.usec.should == 777777
+  ruby_bug "[ruby-dev:38446]", "1.9.2" do
+    it "tracks microseconds" do
+      time = Time.at(0)
+      time += 0.123456
+      time.usec.should == 123456
+      time += 0.654321
+      time.usec.should == 777777
+    end  
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/shared/gm.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/shared/gm.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/shared/gm.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,10 +1,23 @@
 describe :time_gm, :shared => true do
-  it "creates a time based on given values, interpreted as UTC (GMT)" do
-    Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "Sat Jan 01 20:15:01 UTC 2000"
+  ruby_version_is ""..."1.9" do
+    it "creates a time based on given values, interpreted as UTC (GMT)" do
+      Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "Sat Jan 01 20:15:01 UTC 2000"
+    end
+
+    it "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)" do
+      time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
+      time.inspect.should == "Sat Jan 01 20:15:01 UTC 2000"
+    end
   end
 
-  it "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)" do
-    time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
-    time.inspect.should == "Sat Jan 01 20:15:01 UTC 2000"
+  ruby_version_is "1.9" do
+    it "creates a time based on given values, interpreted as UTC (GMT)" do
+      Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "2000-01-01 20:15:01 UTC"
+    end
+
+    it "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)" do
+      time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
+      time.inspect.should == "2000-01-01 20:15:01 UTC"
+    end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/shared/local.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/shared/local.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/shared/local.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,14 +1,32 @@
 describe :time_local, :shared => true do
-  it "creates a time based on given values, interpreted in the local time zone" do
-    with_timezone("PST", -8) do
-      Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "Sat Jan 01 20:15:01 -0800 2000"
+
+  ruby_version_is ""..."1.9" do
+    it "creates a time based on given values, interpreted in the local time zone" do
+      with_timezone("PST", -8) do
+        Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "Sat Jan 01 20:15:01 -0800 2000"
+      end
     end
+
+    it "creates a time based on given C-style gmtime arguments, interpreted in the local time zone" do
+      with_timezone("PST", -8) do
+        time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
+        time.inspect.should == "Sat Jan 01 20:15:01 -0800 2000"
+      end
+    end
   end
 
-  it "creates a time based on given C-style gmtime arguments, interpreted in the local time zone" do
-    with_timezone("PST", -8) do
-      time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
-      time.inspect.should == "Sat Jan 01 20:15:01 -0800 2000"
+  ruby_version_is "1.9" do
+    it "creates a time based on given values, interpreted in the local time zone" do
+      with_timezone("PST", -8) do
+        Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "2000-01-01 20:15:01 -0800"
+      end
     end
+
+    it "creates a time based on given C-style gmtime arguments, interpreted in the local time zone" do
+      with_timezone("PST", -8) do
+        time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
+        time.inspect.should == "2000-01-01 20:15:01 -0800"
+      end
+    end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/shared/time_params.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/shared/time_params.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/shared/time_params.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -25,42 +25,71 @@
     Time.send(@method, 1.0, 15.0, 20.0, 1.0, 1.0, 2000.0, :ignored, :ignored, :ignored, :ignored).should == Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored)
   end
 
-  it "should accept various year ranges" do
-    Time.send(@method, 1901, 12, 31, 23, 59, 59, 0).wday.should == 2
-    Time.send(@method, 2037, 12, 31, 23, 59, 59, 0).wday.should == 4
+  ruby_version_is ""..."1.9.1" do
+    it "should accept various year ranges" do
+      Time.send(@method, 1901, 12, 31, 23, 59, 59, 0).wday.should == 2
+      Time.send(@method, 2037, 12, 31, 23, 59, 59, 0).wday.should == 4
 
-    platform_is :wordsize => 32 do
-      lambda { Time.send(@method, 1900, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
-      lambda { Time.send(@method, 2038, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
-    end
+      platform_is :wordsize => 32 do
+        lambda { Time.send(@method, 1900, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
+        lambda { Time.send(@method, 2038, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
+      end
 
-    platform_is :wordsize => 64 do
-      Time.send(@method, 1900, 12, 31, 23, 59, 59, 0).wday.should == 1
-      Time.send(@method, 2038, 12, 31, 23, 59, 59, 0).wday.should == 5
+      platform_is :wordsize => 64 do
+        Time.send(@method, 1900, 12, 31, 23, 59, 59, 0).wday.should == 1
+        Time.send(@method, 2038, 12, 31, 23, 59, 59, 0).wday.should == 5
+      end
+    end   
+
+    it "raises an ArgumentError for out of range values" do
+      # year-based Time.local(year (, month, day, hour, min, sec, usec))
+      # Year range only fails on 32 bit archs
+      platform_is :wordsize => 32 do
+        lambda { Time.send(@method, 1111, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # year
+      end
+      lambda { Time.send(@method, 2008, 13, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
+      lambda { Time.send(@method, 2008, 12, 32, 23, 59, 59, 0) }.should raise_error(ArgumentError) # day
+      lambda { Time.send(@method, 2008, 12, 31, 25, 59, 59, 0) }.should raise_error(ArgumentError) # hour
+      lambda { Time.send(@method, 2008, 12, 31, 23, 61, 59, 0) }.should raise_error(ArgumentError) # min
+      lambda { Time.send(@method, 2008, 12, 31, 23, 59, 61, 0) }.should raise_error(ArgumentError) # sec
+
+      # second based Time.local(sec, min, hour, day, month, year, wday, yday, isdst, tz)
+      lambda { Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # sec
+      lambda { Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # min
+      lambda { Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # hour
+      lambda { Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # day
+      lambda { Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # month
+      # Year range only fails on 32 bit archs
+      platform_is :wordsize => 32 do
+        lambda { Time.send(@method, 59, 59, 23, 31, 12, 1111, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # year
+      end
     end
   end
 
-  it "throws ArgumentError for out of range values" do
-    # year-based Time.local(year (, month, day, hour, min, sec, usec))
-    # Year range only fails on 32 bit archs
-    platform_is :wordsize => 32 do
-      lambda { Time.send(@method, 1111, 12, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # year
-    end
-    lambda { Time.send(@method, 2008, 13, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
-    lambda { Time.send(@method, 2008, 12, 32, 23, 59, 59, 0) }.should raise_error(ArgumentError) # day
-    lambda { Time.send(@method, 2008, 12, 31, 25, 59, 59, 0) }.should raise_error(ArgumentError) # hour
-    lambda { Time.send(@method, 2008, 12, 31, 23, 61, 59, 0) }.should raise_error(ArgumentError) # min
-    lambda { Time.send(@method, 2008, 12, 31, 23, 59, 61, 0) }.should raise_error(ArgumentError) # sec
+  # MRI 1.9.2 relaxes 1.8's restriction's on allowed years.
+  ruby_version_is "1.9.2" do
+    it "should accept various year ranges" do
+      Time.send(@method, 1801, 12, 31, 23, 59, 59, 0).wday.should == 4
+      Time.send(@method, 3000, 12, 31, 23, 59, 59, 0).wday.should == 3
+    end  
 
-    # second based Time.local(sec, min, hour, day, month, year, wday, yday, isdst, tz)
-    lambda { Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # sec
-    lambda { Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # min
-    lambda { Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # hour
-    lambda { Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # day
-    lambda { Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # month
-    # Year range only fails on 32 bit archs
-    platform_is :wordsize => 32 do
-      lambda { Time.send(@method, 59, 59, 23, 31, 12, 1111, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # year
+    it "raises an ArgumentError for out of range values" do
+      # year-based Time.local(year (, month, day, hour, min, sec, usec))
+      # Year range only fails on 32 bit archs
+      platform_is :wordsize => 32 do
+      end
+      lambda { Time.send(@method, 2008, 13, 31, 23, 59, 59, 0) }.should raise_error(ArgumentError) # mon
+      lambda { Time.send(@method, 2008, 12, 32, 23, 59, 59, 0) }.should raise_error(ArgumentError) # day
+      lambda { Time.send(@method, 2008, 12, 31, 25, 59, 59, 0) }.should raise_error(ArgumentError) # hour
+      lambda { Time.send(@method, 2008, 12, 31, 23, 61, 59, 0) }.should raise_error(ArgumentError) # min
+      lambda { Time.send(@method, 2008, 12, 31, 23, 59, 61, 0) }.should raise_error(ArgumentError) # sec
+
+      # second based Time.local(sec, min, hour, day, month, year, wday, yday, isdst, tz)
+      lambda { Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # sec
+      lambda { Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # min
+      lambda { Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # hour
+      lambda { Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # day
+      lambda { Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored) }.should raise_error(ArgumentError) # month
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,16 +1,8 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/methods'
+require File.dirname(__FILE__) + '/../../shared/process/times'
 
 describe 'Time.times' do
   ruby_version_is "" ... "1.9" do
-    it "is an obsolete method" do
-      lambda { Time.times }.should complain(/obsolete.*use.*Process::times/)
-    end
+    it_behaves_like :process_times, :times, Time
   end
-
-  ruby_version_is "1.9" do
-    it "is no longer exist" do
-      lambda { Time.times }.should raise_error(NoMethodError)
-    end
-  end
 end

Copied: MacRuby/branches/experimental/spec/frozen/shared/process/times.rb (from rev 1777, MacRuby/branches/experimental/spec/frozen/core/process/times_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/process/times.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/process/times.rb	2009-06-06 13:09:07 UTC (rev 1778)
@@ -0,0 +1,26 @@
+describe :process_times, :shared => true do
+  it "returns a Struct::Tms" do
+    @object.send(@method).class.should == Struct::Tms
+  end
+
+  it "returns current cpu times" do
+
+    t = @object.send @method
+
+    # Do busy work for a wall-clock interval.
+    start = Time.now
+    1 until (Time.now - start) > 0.5
+
+    # Ensure times is larger. NOTE that there is no 
+    # guarantee of an upper bound since anything may be 
+    # happening at the OS level, so we ONLY check that at 
+    # least an interval has elapsed. Also, we are assuming 
+    # there is a correlation between wall clock time and 
+    # process time. In practice, there is an observed 
+    # discrepancy often 10% or greater. In other words, 
+    # this is a very fuzzy test.
+    t2 = @object.send @method
+    diff = (t2.utime + t2.stime) - (t.utime + t.stime)
+    diff.should > 0
+  end
+end

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/hash/reject_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/hash/reject_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/hash/reject_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,5 +0,0 @@
-fails:Hash#reject! raises a TypeError if called on a frozen instance
-fails:Hash#reject returns an Enumerator if called on a non-empty hash without a block
-fails:Hash#reject returns an Enumerator if called on an empty hash without a block
-fails:Hash#reject! returns an Enumerator when called on a non-empty hash without a block
-fails:Hash#reject! returns an Enumerator when called on an empty hash without a block

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/at_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/at_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/at_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +0,0 @@
-fails:Time.at converts to time object

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/gm_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/gm_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/gm_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +0,0 @@
-fails:Time.gm creates a time based on given values, interpreted as UTC (GMT)
-fails:Time.gm creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/hash_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/hash_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/hash_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +0,0 @@
-fails:Time#hash returns a unique integer for each time

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/local_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/local_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/local_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +0,0 @@
-fails:Time.local creates a time based on given values, interpreted in the local time zone
-fails:Time.local creates a time based on given C-style gmtime arguments, interpreted in the local time zone

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/mktime_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/mktime_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/mktime_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +0,0 @@
-fails:Time.mktime creates a time based on given values, interpreted in the local time zone
-fails:Time.mktime creates a time based on given C-style gmtime arguments, interpreted in the local time zone

Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/utc_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/utc_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/time/utc_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +0,0 @@
-fails:Time.utc creates a time based on given values, interpreted as UTC (GMT)
-fails:Time.utc creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/initialize_copy_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/initialize_copy_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/initialize_copy_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,3 +1,3 @@
 fails:Hash#initialize_copy is private
 fails:Hash#initialize_copy does not transfer default values
-fails:Hash#initialize_copy raises a TypeError if called on a frozen instance
+fails:Hash#initialize_copy raises a RuntimeError if called on a frozen instance

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/merge_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/merge_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/merge_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,3 +1,4 @@
 fails:Hash#merge returns subclass instance for subclasses
 fails:Hash#merge processes entries with same order as each()
-fails:Hash#merge! raises a TypeError if called on a non-empty, frozen instance
+fails:Hash#merge! raises a RuntimeError if called on a non-empty, frozen instance
+fails:Hash#merge! raises a RuntimeError if called on a frozen instance
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/replace_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/replace_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/replace_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +1,2 @@
 fails:Hash#replace does not transfer default values
-fails:Hash#replace raises a TypeError if called on a frozen instance
+fails:Hash#replace raises a RuntimeError if called on a frozen instance

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/update_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/update_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/hash/update_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +1 @@
-fails:Hash#update raises a TypeError if called on a non-empty, frozen instance
+fails:Hash#update raises a RuntimeError if called on a frozen instance

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Float_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Float_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Float_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +1,28 @@
+critical:Kernel.Float raises an ArgumentError if e is the trailing character
+critical:Kernel.Float raises an ArgumentError if e is the leading character
+critical:Kernel.Float raises an exception if a space is embedded on either side of the 'e'
+critical:Kernel.Float raises an exception if there's a leading _ on either side of the 'e'
+critical:Kernel.Float raises an exception if there's a trailing _ on either side of the 'e'
+critical:Kernel.Float raises an ArgumentError if there's a decimal point on the right side of the 'e'
+critical:Kernel.Float raises an ArgumentError if E is the trailing character
+critical:Kernel.Float raises an ArgumentError if E is the leading character
+critical:Kernel.Float raises an exception if a space is embedded on either side of the 'E'
+critical:Kernel.Float raises an exception if there's a leading _ on either side of the 'E'
+critical:Kernel.Float raises an exception if there's a trailing _ on either side of the 'E'
+critical:Kernel.Float raises an ArgumentError if there's a decimal point on the right side of the 'E'
+critical:Kernel#Float raises an ArgumentError if e is the trailing character
+critical:Kernel#Float raises an ArgumentError if e is the leading character
+critical:Kernel#Float raises an exception if a space is embedded on either side of the 'e'
+critical:Kernel#Float raises an exception if there's a leading _ on either side of the 'e'
+critical:Kernel#Float raises an exception if there's a trailing _ on either side of the 'e'
+critical:Kernel#Float raises an ArgumentError if there's a decimal point on the right side of the 'e'
+critical:Kernel#Float raises an ArgumentError if E is the trailing character
+critical:Kernel#Float raises an ArgumentError if E is the leading character
+critical:Kernel#Float raises an exception if a space is embedded on either side of the 'E'
+critical:Kernel#Float raises an exception if there's a leading _ on either side of the 'E'
+critical:Kernel#Float raises an exception if there's a trailing _ on either side of the 'E'
+critical:Kernel#Float raises an ArgumentError if there's a decimal point on the right side of the 'E'
 fails:Kernel.Float is a private method
+fails:Kernel#Float is a private method
+fails:Kernel.Float raises a TypeError if #to_f is not provided
+fails:Kernel#Float raises a TypeError if #to_f is not provided

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Integer_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Integer_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/Integer_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +1,14 @@
+critical:Kernel.Integer raises an ArgumentError if the number cannot be parsed as hex
+critical:Kernel.Integer raises an ArgumentError if the number cannot be parsed as binary
+critical:Kernel.Integer raises an ArgumentError if the number cannot be parsed as octal
+critical:Kernel.Integer raises an ArgumentError if the number cannot be parsed as decimal
+critical:Kernel#Integer raises an ArgumentError if the number cannot be parsed as hex
+critical:Kernel#Integer raises an ArgumentError if the number cannot be parsed as binary
+critical:Kernel#Integer raises an ArgumentError if the number cannot be parsed as octal
+critical:Kernel#Integer raises an ArgumentError if the number cannot be parsed as decimal
 fails:Kernel.Integer is a private method
+fails:Kernel#Integer is a private method
+fails:Kernel.Integer calls to_i on Rationals
+fails:Kernel.Integer raises an ArgumentError if the String ends with a null byte
+fails:Kernel#Integer calls to_i on Rationals
+fails:Kernel#Integer raises an ArgumentError if the String ends with a null byte
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/String_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/String_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/String_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +1,8 @@
 fails:Kernel.String is a private method
 fails:Kernel.String converts the given argument to a String by calling #to_s
+fails:Kernel.String raises a TypeError if #to_s is not provided
+fails:Kernel.String tries to call the to_s method if respond_to? returns true for to_s
+fails:Kernel#String converts the given argument to a String by calling #to_s
+fails:Kernel#String raises a TypeError if #to_s is not provided
+fails:Kernel#String tries to call the to_s method if respond_to? returns true for to_s
+fails:Kernel#String is a private method
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/block_given_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/block_given_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/block_given_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +1,4 @@
 fails:Kernel#block_given? is a private method
+fails:Kernel#block_given? returns false when a method defined by define_method is called with a block
+fails:Kernel.block_given? returns false when a method defined by define_method is called with a block
+fails:self.send(:block_given?) returns false when a method defined by define_method is called with a block
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/numeric/coerce_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/numeric/coerce_tags.txt	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/numeric/coerce_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1,2 +1,4 @@
 critical:Numeric#coerce returns [other.to_f, self.to_f] if self and other are instances of different classes
 fails:Numeric#coerce raises a TypeError when passed a Symbol
+fails:Numeric#coerce calls #to_f to convert other if self responds to #to_f
+fails:Numeric#coerce raises a TypeError when passed a boolean
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/time/minus_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/time/minus_tags.txt	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/time/minus_tags.txt	2009-06-06 13:09:07 UTC (rev 1778)
@@ -0,0 +1 @@
+fails:Time#- raises TypeError on argument that can't be coerced into Float
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream	2009-06-06 10:45:50 UTC (rev 1777)
+++ MacRuby/branches/experimental/spec/frozen/upstream	2009-06-06 13:09:07 UTC (rev 1778)
@@ -1 +1 @@
-9153e76040d7393521a4980f8b285ecb11e0df91
\ No newline at end of file
+dbbd5f2ad63092b640b7b211a25dd913aee36422
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090606/2aa4bb74/attachment-0001.html>


More information about the macruby-changes mailing list