summaryrefslogtreecommitdiff
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/at_spec.rb18
-rw-r--r--spec/ruby/core/time/getlocal_spec.rb16
-rw-r--r--spec/ruby/core/time/localtime_spec.rb10
-rw-r--r--spec/ruby/core/time/minus_spec.rb12
-rw-r--r--spec/ruby/core/time/new_spec.rb36
-rw-r--r--spec/ruby/core/time/plus_spec.rb14
-rw-r--r--spec/ruby/core/time/shared/gmtime.rb2
-rw-r--r--spec/ruby/core/time/shared/time_params.rb28
-rw-r--r--spec/ruby/core/time/strftime_spec.rb10
-rw-r--r--spec/ruby/core/time/succ_spec.rb2
-rw-r--r--spec/ruby/core/time/zone_spec.rb2
11 files changed, 75 insertions, 75 deletions
diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb
index 1493012676..592b331a28 100644
--- a/spec/ruby/core/time/at_spec.rb
+++ b/spec/ruby/core/time/at_spec.rb
@@ -71,11 +71,11 @@ describe "Time.at" do
describe "passed non-Time, non-Numeric" do
it "raises a TypeError with a String argument" do
- lambda { Time.at("0") }.should raise_error(TypeError)
+ -> { Time.at("0") }.should raise_error(TypeError)
end
it "raises a TypeError with a nil argument" do
- lambda { Time.at(nil) }.should raise_error(TypeError)
+ -> { Time.at(nil) }.should raise_error(TypeError)
end
describe "with an argument that responds to #to_int" do
@@ -127,20 +127,20 @@ describe "Time.at" do
describe "passed [Integer, nil]" do
it "raises a TypeError" do
- lambda { Time.at(0, nil) }.should raise_error(TypeError)
+ -> { Time.at(0, nil) }.should raise_error(TypeError)
end
end
describe "passed [Integer, String]" do
it "raises a TypeError" do
- lambda { Time.at(0, "0") }.should raise_error(TypeError)
+ -> { Time.at(0, "0") }.should raise_error(TypeError)
end
end
describe "passed [Time, Integer]" do
# #8173
it "raises a TypeError" do
- lambda { Time.at(Time.now, 500000) }.should raise_error(TypeError)
+ -> { Time.at(Time.now, 500000) }.should raise_error(TypeError)
end
end
@@ -178,15 +178,15 @@ describe "Time.at" do
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)
+ -> { 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)
+ -> { Time.at(0, 123456, format) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/time/getlocal_spec.rb b/spec/ruby/core/time/getlocal_spec.rb
index 8b6a21bb58..7196577dab 100644
--- a/spec/ruby/core/time/getlocal_spec.rb
+++ b/spec/ruby/core/time/getlocal_spec.rb
@@ -77,24 +77,24 @@ describe "Time#getlocal" do
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
t = Time.now
- lambda { t.getlocal("3600") }.should raise_error(ArgumentError)
+ -> { t.getlocal("3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
t = Time.now
- lambda { t.getlocal("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ -> { t.getlocal("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
t = Time.new
t.getlocal(-86400 + 1).utc_offset.should == (-86400 + 1)
- lambda { t.getlocal(-86400) }.should raise_error(ArgumentError)
+ -> { t.getlocal(-86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
t = Time.new
t.getlocal(86400 - 1).utc_offset.should == (86400 - 1)
- lambda { t.getlocal(86400) }.should raise_error(ArgumentError)
+ -> { t.getlocal(86400) }.should raise_error(ArgumentError)
end
ruby_version_is "2.6" do
@@ -116,7 +116,7 @@ describe "Time#getlocal" do
time
end
- lambda {
+ -> {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
}.should_not raise_error
end
@@ -127,7 +127,7 @@ describe "Time#getlocal" do
time
end
- lambda {
+ -> {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
@@ -138,7 +138,7 @@ describe "Time#getlocal" do
time
end
- lambda {
+ -> {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
}.should_not raise_error
end
@@ -158,7 +158,7 @@ describe "Time#getlocal" do
[Object.new, [], {}, :"some zone"].each do |zone|
time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0)
- lambda {
+ -> {
time.getlocal(zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
diff --git a/spec/ruby/core/time/localtime_spec.rb b/spec/ruby/core/time/localtime_spec.rb
index 7942653c78..2975e112d0 100644
--- a/spec/ruby/core/time/localtime_spec.rb
+++ b/spec/ruby/core/time/localtime_spec.rb
@@ -32,7 +32,7 @@ describe "Time#localtime" do
it "raises a RuntimeError if the time has a different time zone" do
time = Time.gm(2007, 1, 9, 12, 0, 0)
time.freeze
- lambda { time.localtime }.should raise_error(RuntimeError)
+ -> { time.localtime }.should raise_error(RuntimeError)
end
end
@@ -118,23 +118,23 @@ describe "Time#localtime" do
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
t = Time.now
- lambda { t.localtime("3600") }.should raise_error(ArgumentError)
+ -> { t.localtime("3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
t = Time.now
- lambda { t.localtime("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ -> { t.localtime("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
t = Time.new
t.localtime(-86400 + 1).utc_offset.should == (-86400 + 1)
- lambda { t.localtime(-86400) }.should raise_error(ArgumentError)
+ -> { t.localtime(-86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
t = Time.new
t.localtime(86400 - 1).utc_offset.should == (86400 - 1)
- lambda { t.localtime(86400) }.should raise_error(ArgumentError)
+ -> { t.localtime(86400) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb
index a47e726196..e0fbf94cb0 100644
--- a/spec/ruby/core/time/minus_spec.rb
+++ b/spec/ruby/core/time/minus_spec.rb
@@ -20,18 +20,18 @@ describe "Time#-" do
end
it "raises a TypeError if given argument is a coercible String" do
- lambda { Time.now - "1" }.should raise_error(TypeError)
- lambda { Time.now - "0.1" }.should raise_error(TypeError)
- lambda { Time.now - "1/3" }.should raise_error(TypeError)
+ -> { Time.now - "1" }.should raise_error(TypeError)
+ -> { Time.now - "0.1" }.should raise_error(TypeError)
+ -> { Time.now - "1/3" }.should raise_error(TypeError)
end
it "raises TypeError on argument that can't be coerced" do
- lambda { Time.now - Object.new }.should raise_error(TypeError)
- lambda { Time.now - "stuff" }.should raise_error(TypeError)
+ -> { Time.now - Object.new }.should raise_error(TypeError)
+ -> { Time.now - "stuff" }.should raise_error(TypeError)
end
it "raises TypeError on nil argument" do
- lambda { Time.now - nil }.should raise_error(TypeError)
+ -> { Time.now - nil }.should raise_error(TypeError)
end
it "tracks microseconds" do
diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb
index fe0e1aea31..84e97f8082 100644
--- a/spec/ruby/core/time/new_spec.rb
+++ b/spec/ruby/core/time/new_spec.rb
@@ -76,42 +76,42 @@ describe "Time.new with a utc_offset argument" do
# [Bug #8679], r47676
it "disallows a value for minutes greater than 59" do
- lambda {
+ -> {
Time.new(2000, 1, 1, 0, 0, 0, "+01:60")
}.should raise_error(ArgumentError)
- lambda {
+ -> {
Time.new(2000, 1, 1, 0, 0, 0, "+01:99")
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
- lambda { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the hour value is greater than 23" do
- lambda { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
- lambda { Time.new(2000, 1, 1, 0, 0, 0, "-04:10".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, "-04:10".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
Time.new(2000, 1, 1, 0, 0, 0, -86400 + 1).utc_offset.should == (-86400 + 1)
- lambda { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
Time.new(2000, 1, 1, 0, 0, 0, 86400 - 1).utc_offset.should == (86400 - 1)
- lambda { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the seconds argument is negative" do
- lambda { Time.new(2000, 1, 1, 0, 0, -1) }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, -1) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the utc_offset argument is greater than or equal to 10e9" do
- lambda { Time.new(2000, 1, 1, 0, 0, 0, 1000000000) }.should raise_error(ArgumentError)
+ -> { Time.new(2000, 1, 1, 0, 0, 0, 1000000000) }.should raise_error(ArgumentError)
end
end
@@ -134,7 +134,7 @@ ruby_version_is "2.6" do
time
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
}.should_not raise_error
end
@@ -145,7 +145,7 @@ ruby_version_is "2.6" do
time
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
@@ -156,7 +156,7 @@ ruby_version_is "2.6" do
time
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
}.should_not raise_error
end
@@ -170,7 +170,7 @@ ruby_version_is "2.6" do
Time.utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
@@ -182,7 +182,7 @@ ruby_version_is "2.6" do
Class.new(Time).utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
@@ -194,7 +194,7 @@ ruby_version_is "2.6" do
Struct.new(:to_i).new(time.to_i - 60*60)
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
@@ -220,7 +220,7 @@ ruby_version_is "2.6" do
Time.utc(t.year, t.mon, t.day + 1, t.hour, t.min, t.sec)
end
- lambda {
+ -> {
Time.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(ArgumentError, "utc_offset out of range")
end
@@ -277,7 +277,7 @@ ruby_version_is "2.6" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2000, 1, 1, 12, 0, 0, zone)
- lambda {
+ -> {
Marshal.dump(time)
}.should raise_error(NoMethodError, /undefined method `name' for/)
end
@@ -317,7 +317,7 @@ ruby_version_is "2.6" do
it "does not call .find_timezone if passed any not string/numeric/timezone timezone argument" do
[Object.new, [], {}, :"some zone"].each do |zone|
- lambda {
+ -> {
TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb
index 91713b84b3..0a9984f180 100644
--- a/spec/ruby/core/time/plus_spec.rb
+++ b/spec/ruby/core/time/plus_spec.rb
@@ -17,9 +17,9 @@ describe "Time#+" do
end
it "raises a TypeError if given argument is a coercible String" do
- lambda { Time.now + "1" }.should raise_error(TypeError)
- lambda { Time.now + "0.1" }.should raise_error(TypeError)
- lambda { Time.now + "1/3" }.should raise_error(TypeError)
+ -> { Time.now + "1" }.should raise_error(TypeError)
+ -> { Time.now + "0.1" }.should raise_error(TypeError)
+ -> { Time.now + "1/3" }.should raise_error(TypeError)
end
it "increments the time by the specified amount as rational numbers" do
@@ -32,8 +32,8 @@ describe "Time#+" do
end
it "raises TypeError on argument that can't be coerced into Rational" do
- lambda { Time.now + Object.new }.should raise_error(TypeError)
- lambda { Time.now + "stuff" }.should raise_error(TypeError)
+ -> { Time.now + Object.new }.should raise_error(TypeError)
+ -> { Time.now + "stuff" }.should raise_error(TypeError)
end
it "returns a UTC time if self is UTC" do
@@ -74,11 +74,11 @@ describe "Time#+" do
end
it "raises TypeError on Time argument" do
- lambda { Time.now + Time.now }.should raise_error(TypeError)
+ -> { Time.now + Time.now }.should raise_error(TypeError)
end
it "raises TypeError on nil argument" do
- lambda { Time.now + nil }.should raise_error(TypeError)
+ -> { Time.now + nil }.should raise_error(TypeError)
end
#see [ruby-dev:38446]
diff --git a/spec/ruby/core/time/shared/gmtime.rb b/spec/ruby/core/time/shared/gmtime.rb
index e684a1fd95..5ed64c2ab6 100644
--- a/spec/ruby/core/time/shared/gmtime.rb
+++ b/spec/ruby/core/time/shared/gmtime.rb
@@ -26,7 +26,7 @@ describe :time_gmtime, shared: true do
with_timezone("CST", -6) do
time = Time.now
time.freeze
- lambda { time.send(@method) }.should raise_error(RuntimeError)
+ -> { time.send(@method) }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/time/shared/time_params.rb b/spec/ruby/core/time/shared/time_params.rb
index 39245116b0..63d0dbc120 100644
--- a/spec/ruby/core/time/shared/time_params.rb
+++ b/spec/ruby/core/time/shared/time_params.rb
@@ -30,7 +30,7 @@ describe :time_params, shared: true do
end
it "raises a TypeError if the year is nil" do
- lambda { Time.send(@method, nil) }.should raise_error(TypeError)
+ -> { Time.send(@method, nil) }.should raise_error(TypeError)
end
it "accepts nil month, day, hour, minute, and second" do
@@ -145,41 +145,41 @@ describe :time_params, shared: true do
end
it "raises an ArgumentError for out of range month" do
- lambda {
+ -> {
Time.send(@method, 2008, 13, 31, 23, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range day" do
- lambda {
+ -> {
Time.send(@method, 2008, 12, 32, 23, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range hour" do
- lambda {
+ -> {
Time.send(@method, 2008, 12, 31, 25, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range minute" do
- lambda {
+ -> {
Time.send(@method, 2008, 12, 31, 23, 61, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range second" do
- lambda {
+ -> {
Time.send(@method, 2008, 12, 31, 23, 59, 61)
}.should raise_error(ArgumentError)
end
it "raises ArgumentError when given 9 arguments" do
- lambda { Time.send(@method, *[0]*9) }.should raise_error(ArgumentError)
+ -> { Time.send(@method, *[0]*9) }.should raise_error(ArgumentError)
end
it "raises ArgumentError when given 11 arguments" do
- lambda { Time.send(@method, *[0]*11) }.should raise_error(ArgumentError)
+ -> { Time.send(@method, *[0]*11) }.should raise_error(ArgumentError)
end
it "returns subclass instances" do
@@ -202,23 +202,23 @@ describe :time_params_10_arg, shared: true do
end
it "raises an ArgumentError for out of range values" do
- lambda {
+ -> {
Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # sec
- lambda {
+ -> {
Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # min
- lambda {
+ -> {
Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # hour
- lambda {
+ -> {
Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # day
- lambda {
+ -> {
Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # month
end
@@ -231,7 +231,7 @@ describe :time_params_microseconds, shared: true do
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)
+ -> { Time.send(@method, 2000, 1, 1, 20, 15, 1, 1000000) }.should raise_error(ArgumentError)
end
it "handles fractional microseconds as a Float" do
diff --git a/spec/ruby/core/time/strftime_spec.rb b/spec/ruby/core/time/strftime_spec.rb
index 62f9272f32..1bd24b0538 100644
--- a/spec/ruby/core/time/strftime_spec.rb
+++ b/spec/ruby/core/time/strftime_spec.rb
@@ -6,14 +6,14 @@ require_relative '../../shared/time/strftime_for_time'
describe "Time#strftime" do
before :all do
- @new_date = lambda { |y,m,d| Time.gm(y,m,d) }
- @new_time = lambda { |*args| Time.gm(*args) }
- @new_time_in_zone = lambda { |zone,offset,*args|
+ @new_date = -> y, m, d { Time.gm(y,m,d) }
+ @new_time = -> *args { Time.gm(*args) }
+ @new_time_in_zone = -> zone, offset, *args {
with_timezone(zone, offset) do
Time.new(*args)
end
}
- @new_time_with_offset = lambda { |y,m,d,h,min,s,offset|
+ @new_time_with_offset = -> y, m, d, h, min, s, offset {
Time.new(y,m,d,h,min,s,offset)
}
@@ -25,7 +25,7 @@ describe "Time#strftime" do
# Differences with date
it "requires an argument" do
- lambda { @time.strftime }.should raise_error(ArgumentError)
+ -> { @time.strftime }.should raise_error(ArgumentError)
end
# %Z is zone name or empty for Time
diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb
index 395ed67064..e68e64b0cc 100644
--- a/spec/ruby/core/time/succ_spec.rb
+++ b/spec/ruby/core/time/succ_spec.rb
@@ -21,7 +21,7 @@ describe "Time#succ" do
end
it "is obsolete" do
- lambda {
+ -> {
Time.at(100).succ
}.should complain(/Time#succ is obsolete/)
end
diff --git a/spec/ruby/core/time/zone_spec.rb b/spec/ruby/core/time/zone_spec.rb
index 45c9e852ea..907ccf9f4b 100644
--- a/spec/ruby/core/time/zone_spec.rb
+++ b/spec/ruby/core/time/zone_spec.rb
@@ -52,7 +52,7 @@ describe "Time#zone" do
end
it "doesn't raise errors for a Time with a fixed offset" do
- lambda {
+ -> {
Time.new(2001, 1, 1, 0, 0, 0, "+05:00").zone
}.should_not raise_error
end