summaryrefslogtreecommitdiff
path: root/spec/ruby/shared
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
commit5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch)
tree05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/shared
parenta06301b103371b0b7da8eaca26ba744961769f99 (diff)
downloadruby-5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0.tar.gz
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/shared')
-rw-r--r--spec/ruby/shared/basicobject/method_missing.rb18
-rw-r--r--spec/ruby/shared/basicobject/send.rb10
-rw-r--r--spec/ruby/shared/fiber/resume.rb8
-rw-r--r--spec/ruby/shared/file/directory.rb6
-rw-r--r--spec/ruby/shared/file/executable.rb8
-rw-r--r--spec/ruby/shared/file/executable_real.rb8
-rw-r--r--spec/ruby/shared/file/exist.rb6
-rw-r--r--spec/ruby/shared/file/file.rb8
-rw-r--r--spec/ruby/shared/file/identical.rb6
-rw-r--r--spec/ruby/shared/file/size.rb2
-rw-r--r--spec/ruby/shared/file/writable_real.rb8
-rw-r--r--spec/ruby/shared/file/zero.rb8
-rw-r--r--spec/ruby/shared/io/putc.rb8
-rw-r--r--spec/ruby/shared/kernel/raise.rb20
-rw-r--r--spec/ruby/shared/math/atanh.rb8
-rw-r--r--spec/ruby/shared/process/abort.rb12
-rw-r--r--spec/ruby/shared/process/exit.rb20
-rw-r--r--spec/ruby/shared/process/fork.rb2
-rw-r--r--spec/ruby/shared/queue/deque.rb4
-rw-r--r--spec/ruby/shared/queue/enque.rb2
-rw-r--r--spec/ruby/shared/rational/Rational.rb10
-rw-r--r--spec/ruby/shared/rational/coerce.rb8
-rw-r--r--spec/ruby/shared/rational/div.rb12
-rw-r--r--spec/ruby/shared/rational/divide.rb4
-rw-r--r--spec/ruby/shared/rational/divmod.rb6
-rw-r--r--spec/ruby/shared/rational/exponent.rb8
-rw-r--r--spec/ruby/shared/rational/modulo.rb8
-rw-r--r--spec/ruby/shared/rational/round.rb2
-rw-r--r--spec/ruby/shared/sizedqueue/enque.rb4
-rw-r--r--spec/ruby/shared/sizedqueue/max.rb8
-rw-r--r--spec/ruby/shared/sizedqueue/new.rb10
-rw-r--r--spec/ruby/shared/string/times.rb10
32 files changed, 135 insertions, 127 deletions
diff --git a/spec/ruby/shared/basicobject/method_missing.rb b/spec/ruby/shared/basicobject/method_missing.rb
index 0759dd9606..4871603dce 100644
--- a/spec/ruby/shared/basicobject/method_missing.rb
+++ b/spec/ruby/shared/basicobject/method_missing.rb
@@ -24,15 +24,15 @@ end
describe :method_missing_module, shared: true do
describe "for a Module" do
it "raises a NoMethodError when an undefined method is called" do
- lambda { @object.no_such_method }.should raise_error(NoMethodError)
+ -> { @object.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- lambda { @object.method_protected }.should raise_error(NoMethodError)
+ -> { @object.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- lambda { @object.method_private }.should raise_error(NoMethodError)
+ -> { @object.method_private }.should raise_error(NoMethodError)
end
end
end
@@ -60,15 +60,15 @@ end
describe :method_missing_class, shared: true do
describe "for a Class" do
it "raises a NoMethodError when an undefined method is called" do
- lambda { @object.no_such_method }.should raise_error(NoMethodError)
+ -> { @object.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- lambda { @object.method_protected }.should raise_error(NoMethodError)
+ -> { @object.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- lambda { @object.method_private }.should raise_error(NoMethodError)
+ -> { @object.method_private }.should raise_error(NoMethodError)
end
end
end
@@ -100,15 +100,15 @@ end
describe :method_missing_instance, shared: true do
describe "for an instance" do
it "raises a NoMethodError when an undefined method is called" do
- lambda { @object.new.no_such_method }.should raise_error(NoMethodError)
+ -> { @object.new.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- lambda { @object.new.method_protected }.should raise_error(NoMethodError)
+ -> { @object.new.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- lambda { @object.new.method_private }.should raise_error(NoMethodError)
+ -> { @object.new.method_private }.should raise_error(NoMethodError)
end
it 'sets the receiver of the raised NoMethodError' do
diff --git a/spec/ruby/shared/basicobject/send.rb b/spec/ruby/shared/basicobject/send.rb
index f96a3593bd..625aaa2917 100644
--- a/spec/ruby/shared/basicobject/send.rb
+++ b/spec/ruby/shared/basicobject/send.rb
@@ -42,7 +42,7 @@ describe :basicobject_send, shared: true do
'done'
end
end
- lambda { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should raise_error(NameError)
+ -> { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should raise_error(NameError)
end
it "raises a NameError if the corresponding singleton method can't be found" do
@@ -51,12 +51,12 @@ describe :basicobject_send, shared: true do
'done'
end
end
- lambda { SendSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
+ -> { SendSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
end
it "raises an ArgumentError if no arguments are given" do
class SendSpecs::Foo; end
- lambda { SendSpecs::Foo.new.send @method }.should raise_error(ArgumentError)
+ -> { SendSpecs::Foo.new.send @method }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if called with more arguments than available parameters" do
@@ -64,7 +64,7 @@ describe :basicobject_send, shared: true do
def bar; end
end
- lambda { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError)
+ -> { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if called with fewer arguments than required parameters" do
@@ -72,7 +72,7 @@ describe :basicobject_send, shared: true do
def foo(arg); end
end
- lambda { SendSpecs::Foo.new.send(@method, :foo) }.should raise_error(ArgumentError)
+ -> { SendSpecs::Foo.new.send(@method, :foo) }.should raise_error(ArgumentError)
end
it "succeeds if passed an arbitrary number of arguments as a splat parameter" do
diff --git a/spec/ruby/shared/fiber/resume.rb b/spec/ruby/shared/fiber/resume.rb
index e2d30d781b..d3dc438ae2 100644
--- a/spec/ruby/shared/fiber/resume.rb
+++ b/spec/ruby/shared/fiber/resume.rb
@@ -50,7 +50,7 @@ describe :fiber_resume, shared: true do
it "accepts any number of arguments" do
fiber = Fiber.new { |a| }
- lambda { fiber.send(@method, *(1..10).to_a) }.should_not raise_error
+ -> { fiber.send(@method, *(1..10).to_a) }.should_not raise_error
end
it "sets the block parameters to its arguments on the first invocation" do
@@ -64,16 +64,16 @@ describe :fiber_resume, shared: true do
it "raises a FiberError if the Fiber is dead" do
fiber = Fiber.new { true }
fiber.send(@method)
- lambda { fiber.send(@method) }.should raise_error(FiberError)
+ -> { fiber.send(@method) }.should raise_error(FiberError)
end
it "raises a LocalJumpError if the block includes a return statement" do
fiber = Fiber.new { return; }
- lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
+ -> { fiber.send(@method) }.should raise_error(LocalJumpError)
end
it "raises a LocalJumpError if the block includes a break statement" do
fiber = Fiber.new { break; }
- lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
+ -> { fiber.send(@method) }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/shared/file/directory.rb b/spec/ruby/shared/file/directory.rb
index 67e939bf16..8ba933a601 100644
--- a/spec/ruby/shared/file/directory.rb
+++ b/spec/ruby/shared/file/directory.rb
@@ -24,12 +24,12 @@ describe :file_directory, shared: true do
end
it "raises a TypeError when passed an Integer" do
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
- lambda { @object.send(@method, bignum_value) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1) }.should raise_error(TypeError)
+ -> { @object.send(@method, bignum_value) }.should raise_error(TypeError)
end
it "raises a TypeError when passed nil" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/executable.rb b/spec/ruby/shared/file/executable.rb
index 5b21fb0d97..2987d0aabb 100644
--- a/spec/ruby/shared/file/executable.rb
+++ b/spec/ruby/shared/file/executable.rb
@@ -31,13 +31,13 @@ describe :file_executable, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { @object.send(@method) }.should raise_error(ArgumentError)
+ -> { @object.send(@method) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- lambda { @object.send(@method, false) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/executable_real.rb b/spec/ruby/shared/file/executable_real.rb
index 2b1bf8f585..ce3d5ca176 100644
--- a/spec/ruby/shared/file/executable_real.rb
+++ b/spec/ruby/shared/file/executable_real.rb
@@ -29,13 +29,13 @@ describe :file_executable_real, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { @object.send(@method) }.should raise_error(ArgumentError)
+ -> { @object.send(@method) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- lambda { @object.send(@method, false) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/exist.rb b/spec/ruby/shared/file/exist.rb
index 1557f01a82..3bd97711b4 100644
--- a/spec/ruby/shared/file/exist.rb
+++ b/spec/ruby/shared/file/exist.rb
@@ -10,12 +10,12 @@ describe :file_exist, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { @object.send(@method) }.should raise_error(ArgumentError)
- lambda { @object.send(@method, __FILE__, __FILE__) }.should raise_error(ArgumentError)
+ -> { @object.send(@method) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, __FILE__, __FILE__) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "accepts an object that has a #to_path method" do
diff --git a/spec/ruby/shared/file/file.rb b/spec/ruby/shared/file/file.rb
index 095bd63fff..c1748a88b3 100644
--- a/spec/ruby/shared/file/file.rb
+++ b/spec/ruby/shared/file/file.rb
@@ -34,12 +34,12 @@ describe :file_file, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { @object.send(@method) }.should raise_error(ArgumentError)
- lambda { @object.send(@method, @null, @file) }.should raise_error(ArgumentError)
+ -> { @object.send(@method) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, @null, @file) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/identical.rb b/spec/ruby/shared/file/identical.rb
index e89cd309ea..ecc21727ca 100644
--- a/spec/ruby/shared/file/identical.rb
+++ b/spec/ruby/shared/file/identical.rb
@@ -31,12 +31,12 @@ describe :file_identical, shared: true do
end
it "raises an ArgumentError if not passed two arguments" do
- lambda { @object.send(@method, @file1, @file2, @link) }.should raise_error(ArgumentError)
- lambda { @object.send(@method, @file1) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, @file1, @file2, @link) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, @file1) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed String types" do
- lambda { @object.send(@method, 1,1) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1,1) }.should raise_error(TypeError)
end
it "returns true if both named files are identical" do
diff --git a/spec/ruby/shared/file/size.rb b/spec/ruby/shared/file/size.rb
index bb95190fc0..880dfbb612 100644
--- a/spec/ruby/shared/file/size.rb
+++ b/spec/ruby/shared/file/size.rb
@@ -56,7 +56,7 @@ describe :file_size_raise_when_missing, shared: true do
end
it "raises an error if file_name doesn't exist" do
- lambda {@object.send(@method, @missing)}.should raise_error(Errno::ENOENT)
+ -> {@object.send(@method, @missing)}.should raise_error(Errno::ENOENT)
end
end
diff --git a/spec/ruby/shared/file/writable_real.rb b/spec/ruby/shared/file/writable_real.rb
index 3730befb7a..e9721fd379 100644
--- a/spec/ruby/shared/file/writable_real.rb
+++ b/spec/ruby/shared/file/writable_real.rb
@@ -16,13 +16,13 @@ describe :file_writable_real, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { File.writable_real? }.should raise_error(ArgumentError)
+ -> { File.writable_real? }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- lambda { @object.send(@method, false) }.should raise_error(TypeError)
+ -> { @object.send(@method, 1) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/zero.rb b/spec/ruby/shared/file/zero.rb
index cf014d4722..6a9399a021 100644
--- a/spec/ruby/shared/file/zero.rb
+++ b/spec/ruby/shared/file/zero.rb
@@ -40,13 +40,13 @@ describe :file_zero, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { File.zero? }.should raise_error(ArgumentError)
+ -> { File.zero? }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- lambda { @object.send(@method, true) }.should raise_error(TypeError)
- lambda { @object.send(@method, false) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, true) }.should raise_error(TypeError)
+ -> { @object.send(@method, false) }.should raise_error(TypeError)
end
it "returns true inside a block opening a file if it is empty" do
diff --git a/spec/ruby/shared/io/putc.rb b/spec/ruby/shared/io/putc.rb
index b71443e219..fac14886ee 100644
--- a/spec/ruby/shared/io/putc.rb
+++ b/spec/ruby/shared/io/putc.rb
@@ -40,18 +40,18 @@ describe :io_putc, shared: true do
it "raises IOError on a closed stream" do
@io.close
- lambda { @io_object.send(@method, "a") }.should raise_error(IOError)
+ -> { @io_object.send(@method, "a") }.should raise_error(IOError)
end
it "raises a TypeError when passed nil" do
- lambda { @io_object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @io_object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
- lambda { @io_object.send(@method, false) }.should raise_error(TypeError)
+ -> { @io_object.send(@method, false) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
- lambda { @io_object.send(@method, true) }.should raise_error(TypeError)
+ -> { @io_object.send(@method, true) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/kernel/raise.rb b/spec/ruby/shared/kernel/raise.rb
index 7b9a29ca3f..d4553775f4 100644
--- a/spec/ruby/shared/kernel/raise.rb
+++ b/spec/ruby/shared/kernel/raise.rb
@@ -4,7 +4,7 @@ describe :kernel_raise, shared: true do
end
it "aborts execution" do
- lambda do
+ -> do
@object.raise Exception, "abort"
ScratchPad.record :no_abort
end.should raise_error(Exception, "abort")
@@ -13,36 +13,36 @@ describe :kernel_raise, shared: true do
end
it "raises RuntimeError if no exception class is given" do
- lambda { @object.raise }.should raise_error(RuntimeError, "")
+ -> { @object.raise }.should raise_error(RuntimeError, "")
end
it "raises a given Exception instance" do
error = RuntimeError.new
- lambda { @object.raise(error) }.should raise_error(error)
+ -> { @object.raise(error) }.should raise_error(error)
end
it "raises a RuntimeError if string given" do
- lambda { @object.raise("a bad thing") }.should raise_error(RuntimeError)
+ -> { @object.raise("a bad thing") }.should raise_error(RuntimeError)
end
it "raises a TypeError when passed a non-Exception object" do
- lambda { @object.raise(Object.new) }.should raise_error(TypeError)
+ -> { @object.raise(Object.new) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
- lambda { @object.raise(true) }.should raise_error(TypeError)
+ -> { @object.raise(true) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
- lambda { @object.raise(false) }.should raise_error(TypeError)
+ -> { @object.raise(false) }.should raise_error(TypeError)
end
it "raises a TypeError when passed nil" do
- lambda { @object.raise(nil) }.should raise_error(TypeError)
+ -> { @object.raise(nil) }.should raise_error(TypeError)
end
it "re-raises the previously rescued exception if no exception is specified" do
- lambda do
+ -> do
begin
@object.raise Exception, "outer"
ScratchPad.record :no_abort
@@ -78,7 +78,7 @@ describe :kernel_raise, shared: true do
end
it "allows Exception, message, and backtrace parameters" do
- lambda do
+ -> do
@object.raise(ArgumentError, "message", caller)
end.should raise_error(ArgumentError, "message")
end
diff --git a/spec/ruby/shared/math/atanh.rb b/spec/ruby/shared/math/atanh.rb
index 1d1a6ebd74..3fb64153a0 100644
--- a/spec/ruby/shared/math/atanh.rb
+++ b/spec/ruby/shared/math/atanh.rb
@@ -11,11 +11,11 @@ describe :math_atanh_base, shared: true do
end
it "raises a TypeError if the argument is nil" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is not a Numeric" do
- lambda { @object.send(@method, "test") }.should raise_error(TypeError)
+ -> { @object.send(@method, "test") }.should raise_error(TypeError)
end
it "returns Infinity if x == 1.0" do
@@ -35,10 +35,10 @@ end
describe :math_atanh_no_complex, shared: true do
it "raises a Math::DomainError for arguments greater than 1.0" do
- lambda { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError)
+ -> { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError)
end
it "raises a Math::DomainError for arguments less than -1.0" do
- lambda { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError)
+ -> { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError)
end
end
diff --git a/spec/ruby/shared/process/abort.rb b/spec/ruby/shared/process/abort.rb
index 1a25aeffc2..935637e1c2 100644
--- a/spec/ruby/shared/process/abort.rb
+++ b/spec/ruby/shared/process/abort.rb
@@ -8,29 +8,29 @@ describe :process_abort, shared: true do
end
it "raises a SystemExit exception" do
- lambda { @object.abort }.should raise_error(SystemExit)
+ -> { @object.abort }.should raise_error(SystemExit)
end
it "sets the exception message to the given message" do
- lambda { @object.abort "message" }.should raise_error { |e| e.message.should == "message" }
+ -> { @object.abort "message" }.should raise_error { |e| e.message.should == "message" }
end
it "sets the exception status code of 1" do
- lambda { @object.abort }.should raise_error { |e| e.status.should == 1 }
+ -> { @object.abort }.should raise_error { |e| e.status.should == 1 }
end
it "prints the specified message to STDERR" do
- lambda { @object.abort "a message" }.should raise_error(SystemExit)
+ -> { @object.abort "a message" }.should raise_error(SystemExit)
$stderr.should =~ /a message/
end
it "coerces the argument with #to_str" do
str = mock('to_str')
str.should_receive(:to_str).any_number_of_times.and_return("message")
- lambda { @object.abort str }.should raise_error(SystemExit, "message")
+ -> { @object.abort str }.should raise_error(SystemExit, "message")
end
it "raises TypeError when given a non-String object" do
- lambda { @object.abort 123 }.should raise_error(TypeError)
+ -> { @object.abort 123 }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/process/exit.rb b/spec/ruby/shared/process/exit.rb
index 7d567c8195..1820dd17fd 100644
--- a/spec/ruby/shared/process/exit.rb
+++ b/spec/ruby/shared/process/exit.rb
@@ -1,13 +1,13 @@
describe :process_exit, shared: true do
it "raises a SystemExit with status 0" do
- lambda { @object.exit }.should raise_error(SystemExit) { |e|
+ -> { @object.exit }.should raise_error(SystemExit) { |e|
e.status.should == 0
}
end
it "raises a SystemExit with the specified status" do
[-2**16, -2**8, -8, -1, 0, 1 , 8, 2**8, 2**16].each do |value|
- lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == value
}
end
@@ -15,7 +15,7 @@ describe :process_exit, shared: true do
it "raises a SystemExit with the specified boolean status" do
{ true => 0, false => 1 }.each do |value, status|
- lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == status
}
end
@@ -24,24 +24,24 @@ describe :process_exit, shared: true do
it "tries to convert the passed argument to an Integer using #to_int" do
obj = mock('5')
obj.should_receive(:to_int).and_return(5)
- lambda { @object.exit(obj) }.should raise_error(SystemExit) { |e|
+ -> { @object.exit(obj) }.should raise_error(SystemExit) { |e|
e.status.should == 5
}
end
it "converts the passed Float argument to an Integer" do
{ -2.2 => -2, -0.1 => 0, 5.5 => 5, 827.999 => 827 }.each do |value, status|
- lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == status
}
end
end
it "raises TypeError if can't convert the argument to an Integer" do
- lambda { @object.exit(Object.new) }.should raise_error(TypeError)
- lambda { @object.exit('0') }.should raise_error(TypeError)
- lambda { @object.exit([0]) }.should raise_error(TypeError)
- lambda { @object.exit(nil) }.should raise_error(TypeError)
+ -> { @object.exit(Object.new) }.should raise_error(TypeError)
+ -> { @object.exit('0') }.should raise_error(TypeError)
+ -> { @object.exit([0]) }.should raise_error(TypeError)
+ -> { @object.exit(nil) }.should raise_error(TypeError)
end
it "raises the SystemExit in the main thread if it reaches the top-level handler of another thread" do
@@ -69,7 +69,7 @@ describe :process_exit, shared: true do
ScratchPad.recorded.should == [:in_thread, :in_main]
# the thread also keeps the exception as its value
- lambda { t.value }.should raise_error(SystemExit)
+ -> { t.value }.should raise_error(SystemExit)
end
end
diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb
index c2c2aee9bf..cb863b42d8 100644
--- a/spec/ruby/shared/process/fork.rb
+++ b/spec/ruby/shared/process/fork.rb
@@ -8,7 +8,7 @@ describe :process_fork, shared: true do
end
it "raises a NotImplementedError when called" do
- lambda { @object.fork }.should raise_error(NotImplementedError)
+ -> { @object.fork }.should raise_error(NotImplementedError)
end
end
diff --git a/spec/ruby/shared/queue/deque.rb b/spec/ruby/shared/queue/deque.rb
index 3590f367ba..8b755dd9b7 100644
--- a/spec/ruby/shared/queue/deque.rb
+++ b/spec/ruby/shared/queue/deque.rb
@@ -66,7 +66,7 @@ describe :queue_deq, shared: true do
it "raises a ThreadError if the queue is empty" do
q = @object.call
- lambda { q.send(@method, true) }.should raise_error(ThreadError)
+ -> { q.send(@method, true) }.should raise_error(ThreadError)
end
it "removes an item from a closed queue" do
@@ -79,7 +79,7 @@ describe :queue_deq, shared: true do
it "raises a ThreadError for a closed empty queue" do
q = @object.call
q.close
- lambda { q.send(@method, true) }.should raise_error(ThreadError)
+ -> { q.send(@method, true) }.should raise_error(ThreadError)
end
end
end
diff --git a/spec/ruby/shared/queue/enque.rb b/spec/ruby/shared/queue/enque.rb
index ad413e1f46..8aba02e544 100644
--- a/spec/ruby/shared/queue/enque.rb
+++ b/spec/ruby/shared/queue/enque.rb
@@ -11,7 +11,7 @@ describe :queue_enq, shared: true do
it "is an error for a closed queue" do
q = @object.call
q.close
- lambda {
+ -> {
q.send @method, Object.new
}.should raise_error(ClosedQueueError)
end
diff --git a/spec/ruby/shared/rational/Rational.rb b/spec/ruby/shared/rational/Rational.rb
index 3952f663c6..2c36243dc3 100644
--- a/spec/ruby/shared/rational/Rational.rb
+++ b/spec/ruby/shared/rational/Rational.rb
@@ -80,24 +80,24 @@ describe :kernel_Rational, shared: true do
end
it "raises a RangeError if the imaginary part is not 0" do
- lambda { Rational(Complex(1, 2)) }.should raise_error(RangeError)
+ -> { Rational(Complex(1, 2)) }.should raise_error(RangeError)
end
end
it "raises a TypeError if the first argument is nil" do
- lambda { Rational(nil) }.should raise_error(TypeError)
+ -> { Rational(nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is nil" do
- lambda { Rational(1, nil) }.should raise_error(TypeError)
+ -> { Rational(1, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the first argument is a Symbol" do
- lambda { Rational(:sym) }.should raise_error(TypeError)
+ -> { Rational(:sym) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is a Symbol" do
- lambda { Rational(1, :sym) }.should raise_error(TypeError)
+ -> { Rational(1, :sym) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/rational/coerce.rb b/spec/ruby/shared/rational/coerce.rb
index 0d6c440993..ffb118e2a7 100644
--- a/spec/ruby/shared/rational/coerce.rb
+++ b/spec/ruby/shared/rational/coerce.rb
@@ -1,5 +1,7 @@
require_relative '../../spec_helper'
+require 'bigdecimal'
+
describe :rational_coerce, shared: true do
it "returns the passed argument, self as Float, when given a Float" do
result = Rational(3, 4).coerce(1.0)
@@ -18,4 +20,10 @@ describe :rational_coerce, shared: true do
it "returns [argument, self] when given a Rational" do
Rational(3, 7).coerce(Rational(9, 2)).should == [Rational(9, 2), Rational(3, 7)]
end
+
+ it "raises an error when passed a BigDecimal" do
+ -> {
+ Rational(500, 3).coerce(BigDecimal('166.666666666'))
+ }.should raise_error(TypeError, /BigDecimal can't be coerced into Rational/)
+ end
end
diff --git a/spec/ruby/shared/rational/div.rb b/spec/ruby/shared/rational/div.rb
index 2bf9b80eb5..d5bd9e6644 100644
--- a/spec/ruby/shared/rational/div.rb
+++ b/spec/ruby/shared/rational/div.rb
@@ -7,11 +7,11 @@ describe :rational_div_rat, shared: true do
end
it "raises a ZeroDivisionError when the argument has a numerator of 0" do
- lambda { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
- lambda { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
end
end
@@ -23,7 +23,7 @@ describe :rational_div_float, shared: true do
end
it "raises a ZeroDivisionError when the argument is 0.0" do
- lambda { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
end
end
@@ -34,7 +34,7 @@ describe :rational_div_int, shared: true do
end
it "raises a ZeroDivisionError when the argument is 0" do
- lambda { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
end
end
@@ -44,11 +44,11 @@ describe :rational_div, shared: true do
end
it "raises an ArgumentError if passed more than one argument" do
- lambda { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
+ -> { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
end
# See http://redmine.ruby-lang.org/issues/show/1648
it "raises a TypeError if passed a non-numeric argument" do
- lambda { Rational(3, 4).div([]) }.should raise_error(TypeError)
+ -> { Rational(3, 4).div([]) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/rational/divide.rb b/spec/ruby/shared/rational/divide.rb
index 86d30c39d8..7d6d66390f 100644
--- a/spec/ruby/shared/rational/divide.rb
+++ b/spec/ruby/shared/rational/divide.rb
@@ -10,7 +10,7 @@ describe :rational_divide_rat, shared: true do
end
it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
- lambda { Rational(3, 4).send(@method, Rational(0, 1)) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).send(@method, Rational(0, 1)) }.should raise_error(ZeroDivisionError)
end
end
@@ -22,7 +22,7 @@ describe :rational_divide_int, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- lambda { Rational(3, 4).send(@method, 0) }.should raise_error(ZeroDivisionError)
+ -> { Rational(3, 4).send(@method, 0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/shared/rational/divmod.rb b/spec/ruby/shared/rational/divmod.rb
index 9433674007..5b319a95ff 100644
--- a/spec/ruby/shared/rational/divmod.rb
+++ b/spec/ruby/shared/rational/divmod.rb
@@ -10,7 +10,7 @@ describe :rational_divmod_rat, shared: true do
end
it "raises a ZeroDivisonError when passed a Rational with a numerator of 0" do
- lambda { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ -> { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
end
@@ -23,7 +23,7 @@ describe :rational_divmod_int, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- lambda { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
+ -> { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
end
end
@@ -37,6 +37,6 @@ describe :rational_divmod_float, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- lambda { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError)
+ -> { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/shared/rational/exponent.rb b/spec/ruby/shared/rational/exponent.rb
index ac8237c291..1d808177e9 100644
--- a/spec/ruby/shared/rational/exponent.rb
+++ b/spec/ruby/shared/rational/exponent.rb
@@ -66,7 +66,7 @@ describe :rational_exponent, shared: true do
end
it "raises ZeroDivisionError when self is Rational(0) and the exponent is negative" do
- lambda { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
+ -> { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
end
it "returns Rational(1) when self is Rational(1)" do
@@ -153,19 +153,19 @@ describe :rational_exponent, shared: true do
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Integer" do
[-1, -4, -9999].each do |exponent|
- lambda { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
+ -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational with denominator 1" do
[Rational(-1, 1), Rational(-3, 1)].each do |exponent|
- lambda { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
+ -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
# #7513
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational" do
- lambda { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0")
+ -> { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0")
end
platform_is_not :solaris do # See https://github.com/ruby/spec/issues/134
diff --git a/spec/ruby/shared/rational/modulo.rb b/spec/ruby/shared/rational/modulo.rb
index 39abaed5fe..9e4b0c49e6 100644
--- a/spec/ruby/shared/rational/modulo.rb
+++ b/spec/ruby/shared/rational/modulo.rb
@@ -22,21 +22,21 @@ describe :rational_modulo, shared: true do
end
it "raises ZeroDivisionError on zero denominator" do
- lambda {
+ -> {
Rational(3, 5).send(@method, Rational(0, 1))
}.should raise_error(ZeroDivisionError)
- lambda {
+ -> {
Rational(0, 1).send(@method, Rational(0, 1))
}.should raise_error(ZeroDivisionError)
- lambda {
+ -> {
Rational(3, 5).send(@method, 0)
}.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument is 0.0" do
- lambda {
+ -> {
Rational(3, 5).send(@method, 0.0)
}.should raise_error(ZeroDivisionError)
end
diff --git a/spec/ruby/shared/rational/round.rb b/spec/ruby/shared/rational/round.rb
index e99f884cea..5b159ee3e6 100644
--- a/spec/ruby/shared/rational/round.rb
+++ b/spec/ruby/shared/rational/round.rb
@@ -100,7 +100,7 @@ describe :rational_round, shared: true do
end
it "raise for a non-existent round mode" do
- lambda { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
+ -> { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
end
end
end
diff --git a/spec/ruby/shared/sizedqueue/enque.rb b/spec/ruby/shared/sizedqueue/enque.rb
index b724101269..6ef12349f8 100644
--- a/spec/ruby/shared/sizedqueue/enque.rb
+++ b/spec/ruby/shared/sizedqueue/enque.rb
@@ -22,7 +22,7 @@ describe :sizedqueue_enq, shared: true do
q = @object.call(2)
non_blocking = true
- add_to_queue = lambda { q.send(@method, Object.new, non_blocking) }
+ add_to_queue = -> { q.send(@method, Object.new, non_blocking) }
q.size.should == 0
add_to_queue.call
@@ -37,7 +37,7 @@ describe :sizedqueue_enq, shared: true do
q << 1
t = Thread.new {
- lambda { q.send(@method, 2) }.should raise_error(ClosedQueueError)
+ -> { q.send(@method, 2) }.should raise_error(ClosedQueueError)
}
Thread.pass until q.num_waiting == 1
diff --git a/spec/ruby/shared/sizedqueue/max.rb b/spec/ruby/shared/sizedqueue/max.rb
index cd4b47f1c1..ea10d24be0 100644
--- a/spec/ruby/shared/sizedqueue/max.rb
+++ b/spec/ruby/shared/sizedqueue/max.rb
@@ -27,21 +27,21 @@ describe :sizedqueue_max=, shared: true do
it "raises a TypeError when given a non-numeric value" do
q = @object.call(5)
- lambda { q.max = "foo" }.should raise_error(TypeError)
- lambda { q.max = Object.new }.should raise_error(TypeError)
+ -> { q.max = "foo" }.should raise_error(TypeError)
+ -> { q.max = Object.new }.should raise_error(TypeError)
end
it "raises an argument error when set to zero" do
q = @object.call(5)
q.max.should == 5
- lambda { q.max = 0 }.should raise_error(ArgumentError)
+ -> { q.max = 0 }.should raise_error(ArgumentError)
q.max.should == 5
end
it "raises an argument error when set to a negative number" do
q = @object.call(5)
q.max.should == 5
- lambda { q.max = -1 }.should raise_error(ArgumentError)
+ -> { q.max = -1 }.should raise_error(ArgumentError)
q.max.should == 5
end
end
diff --git a/spec/ruby/shared/sizedqueue/new.rb b/spec/ruby/shared/sizedqueue/new.rb
index 4439f2a9c6..713785fb50 100644
--- a/spec/ruby/shared/sizedqueue/new.rb
+++ b/spec/ruby/shared/sizedqueue/new.rb
@@ -1,18 +1,18 @@
describe :sizedqueue_new, shared: true do
it "raises a TypeError when the given argument is not Numeric" do
- lambda { @object.call("foo") }.should raise_error(TypeError)
- lambda { @object.call(Object.new) }.should raise_error(TypeError)
+ -> { @object.call("foo") }.should raise_error(TypeError)
+ -> { @object.call(Object.new) }.should raise_error(TypeError)
end
it "raises an argument error when no argument is given" do
- lambda { @object.call }.should raise_error(ArgumentError)
+ -> { @object.call }.should raise_error(ArgumentError)
end
it "raises an argument error when the given argument is zero" do
- lambda { @object.call(0) }.should raise_error(ArgumentError)
+ -> { @object.call(0) }.should raise_error(ArgumentError)
end
it "raises an argument error when the given argument is negative" do
- lambda { @object.call(-1) }.should raise_error(ArgumentError)
+ -> { @object.call(-1) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb
index e7b788d4f9..0baefd25b1 100644
--- a/spec/ruby/shared/string/times.rb
+++ b/spec/ruby/shared/string/times.rb
@@ -18,12 +18,12 @@ describe :string_times, shared: true do
end
it "raises an ArgumentError when given integer is negative" do
- lambda { @object.call("cool", -3) }.should raise_error(ArgumentError)
- lambda { @object.call("cool", -3.14) }.should raise_error(ArgumentError)
+ -> { @object.call("cool", -3) }.should raise_error(ArgumentError)
+ -> { @object.call("cool", -3.14) }.should raise_error(ArgumentError)
end
it "raises a RangeError when given integer is a Bignum" do
- lambda { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError)
+ -> { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError)
end
it "returns subclass instances" do
@@ -50,13 +50,13 @@ describe :string_times, shared: true do
platform_is wordsize: 32 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- lambda { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError)
+ -> { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError)
end
end
platform_is wordsize: 64 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- lambda { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError)
+ -> { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError)
end
end
end