summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-25 22:12:46 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-25 22:12:46 +0000
commit2695d032e3fe0a342e586a03bd7f0eaffe52c5c1 (patch)
treefccc3320246fcd557ba186723f73a827e837b63d /test/psych
parentba1de001b19ee58a3dc6865dc6acfaa25c6506a1 (diff)
* ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose
whose format is (+/-)hhmm. Thanks Gonçalo Silva! * test/psych/test_scalar_scanner.rb: test for bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_scalar_scanner.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index 69dc127236..df54eb1eed 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -2,18 +2,6 @@ require_relative 'helper'
module Psych
class TestScalarScanner < TestCase
- def test_scan_time
- [ '2001-12-15T02:59:43.1Z',
- '2001-12-14t21:59:43.10-05:00',
- '2001-12-14 21:59:43.10 -5',
- '2010-01-06 00:00:00 -08:00',
- '2001-12-15 2:59:43.10',
- ].each do |time|
- ss = Psych::ScalarScanner.new
- assert_instance_of Time, ss.tokenize(time)
- end
- end
-
attr_reader :ss
def setup
@@ -21,6 +9,17 @@ module Psych
@ss = Psych::ScalarScanner.new
end
+ def test_scan_time
+ { '2001-12-15T02:59:43.1Z' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-14t21:59:43.10-05:00' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-14 21:59:43.10 -5' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-15 2:59:43.10' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2011-02-24 11:17:06 -0800' => Time.utc(2011, 02, 24, 19, 17, 06)
+ }.each do |time_str, time|
+ assert_equal time, @ss.tokenize(time_str)
+ end
+ end
+
def test_scan_date
date = '1980-12-16'
token = @ss.tokenize date