aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/time
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/time')
-rw-r--r--spec/ruby/core/time/nsec_spec.rb4
-rw-r--r--spec/ruby/core/time/shared/time_params.rb4
-rw-r--r--spec/ruby/core/time/usec_spec.rb4
3 files changed, 12 insertions, 0 deletions
diff --git a/spec/ruby/core/time/nsec_spec.rb b/spec/ruby/core/time/nsec_spec.rb
index fb3df6394c..9338eb435a 100644
--- a/spec/ruby/core/time/nsec_spec.rb
+++ b/spec/ruby/core/time/nsec_spec.rb
@@ -24,4 +24,8 @@ describe "Time#nsec" do
it "returns the nanoseconds part of a Time constructed with an Rational number of microseconds" do
Time.at(0, Rational(99, 10)).nsec.should == 9900
end
+
+ it "returns a positive value for dates before the epoch" do
+ Time.utc(1969, 11, 12, 13, 18, 57, 404240).nsec.should == 404240000
+ end
end
diff --git a/spec/ruby/core/time/shared/time_params.rb b/spec/ruby/core/time/shared/time_params.rb
index 120d8d3af1..39245116b0 100644
--- a/spec/ruby/core/time/shared/time_params.rb
+++ b/spec/ruby/core/time/shared/time_params.rb
@@ -230,6 +230,10 @@ describe :time_params_microseconds, shared: true do
t.usec.should == 123
end
+ it "raises an ArgumentError for out of range microsecond" do
+ lambda { Time.send(@method, 2000, 1, 1, 20, 15, 1, 1000000) }.should raise_error(ArgumentError)
+ end
+
it "handles fractional microseconds as a Float" do
t = Time.send(@method, 2000, 1, 1, 20, 15, 1, 1.75)
t.usec.should == 1
diff --git a/spec/ruby/core/time/usec_spec.rb b/spec/ruby/core/time/usec_spec.rb
index 44cd2047e7..6ea52f5e79 100644
--- a/spec/ruby/core/time/usec_spec.rb
+++ b/spec/ruby/core/time/usec_spec.rb
@@ -36,4 +36,8 @@ describe "Time#usec" do
it "returns the microseconds for time created by Time#local" do
Time.local(1,2,3,4,5,Rational(6.78)).usec.should == 780000
end
+
+ it "returns a positive value for dates before the epoch" do
+ Time.utc(1969, 11, 12, 13, 18, 57, 404240).usec.should == 404240
+ end
end