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

ruby-changes:55193

From: nobu <ko1@a...>
Date: Mon, 1 Apr 2019 14:58:39 +0900 (JST)
Subject: [ruby-changes:55193] nobu:r67400 (trunk): Added tests for end of Heisei

nobu	2019-04-01 14:58:31 +0900 (Mon, 01 Apr 2019)

  New Revision: 67400

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67400

  Log:
    Added tests for end of Heisei

  Modified files:
    trunk/test/date/test_date_parse.rb
    trunk/test/date/test_date_strftime.rb
Index: test/date/test_date_parse.rb
===================================================================
--- test/date/test_date_parse.rb	(revision 67399)
+++ test/date/test_date_parse.rb	(revision 67400)
@@ -121,6 +121,8 @@ class TestDateParse < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L121
      [['S40.05.23T23:55:21-09:00',false],[1965,5,23,23,55,21,'-09:00',-9*3600,nil], __LINE__],
      [['H11.05.23 23:55:21Z',false],[1999,5,23,23,55,21,'Z',0,nil], __LINE__],
      [['H11.05.23T23:55:21Z',false],[1999,5,23,23,55,21,'Z',0,nil], __LINE__],
+     [['H31.04.30 23:55:21Z',false],[2019,4,30,23,55,21,'Z',0,nil], __LINE__],
+     [['H31.04.30T23:55:21Z',false],[2019,4,30,23,55,21,'Z',0,nil], __LINE__],
 
      # ofx date
      [['19990523235521',false],[1999,5,23,23,55,21,nil,nil,nil], __LINE__],
@@ -984,6 +986,12 @@ class TestDateParse < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L986
     h = Date._jisx0301('S63.02.03')
     assert_equal([1988, 2, 3, nil, nil, nil, nil],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.04.30')
+    assert_equal([2019, 4, 30, nil, nil, nil, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.05.01')
+    assert_equal([2019, 5, 1, nil, nil, nil, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
 
     h = Date._jisx0301('H13.02.03T04:05:06')
     assert_equal([2001, 2, 3, 4, 5, 6, nil],
@@ -998,6 +1006,32 @@ class TestDateParse < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L1006
     assert_equal([2001, 2, 3, 4, 5, 6, 3600],
 		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
 
+    h = Date._jisx0301('H31.04.30T04:05:06')
+    assert_equal([2019, 4, 30, 4, 5, 6, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.04.30T04:05:06,07')
+    assert_equal([2019, 4, 30, 4, 5, 6, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.04.30T04:05:06Z')
+    assert_equal([2019, 4, 30, 4, 5, 6, 0],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.04.30T04:05:06.07+0100')
+    assert_equal([2019, 4, 30, 4, 5, 6, 3600],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
+    h = Date._jisx0301('H31.05.01T04:05:06')
+    assert_equal([2019, 5, 1, 4, 5, 6, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.05.01T04:05:06,07')
+    assert_equal([2019, 5, 1, 4, 5, 6, nil],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.05.01T04:05:06Z')
+    assert_equal([2019, 5, 1, 4, 5, 6, 0],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+    h = Date._jisx0301('H31.05.01T04:05:06.07+0100')
+    assert_equal([2019, 5, 1, 4, 5, 6, 3600],
+		 h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
+
     h = Date._jisx0301('')
     assert_equal({}, h)
   end
@@ -1083,9 +1117,25 @@ class TestDateParse < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L1117
     assert_equal(Date.new(2001,2,3), d)
     assert_equal(Date::ITALY + 10, d.start)
 
+    d = Date.jisx0301('H31.04.30', Date::ITALY + 10)
+    assert_equal(Date.new(2019,4,30), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = Date.jisx0301('H31.05.01', Date::ITALY + 10)
+    assert_equal(Date.new(2019,5,1), 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)
+
+    d = DateTime.jisx0301('H31.04.30T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2019,4,30,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
+
+    d = DateTime.jisx0301('H31.05.01T04:05:06+07:00', Date::ITALY + 10)
+    assert_equal(DateTime.new(2019,5,1,4,5,6,'+07:00'), d)
+    assert_equal(Date::ITALY + 10, d.start)
   end
 
   def test_given_string
@@ -1120,6 +1170,16 @@ class TestDateParse < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L1170
     s0 = s.dup
     assert_not_equal({}, Date._jisx0301(s))
     assert_equal(s0, s)
+
+    s = 'H31.04.30T04:05:06,07Z'
+    s0 = s.dup
+    assert_not_equal({}, Date._jisx0301(s))
+    assert_equal(s0, s)
+
+    s = 'H31.05.01T04:05:06,07Z'
+    s0 = s.dup
+    assert_not_equal({}, Date._jisx0301(s))
+    assert_equal(s0, s)
   end
 
 end
Index: test/date/test_date_strftime.rb
===================================================================
--- test/date/test_date_strftime.rb	(revision 67399)
+++ test/date/test_date_strftime.rb	(revision 67400)
@@ -406,6 +406,7 @@ class TestDateStrftime < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/date/test_date_strftime.rb#L406
     assert_equal('S64.01.07', Date.parse('1989-01-07').jisx0301)
     assert_equal('H01.01.08', Date.parse('1989-01-08').jisx0301)
     assert_equal('H18.09.01', Date.parse('2006-09-01').jisx0301)
+    assert_equal('H31.04.30', Date.parse('2019-04-30').jisx0301)
 
     %w(M06.01.01
        M45.07.29
@@ -414,7 +415,9 @@ class TestDateStrftime < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/date/test_date_strftime.rb#L415
        S01.12.25
        S64.01.07
        H01.01.08
-       H18.09.01).each do |s|
+       H18.09.01
+       H31.04.30
+    ).each do |s|
       assert_equal(s, Date.parse(s).jisx0301)
     end
 

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

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