Created
August 5, 2011 20:32
-
-
Save tenderlove/1128445 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# Run this with 1.9.2 or 1.9.3 | |
require 'psych' | |
require 'minitest/autorun' | |
require 'date' | |
class ZOMGTest < MiniTest::Unit::TestCase | |
# Quoted strings are assumed to be Strings | |
def test_json | |
json = <<EOF | |
{ | |
"date_a": "2011-07-22T09:54:44Z", | |
"city": "wroc\u0142aw", # after this the next date is not parsed anymore! | |
"date_b": "2011-07-22T09:54:44Z" | |
} | |
EOF | |
hash = Psych.load json | |
assert_equal "wrocław", hash['city'] | |
end | |
# Tagged string literals are typecast | |
def test_yaml | |
yaml = <<EOF | |
{ | |
"date_a": ! "2011-07-22T09:54:44Z", | |
"city": "wroc\u0142aw", # after this the next date is not parsed anymore! | |
"date_b": ! "2011-07-22T09:54:44Z" | |
} | |
EOF | |
hash = Psych.load yaml | |
assert_kind_of Time, hash['date_a'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment