[macruby-changes] [2136] MacRuby/branches/experimental/spec/frozen/library/date

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 1 20:09:49 PDT 2009


Revision: 2136
          http://trac.macosforge.org/projects/ruby/changeset/2136
Author:   lsansonetti at apple.com
Date:     2009-08-01 20:09:49 -0700 (Sat, 01 Aug 2009)
Log Message:
-----------
ported to 1.9

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/library/date/civil_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/commercial_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/julian_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/neww_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/ordinal_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/parse_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb
    MacRuby/branches/experimental/spec/frozen/library/date/shared/commercial.rb
    MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_eu.rb
    MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_us.rb

Modified: MacRuby/branches/experimental/spec/frozen/library/date/civil_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/civil_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/civil_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -10,19 +10,39 @@
 
 describe "Date#valid_civil?" do
 
-  it "should be able to determine if a date is valid" do
-    Date.valid_civil?(1582, 10, 14).should == nil
-    Date.valid_civil?(1582, 10, 15).should == Date.civil(1582, 10, 15).jd
-    Date.valid_civil?(1582, 10, 14, Date::ENGLAND).should_not == nil
-    Date.valid_civil?(1582, 10, 14, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND).jd
+  ruby_version_is '' ... '1.9' do
+    it "should be able to determine if a date is valid" do
+      Date.valid_civil?(1582, 10, 14).should == nil
+      Date.valid_civil?(1582, 10, 15).should == Date.civil(1582, 10, 15).jd
+      Date.valid_civil?(1582, 10, 14, Date::ENGLAND).should_not == nil
+      Date.valid_civil?(1582, 10, 14, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND).jd
+    end
   end
+
+  ruby_version_is '1.9' do
+    it "should be able to determine if a date is valid" do
+      Date.valid_civil?(1582, 10, 14).should == false
+      Date.valid_civil?(1582, 10, 15).should == true
+      Date.valid_civil?(1582, 10, 14, Date::ENGLAND).should == true
+    end
+  end
   
-  it "should be able to handle negative months and days" do
-    Date.valid_civil?(1582, -3, -18).should == nil
-    Date.valid_civil?(1582, -3, -17).should == Date.civil(1582, 10, 15).jd
-    
-    Date.valid_civil?(2007, -11, -10).should == Date.civil(2007, 2, 19).jd
-    Date.valid_civil?(2008, -11, -10).should == Date.civil(2008, 2, 20).jd
+  ruby_version_is '' ... '1.9' do
+    it "should be able to handle negative months and days" do
+      Date.valid_civil?(1582, -3, -18).should == nil
+      Date.valid_civil?(1582, -3, -17).should == Date.civil(1582, 10, 15).jd
+      
+      Date.valid_civil?(2007, -11, -10).should == Date.civil(2007, 2, 19).jd
+      Date.valid_civil?(2008, -11, -10).should == Date.civil(2008, 2, 20).jd
+    end
   end
 
+  ruby_version_is '1.9' do
+      Date.valid_civil?(1582, -3, -18).should == true
+      Date.valid_civil?(1582, -3, -17).should == true
+      
+      Date.valid_civil?(2007, -11, -10).should == true
+      Date.valid_civil?(2008, -11, -10).should == true
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/commercial_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/commercial_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/commercial_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -10,20 +10,39 @@
 
 describe "Date#valid_commercial?" do
 
-  it "should be able to determine if the date is a valid commercial date" do
-    Date.valid_commercial?(1582, 41, 4).should == nil
-    Date.valid_commercial?(1582, 41, 5).should == Date.civil(1582, 10, 15).jd
-    # valid_commercial? can't handle dates before the Gregorian calendar
-    Date.valid_commercial?(1582, 41, 4, Date::ENGLAND).should == nil
-    Date.valid_commercial?(1752, 37, 4, Date::ENGLAND).should == Date.civil(1752, 9, 14, Date::ENGLAND).jd
+  ruby_version_is "" ... "1.9" do
+    it "should be able to determine if the date is a valid commercial date" do
+      Date.valid_commercial?(1582, 41, 4).should == nil
+      Date.valid_commercial?(1582, 41, 5).should == Date.civil(1582, 10, 15).jd
+      # valid_commercial? can't handle dates before the Gregorian calendar
+      Date.valid_commercial?(1582, 41, 4, Date::ENGLAND).should == nil
+      Date.valid_commercial?(1752, 37, 4, Date::ENGLAND).should == Date.civil(1752, 9, 14, Date::ENGLAND).jd
+    end
+
+    it "should be able to handle negative week and day numbers" do
+      Date.valid_commercial?(1582, -12, -4).should == nil
+      Date.valid_commercial?(1582, -12, -3).should == Date.civil(1582, 10, 15).jd
+      
+      Date.valid_commercial?(2007, -44, -2).should == Date.civil(2007, 3, 3).jd
+      Date.valid_commercial?(2008, -44, -2).should == Date.civil(2008, 3, 1).jd
+    end
   end
 
