summaryrefslogtreecommitdiff
path: root/test/psych/test_scalar_scanner.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-18 03:05:02 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-18 03:05:02 +0000
commit9f688d53c2b5af5960d1e8d8fb09b26aa9d8b5f9 (patch)
treed1253df0647f4a5477ea22758e29c10c1137a0a9 /test/psych/test_scalar_scanner.rb
parent07fa1c9144aaf58414df1a27c06fb4a78683717d (diff)
* ext/psych/lib/psych/scalar_scanner.rb: Strings that look like dates
should be treated as strings and not dates. * test/psych/test_scalar_scanner.rb: corresponding tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_scalar_scanner.rb')
-rw-r--r--test/psych/test_scalar_scanner.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index 659909909e..cf0dfff6aa 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -1,4 +1,5 @@
require 'psych/helper'
+require 'date'
module Psych
class TestScalarScanner < TestCase
@@ -20,6 +21,27 @@ module Psych
end
end
+ def test_scan_bad_dates
+ x = '2000-15-01'
+ assert_equal x, @ss.tokenize(x)
+
+ x = '2000-10-51'
+ assert_equal x, @ss.tokenize(x)
+
+ x = '2000-10-32'
+ assert_equal x, @ss.tokenize(x)
+ end
+
+ def test_scan_good_edge_date
+ x = '2000-1-31'
+ assert_equal Date.strptime(x, '%Y-%m-%d'), @ss.tokenize(x)
+ end
+
+ def test_scan_bad_edge_date
+ x = '2000-11-31'
+ assert_equal x, @ss.tokenize(x)
+ end
+
def test_scan_date
date = '1980-12-16'
token = @ss.tokenize date