[前][次][番号順一覧][スレッド一覧]

ruby-changes:20039

From: tadf <ko1@a...>
Date: Tue, 14 Jun 2011 22:56:34 +0900 (JST)
Subject: [ruby-changes:20039] tadf:r32086 (trunk): * test/date/test_*.rb: added tests.

tadf	2011-06-14 22:52:25 +0900 (Tue, 14 Jun 2011)

  New Revision: 32086

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32086

  Log:
    * test/date/test_*.rb: added tests.

  Modified files:
    trunk/ChangeLog
    trunk/test/date/test_date_parse.rb
    trunk/test/date/test_switch_hitter.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32085)
+++ ChangeLog	(revision 32086)
@@ -1,3 +1,7 @@
+Tue Jun 14 22:51:42 2011  Tadayoshi Funaba  <tadf@d...>
+
+	* test/date/test_*.rb: added tests.
+
 Tue Jun 14 22:09:58 2011  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c: renamed some functions.
Index: test/date/test_switch_hitter.rb
===================================================================
--- test/date/test_switch_hitter.rb	(revision 32085)
+++ test/date/test_switch_hitter.rb	(revision 32086)
@@ -348,11 +348,15 @@
   def test_marshal
     s = "\x04\bU:\tDate[\bU:\rRational[\ai\x03\xCF\xD3Ji\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA"
     d = Marshal.load(s)
-    assert_equal(Date.new(2001,2,3,Date::GREGORIAN), d)
+    assert_equal(Rational(4903887,2), d.ajd)
+    assert_equal(Rational(0,24), d.send(:offset))
+    assert_equal(Date::GREGORIAN, d.start)
 
     s = "\x04\bU:\rDateTime[\bU:\rRational[\al+\b\xC9\xB0\x81\xBD\x02\x00i\x02\xC0\x12U;\x06[\ai\bi\ro:\x13Date::Infinity\x06:\a@di\xFA"
     d = Marshal.load(s)
-    assert_equal(DateTime.new(2001,2,3,4,5,6,Rational(9,24),Date::GREGORIAN), d)
+    assert_equal(Rational(11769327817,4800), d.ajd)
+    assert_equal(Rational(9,24), d.offset)
+    assert_equal(Date::GREGORIAN, d.start)
   end
 
   def test_taint
Index: test/date/test_date_parse.rb
===================================================================
--- test/date/test_date_parse.rb	(revision 32085)
+++ test/date/test_date_parse.rb	(revision 32086)
@@ -980,16 +980,40 @@
   def test_iso8601
     assert_instance_of(Date, Date.iso8601)
     assert_instance_of(DateTime, DateTime.iso8601)
+
+    d = Date.iso8601('2001-02-03', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.iso8601('2001-02-03T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_rfc3339
     assert_instance_of(Date, Date.rfc3339)
     assert_instance_of(DateTime, DateTime.rfc3339)
+
+    d = Date.rfc3339('2001-02-03T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.rfc3339('2001-02-03T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_xmlschema
     assert_instance_of(Date, Date.xmlschema)
     assert_instance_of(DateTime, DateTime.xmlschema)
+
+    d = Date.xmlschema('2001-02-03', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.xmlschema('2001-02-03T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_rfc2822
@@ -997,16 +1021,40 @@
     assert_instance_of(DateTime, DateTime.rfc2822)
     assert_instance_of(Date, Date.rfc822)
     assert_instance_of(DateTime, DateTime.rfc822)
+
+    d = Date.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_httpdate
     assert_instance_of(Date, Date.httpdate)
     assert_instance_of(DateTime, DateTime.httpdate)
+
+    d = Date.httpdate('Sat, 03 Feb 2001 04:05:06 GMT', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+00:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_jisx0301
     assert_instance_of(Date, Date.jisx0301)
     assert_instance_of(DateTime, DateTime.jisx0301)
+
+    d = Date.jisx0301('H13.02.03', Date::ITALY + 10)
+    assert_equal(Date.new(2001,2,3), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.jisx0301('H13.02.03T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]