-  it "should be able to handle negative week and day numbers" do
-    Date.valid_commercial?(1582, -12, -4).should == nil
-    Date.valid_commercial?(1582, -12, -3).should == Date.civil(1582, 10, 15).jd
-    
-    Date.valid_commercial?(2007, -44, -2).should == Date.civil(2007, 3, 3).jd
-    Date.valid_commercial?(2008, -44, -2).should == Date.civil(2008, 3, 1).jd
+  ruby_version_is "1.9" do
+    it "should be able to determine if the date is a valid commercial date" do
+      Date.valid_commercial?(1582, 41, 4).should == true
+      Date.valid_commercial?(1582, 41, 5).should == true
+      Date.valid_commercial?(1582, 41, 4, Date::ENGLAND).should == true
+      Date.valid_commercial?(1752, 37, 4, Date::ENGLAND).should == true
+    end
+
+    it "should be able to handle negative week and day numbers" do
+      Date.valid_commercial?(1582, -12, -4).should == true
+      Date.valid_commercial?(1582, -12, -3).should == true
+      Date.valid_commercial?(2007, -44, -2).should == true
+      Date.valid_commercial?(2008, -44, -2).should == true
+    end
   end
 
-end
\ No newline at end of file
+
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/julian_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/julian_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/julian_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -41,12 +41,22 @@
 
 describe "Date#valid_jd?" do
 
-  it "should be able to determine if a day number is a valid Julian day number, true for all numbers" do
-    # This might need to check the type of the jd parameter. Date.valid_jd?(:number) is of course
-    # bogus but returns itself with the current implementation
-    Date.valid_jd?(-100).should == -100
-    Date.valid_jd?(0).should    ==    0
-    Date.valid_jd?(100).should  ==  100
+  ruby_version_is "" ... "1.9" do
+    it "should be able to determine if a day number is a valid Julian day number, true for all numbers" do
+      # This might need to check the type of the jd parameter. Date.valid_jd?(:number) is of course
+      # bogus but returns itself with the current implementation
+      Date.valid_jd?(-100).should == -100
+      Date.valid_jd?(0).should    ==    0
+      Date.valid_jd?(100).should  ==  100
+    end
   end
 
-end
\ No newline at end of file
+  ruby_version_is "1.9" do
+    it "should be able to determine if a day number is a valid Julian day number, true for all numbers" do
+      Date.valid_jd?(-100).should == true
+      Date.valid_jd?(0).should    == true
+      Date.valid_jd?(100).should  == true
+    end
+  end
+
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/neww_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/neww_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/neww_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -2,8 +2,12 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/commercial'
 
-describe "Date#neww" do
+ruby_version_is "" ... "1.9" do
 
-  it_behaves_like(:date_commercial, :neww)
+  describe "Date#neww" do
+  
+    it_behaves_like(:date_commercial, :neww)
+  
+  end
 
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/ordinal_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/ordinal_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/ordinal_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -4,26 +4,50 @@
 
 describe "Date#ordinal" do
 
-  it "should be able to construct a Date object from an ordinal date" do
-    lambda { Date.ordinal(1582, 287) }.should raise_error(ArgumentError)
-    Date.ordinal(1582, 288).should == Date.civil(1582, 10, 15)
-    Date.ordinal(1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND)
+  ruby_version_is "" ... "1.9" do
+    it "should be able to construct a Date object from an ordinal date" do
+      lambda { Date.ordinal(1582, 287) }.should raise_error(ArgumentError)
+      Date.ordinal(1582, 288).should == Date.civil(1582, 10, 15)
+      Date.ordinal(1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND)
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "should be able to construct a Date object from an ordinal date" do
+      Date.ordinal(1582, 288).should == Date.civil(1582, 10, 25)
+      Date.ordinal(1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND)
+    end
+  end
+
 end
 
 describe "Date#valid_ordinal?" do
 
-  it "should be able to determine if the date is a valid ordinal date" do
-    Date.valid_ordinal?(1582, 287).should == nil
-    Date.valid_ordinal?(1582, 288).should == Date.civil(1582, 10, 15).jd
-    Date.valid_ordinal?(1582, 287, Date::ENGLAND).should_not == nil
-    Date.valid_ordinal?(1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND).jd
+  ruby_version_is "" ... "1.9" do
+    it "should be able to determine if the date is a valid ordinal date" do
+      Date.valid_ordinal?(1582, 287).should == nil
+      Date.valid_ordinal?(1582, 288).should == Date.civil(1582, 10, 15).jd
+      Date.valid_ordinal?(1582, 287, Date::ENGLAND).should_not == nil
+      Date.valid_ordinal?(1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND).jd
+    end
+  
+    it "should be able to handle negative day numbers" do
+      Date.valid_ordinal?(1582, -79).should == nil
+      Date.valid_ordinal?(2007, -100).should == Date.valid_ordinal?(2007, 266)
+    end
   end
 
-  it "should be able to handle negative day numbers" do
-    Date.valid_ordinal?(1582, -79).should == nil
-    Date.valid_ordinal?(2007, -100).should == Date.valid_ordinal?(2007, 266)
+  ruby_version_is "1.9" do
+    it "should be able to determine if the date is a valid ordinal date" do
+      Date.valid_ordinal?(1582, 287).should == true 
+      Date.valid_ordinal?(1582, 288).should == true
+      Date.valid_ordinal?(1582, 287, Date::ENGLAND).should == true
+      Date.valid_ordinal?(1582, 287, Date::ENGLAND).should == true
+    end
+  
+    it "should be able to handle negative day numbers" do
+      Date.valid_ordinal?(1582, -79).should == true
+      Date.valid_ordinal?(2007, -100).should == true
+    end
   end
-
-end
\ No newline at end of file
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/parse_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/parse_spec.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/parse_spec.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -45,16 +45,34 @@
     d.should == Date.civil(Date.today.year, 11, 8)
   end
 
-  it "can handle YYDDD as year and day number" do
-    d = Date.parse("10100")
-    d.should == Date.civil(10, 4, 10)
+  ruby_version_is "" ... "1.9" do
+    it "can handle YYDDD as year and day number" do
+      d = Date.parse("10100")
+      d.should == Date.civil(10, 4, 10)
+    end
   end
 
-  it "can handle YYMMDD as year month and day" do
-    d = Date.parse("201023")
-    d.should == Date.civil(20, 10, 23)
+  ruby_version_is "1.9" do
+    it "can handle YYDDD as year and day number" do
+      d = Date.parse("10100")
+      d.should == Date.civil(2010, 4, 10)
+    end
   end
 
+  ruby_version_is "" ... "1.9" do
+    it "can handle YYMMDD as year month and day" do
+      d = Date.parse("201023")
+      d.should == Date.civil(20, 10, 23)
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "can handle YYMMDD as year month and day" do
+      d = Date.parse("201023")
+      d.should == Date.civil(2020, 10, 23)
+    end
+  end
+
   it "can handle YYYYDDD as year and day number" do
     d = Date.parse("1910100")
     d.should == Date.civil(1910, 4, 10)
@@ -132,13 +150,24 @@
       d.day.should   == 10
     end
 
-    it "parses a YY.MM.DD string into a Date object" do
-      d = Date.parse("10.01.07")
-      d.year.should  == 10
-      d.month.should == 1
-      d.day.should   == 7
+    ruby_version_is "" ... "1.9" do
+      it "parses a YY.MM.DD string into a Date object" do
+        d = Date.parse("10.01.07")
+        d.year.should  == 10
+        d.month.should == 1
+        d.day.should   == 7
+      end
     end
 
+    ruby_version_is "1.9" do
+      it "parses a YY.MM.DD string into a Date object" do
+        d = Date.parse("10.01.07")
+        d.year.should  == 2010
+        d.month.should == 1
+        d.day.should   == 7
+      end
+    end
+
     it "parses a YY.MM.DD string into a Date object using the year digits as 20XX" do
       d = Date.parse("10.01.07", true)
       d.year.should  == 2010

Modified: MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -64,12 +64,15 @@
     lambda { Date.send(@method, 2000, 2, 2, r.jd) }.should raise_error(ArgumentError)
   end
 
-  ruby_bug "1589", "1.8.6.368" do
-    require 'bigdecimal'
-    require 'bigdecimal/util'
-    it "doesn't blow up (illegal instruction and segfault, respectively) when fed huge numbers" do
-      ["9E69999999","1"*10000000].each do |dv|
-        lambda { Date.new(2002,10,dv.to_d) }.should raise_error(BigDecimal::FloatDomainError)
+  # bigdecimal is not implemented yet in macruby
+  not_compliant_on :macruby do
+    ruby_bug "1589", "1.8.6.368" do
+      require 'bigdecimal'
+      require 'bigdecimal/util'
+      it "doesn't blow up (illegal instruction and segfault, respectively) when fed huge numbers" do
+        ["9E69999999","1"*10000000].each do |dv|
+          lambda { Date.new(2002,10,dv.to_d) }.should raise_error(BigDecimal::FloatDomainError)
+        end
       end
     end
   end

