summaryrefslogtreecommitdiff
path: root/spec/ruby/core/time
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-01-28 20:47:48 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-01-28 20:47:48 +0100
commit809f0b8a1357f14f9645210d4812f4400c8d397e (patch)
tree7ce6192f94b1dc4b004798aa5d0c4d6bac02577f /spec/ruby/core/time
parented377cc9aaf1ccbede19ddc6c464f5fbf3cabc34 (diff)
Update to ruby/spec@f8a2d54
Diffstat (limited to 'spec/ruby/core/time')
-rw-r--r--spec/ruby/core/time/inspect_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/time/inspect_spec.rb b/spec/ruby/core/time/inspect_spec.rb
index 01e1dfdaa6..85133838e2 100644
--- a/spec/ruby/core/time/inspect_spec.rb
+++ b/spec/ruby/core/time/inspect_spec.rb
@@ -3,4 +3,19 @@ require_relative 'shared/inspect'
describe "Time#inspect" do
it_behaves_like :inspect, :inspect
+
+ ruby_version_is "2.7" do
+ it "preserves milliseconds" do
+ t = Time.utc(2007, 11, 1, 15, 25, 0, 123456)
+ t.inspect.should == "2007-11-01 15:25:00.123456 UTC"
+ end
+
+ it "formats nanoseconds as a Rational" do
+ t = Time.utc(2007, 11, 1, 15, 25, 0, 123456.789)
+ t.nsec.should == 123456789
+ t.strftime("%N").should == "123456789"
+
+ t.inspect.should == "2007-11-01 15:25:00 8483885939586761/68719476736000000 UTC"
+ end
+ end
end