summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_date_time.rb17
-rw-r--r--test/psych/visitors/test_to_ruby.rb12
-rw-r--r--test/psych/visitors/test_yaml_tree.rb2
3 files changed, 24 insertions, 7 deletions
diff --git a/test/psych/test_date_time.rb b/test/psych/test_date_time.rb
new file mode 100644
index 0000000..df66d14
--- /dev/null
+++ b/test/psych/test_date_time.rb
@@ -0,0 +1,17 @@
+require_relative 'helper'
+require 'date'
+
+module Psych
+ class TestDateTime < TestCase
+ def test_string_tag
+ dt = DateTime.now
+ yaml = Psych.dump dt
+ assert_match(/DateTime/, yaml)
+ end
+
+ def test_round_trip
+ dt = DateTime.now
+ assert_cycle dt
+ end
+ end
+end
diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb
index 8ad41db..1a4d319 100644
--- a/test/psych/visitors/test_to_ruby.rb
+++ b/test/psych/visitors/test_to_ruby.rb
@@ -113,25 +113,25 @@ description:
def test_time
now = Time.now
formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
- ".%06d %+.2d:00" % [now.usec, now.gmt_offset / 3600]
+ ".%09d %+.2d:00" % [now.nsec, now.gmt_offset / 3600]
- assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
end
def test_time_utc
now = Time.now.utc
formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
- ".%06dZ" % [now.usec]
+ ".%09dZ" % [now.nsec]
- assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
end
def test_time_utc_no_z
now = Time.now.utc
formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
- ".%06d" % [now.usec]
+ ".%09d" % [now.nsec]
- assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
end
def test_date
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 758cfae..ed89e78 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -54,7 +54,7 @@ module Psych
def test_time
t = Time.now
- assert_in_delta t, Psych.load(Psych.dump(t)), 0.000001
+ assert_equal t, Psych.load(Psych.dump(t))
end
def test_date