Modified: MacRuby/branches/experimental/spec/frozen/library/date/shared/commercial.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/shared/commercial.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/shared/commercial.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -1,17 +1,36 @@
 describe :date_commercial, :shared => true do
-  it "creates a Date for the day of Julian calendar reform in Italy by default" do
-    d = Date.send(@method)
-    d.year.should  == 1582
-    d.month.should == 10
-    d.day.should   == 15
+  ruby_version_is "" ... "1.9" do
+    it "creates a Date for the day of Julian calendar reform in Italy by default" do
+      d = Date.send(@method)
+      d.year.should  == 1582
+      d.month.should == 10
+      d.day.should   == 15
+    end
+
+    it "Creates a Date for the friday in the year and week given" do
+      d = Date.send(@method, 2000, 1)
+      d.year.should  == 2000
+      d.month.should == 1
+      d.day.should   == 7
+      d.cwday.should == 5
+    end
   end
 
-  it "Creates a Date for the friday in the year and week given" do
-    d = Date.send(@method, 2000, 1)
-    d.year.should  == 2000
-    d.month.should == 1
-    d.day.should   == 7
-    d.cwday.should == 5
+  ruby_version_is "1.9" do
+    it "creates a Date for the day of Julian calendar reform in Italy by default" do
+      d = Date.send(@method)
+      d.year.should  == -4712
+      d.month.should == 1
+      d.day.should   == 1
+    end
+
+    it "Creates a Date for the monday in the year and week given" do
+      d = Date.send(@method, 2000, 1)
+      d.year.should  == 2000
+      d.month.should == 1
+      d.day.should   == 3
+      d.cwday.should == 1
+    end
   end
 
   it "Creates a Date for the correct day given the year, week and day number" do

Modified: MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_eu.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_eu.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_eu.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -14,13 +14,24 @@
     d.day.should   == 10
   end
 
-  it "can parse a MM-DD-YY string into a Date object" do
-    d = Date.parse("10#{@sep}01#{@sep}07")
-    d.year.should  == 10
-    d.month.should == 1
-    d.day.should   == 7
+  ruby_version_is "" ... "1.9" do
+    it "can parse a MM-DD-YY string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}07")
+      d.year.should  == 10
+      d.month.should == 1
+      d.day.should   == 7
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "can parse a MM-DD-YY string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}07")
+      d.year.should  == 2010
+      d.month.should == 1
+      d.day.should   == 7
+    end
+  end
+
   it "can parse a MM-DD-YY string into a Date object using the year digits as 20XX" do
     d = Date.parse("10#{@sep}01#{@sep}07", true)
     d.year.should  == 2010

Modified: MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_us.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_us.rb	2009-08-02 03:09:26 UTC (rev 2135)
+++ MacRuby/branches/experimental/spec/frozen/library/date/shared/parse_us.rb	2009-08-02 03:09:49 UTC (rev 2136)
@@ -6,24 +6,42 @@
     d.day.should   == 1
   end
 
-  it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
-    d = Date.parse("10#{@sep}01#{@sep}2007")
-    d.year.should  == 2007
-    d.month.should == 10
-    d.day.should   == 1
-  end
+  ruby_version_is "" ... "1.9" do
+    it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}2007")
+      d.year.should  == 2007
+      d.month.should == 10
+      d.day.should   == 1
+    end
 
-  it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
-    d = Date.parse("10#{@sep}01#{@sep}07")
-    d.year.should  == 7
-    d.month.should == 10
-    d.day.should   == 1
+    it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}07")
+      d.year.should  == 7
+      d.month.should == 10
+      d.day.should   == 1
+    end
+
+    it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
+      d = Date.parse("10#{@sep}01#{@sep}07", true)
+      d.year.should  == 2007
+      d.month.should == 10
+      d.day.should   == 1
+    end
   end
 
-  it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
-    d = Date.parse("10#{@sep}01#{@sep}07", true)
-    d.year.should  == 2007
-    d.month.should == 10
-    d.day.should   == 1
+  ruby_version_is "1.9" do
+    it "parses a DD#{@sep}MM#{@sep}YYYY string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}2007")
+      d.year.should  == 2007
+      d.month.should == 1
+      d.day.should   == 10
+    end
+
+    it "parses a YY#{@sep}MM#{@sep}DD string into a Date object" do
+      d = Date.parse("10#{@sep}01#{@sep}07")
+      d.year.should  == 2010
+      d.month.should == 1
+      d.day.should   == 7
+    end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090801/b9ff1f4e/attachment-0001.html>


More information about the macruby-changes mailing list