summaryrefslogtreecommitdiff
path: root/test/psych/test_scalar_scanner.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-17 19:06:07 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-17 19:06:07 -0800
commit1caecdca27675e80f9a762875fcf7ced81b2d9f1 (patch)
tree69ec509719627f6392956a70c3eb72a3bd78ed47 /test/psych/test_scalar_scanner.rb
parent40b1bc7cf72570f0645675b0e950de455566fe5e (diff)
downloadpsych-1caecdca27675e80f9a762875fcf7ced81b2d9f1.zip
* ext/psych/lib/psych/scalar_scanner.rb: Strings that look like dates
should be treated as strings and not dates. Fixes #42 * test/psych/test_scalar_scanner.rb: corresponding tests.
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 6599099..cf0dfff 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