Skip to content

Instantly share code, notes, and snippets.

@mame
Created February 16, 2010 17:14
Show Gist options
  • Save mame/305689 to your computer and use it in GitHub Desktop.
Save mame/305689 to your computer and use it in GitHub Desktop.
diff --git a/core/time/plus_spec.rb b/core/time/plus_spec.rb
index 712c035..1b5d179 100644
--- a/core/time/plus_spec.rb
+++ b/core/time/plus_spec.rb
@@ -10,12 +10,6 @@ describe "Time#+" do
(Time.at(1.1) + 0.9).should == Time.at(0.9) + 1.1
end
- it "understands negative additions" do
- t = Time.at(100) + -1.3
- t.usec.should == 700000
- t.to_i.should == 98
- end
-
ruby_version_is "" ... "1.9" do
it "rounds micro seconds rather than truncates" do
# The use of 8.9999999 is intentional. This is because
@@ -33,6 +27,12 @@ describe "Time#+" do
t2 = Time.at(0) + 8.9
t2.usec.should == 900000
end
+
+ it "understands negative additions" do
+ t = Time.at(100) + -1.3
+ t.usec.should == 700000
+ t.to_i.should == 98
+ end
end
ruby_version_is "1.9" do
@@ -43,6 +43,12 @@ describe "Time#+" do
t.nsec.should == 999_999_999
t.subsec.should == Rational(999_999_999_999_999, 1_000_000_000_000_000)
end
+
+ it "understands negative additions" do
+ t = Time.at(100) + Rational(-13, 10)
+ t.usec.should == 700000
+ t.to_i.should == 98
+ end
end
ruby_version_is "" ... "1.9" do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment