aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/time
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-08 19:43:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-01 15:36:20 +0900
commit826f44834fe11f3f9c52343443a15b6c83466889 (patch)
treef2c2abed62db1c750515cd8b0fbac6442b6d4200 /spec/ruby/core/time
parent3a2073e61b6ccce6d07d31ebd89d4c385b9a55f2 (diff)
downloadruby-826f44834fe11f3f9c52343443a15b6c83466889.tar.gz
Drop support for ruby 2.4 from ruby/spec
Diffstat (limited to 'spec/ruby/core/time')
-rw-r--r--spec/ruby/core/time/at_spec.rb78
-rw-r--r--spec/ruby/core/time/shared/now.rb22
2 files changed, 48 insertions, 52 deletions
diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb
index 368eeb7fca..28a3d7b34c 100644
--- a/spec/ruby/core/time/at_spec.rb
+++ b/spec/ruby/core/time/at_spec.rb
@@ -144,60 +144,58 @@ describe "Time.at" do
end
end
- ruby_version_is "2.5" do
- describe "passed [Time, Numeric, format]" do
- context ":nanosecond format" do
- it "treats second argument as nanoseconds" do
- Time.at(0, 123456789, :nanosecond).nsec.should == 123456789
- end
+ describe "passed [Time, Numeric, format]" do
+ context ":nanosecond format" do
+ it "treats second argument as nanoseconds" do
+ Time.at(0, 123456789, :nanosecond).nsec.should == 123456789
end
+ end
- context ":nsec format" do
- it "treats second argument as nanoseconds" do
- Time.at(0, 123456789, :nsec).nsec.should == 123456789
- end
+ context ":nsec format" do
+ it "treats second argument as nanoseconds" do
+ Time.at(0, 123456789, :nsec).nsec.should == 123456789
end
+ end
- context ":microsecond format" do
- it "treats second argument as microseconds" do
- Time.at(0, 123456, :microsecond).nsec.should == 123456000
- end
+ context ":microsecond format" do
+ it "treats second argument as microseconds" do
+ Time.at(0, 123456, :microsecond).nsec.should == 123456000
end
+ end
- context ":usec format" do
- it "treats second argument as microseconds" do
- Time.at(0, 123456, :usec).nsec.should == 123456000
- end
+ context ":usec format" do
+ it "treats second argument as microseconds" do
+ Time.at(0, 123456, :usec).nsec.should == 123456000
end
+ end
- context ":millisecond format" do
- it "treats second argument as milliseconds" do
- Time.at(0, 123, :millisecond).nsec.should == 123000000
- end
+ context ":millisecond format" do
+ it "treats second argument as milliseconds" do
+ Time.at(0, 123, :millisecond).nsec.should == 123000000
end
+ end
- context "not supported format" do
- it "raises ArgumentError" do
- -> { Time.at(0, 123456, 2) }.should raise_error(ArgumentError)
- -> { Time.at(0, 123456, nil) }.should raise_error(ArgumentError)
- -> { Time.at(0, 123456, :invalid) }.should raise_error(ArgumentError)
- end
-
- it "does not try to convert format to Symbol with #to_sym" do
- format = "usec"
- format.should_not_receive(:to_sym)
- -> { Time.at(0, 123456, format) }.should raise_error(ArgumentError)
- end
+ context "not supported format" do
+ it "raises ArgumentError" do
+ -> { Time.at(0, 123456, 2) }.should raise_error(ArgumentError)
+ -> { Time.at(0, 123456, nil) }.should raise_error(ArgumentError)
+ -> { Time.at(0, 123456, :invalid) }.should raise_error(ArgumentError)
end
- it "supports Float second argument" do
- Time.at(0, 123456789.500, :nanosecond).nsec.should == 123456789
- Time.at(0, 123456789.500, :nsec).nsec.should == 123456789
- Time.at(0, 123456.500, :microsecond).nsec.should == 123456500
- Time.at(0, 123456.500, :usec).nsec.should == 123456500
- Time.at(0, 123.500, :millisecond).nsec.should == 123500000
+ it "does not try to convert format to Symbol with #to_sym" do
+ format = "usec"
+ format.should_not_receive(:to_sym)
+ -> { Time.at(0, 123456, format) }.should raise_error(ArgumentError)
end
end
+
+ it "supports Float second argument" do
+ Time.at(0, 123456789.500, :nanosecond).nsec.should == 123456789
+ Time.at(0, 123456789.500, :nsec).nsec.should == 123456789
+ Time.at(0, 123456.500, :microsecond).nsec.should == 123456500
+ Time.at(0, 123456.500, :usec).nsec.should == 123456500
+ Time.at(0, 123.500, :millisecond).nsec.should == 123500000
+ end
end
ruby_version_is "2.6" do
diff --git a/spec/ruby/core/time/shared/now.rb b/spec/ruby/core/time/shared/now.rb
index d8e5ac9d50..80f66a1134 100644
--- a/spec/ruby/core/time/shared/now.rb
+++ b/spec/ruby/core/time/shared/now.rb
@@ -18,18 +18,16 @@ describe :time_now, shared: true do
end
end
- guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
- it "has at least microsecond precision" do
- times = []
- 10_000.times do
- times << Time.now.nsec
- end
-
- # The clock should not be less accurate than expected (times should
- # not all be a multiple of the next precision up, assuming precisions
- # are multiples of ten.)
- expected = 1_000
- times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size
+ it "has at least microsecond precision" do
+ times = []
+ 10_000.times do
+ times << Time.now.nsec
end
+
+ # The clock should not be less accurate than expected (times should
+ # not all be a multiple of the next precision up, assuming precisions
+ # are multiples of ten.)
+ expected = 1_000
+ times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size
end
end