diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/language | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/language')
51 files changed, 359 insertions, 359 deletions
diff --git a/spec/ruby/language/BEGIN_spec.rb b/spec/ruby/language/BEGIN_spec.rb index bd7112a0f0..58cc2bebfb 100644 --- a/spec/ruby/language/BEGIN_spec.rb +++ b/spec/ruby/language/BEGIN_spec.rb @@ -15,7 +15,7 @@ describe "The BEGIN keyword" do end it "must appear in a top-level context" do - lambda { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError) + -> { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError) end it "runs first in a given code unit" do diff --git a/spec/ruby/language/alias_spec.rb b/spec/ruby/language/alias_spec.rb index a7f34146d1..79348f70c3 100644 --- a/spec/ruby/language/alias_spec.rb +++ b/spec/ruby/language/alias_spec.rb @@ -122,7 +122,7 @@ describe "The alias keyword" do end @obj.__value.should == 5 - lambda { AliasObject.new.__value }.should raise_error(NoMethodError) + -> { AliasObject.new.__value }.should raise_error(NoMethodError) end it "operates on the class/module metaclass when used in instance_eval" do @@ -131,7 +131,7 @@ describe "The alias keyword" do end AliasObject.__klass_method.should == 7 - lambda { Object.__klass_method }.should raise_error(NoMethodError) + -> { Object.__klass_method }.should raise_error(NoMethodError) end it "operates on the class/module metaclass when used in instance_exec" do @@ -140,7 +140,7 @@ describe "The alias keyword" do end AliasObject.__klass_method2.should == 7 - lambda { Object.__klass_method2 }.should raise_error(NoMethodError) + -> { Object.__klass_method2 }.should raise_error(NoMethodError) end it "operates on methods defined via attr, attr_reader, and attr_accessor" do @@ -219,13 +219,13 @@ describe "The alias keyword" do end it "is not allowed against Fixnum or String instances" do - lambda do + -> do 1.instance_eval do alias :foo :to_s end end.should raise_error(TypeError) - lambda do + -> do :blah.instance_eval do alias :foo :to_s end @@ -238,7 +238,7 @@ describe "The alias keyword" do end it "raises a NameError when passed a missing name" do - lambda { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError) { |e| + -> { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb index bf613433e7..9230740d07 100644 --- a/spec/ruby/language/block_spec.rb +++ b/spec/ruby/language/block_spec.rb @@ -110,7 +110,7 @@ describe "A block yielded a single" do obj = mock("destructure block keyword arguments") obj.should_receive(:to_hash).and_return(1) - lambda { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(TypeError) + -> { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(TypeError) end it "raises the error raised inside #to_hash" do @@ -118,7 +118,7 @@ describe "A block yielded a single" do error = RuntimeError.new("error while converting to a hash") obj.should_receive(:to_hash).and_raise(error) - lambda { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(error) + -> { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(error) end it "does not call #to_ary on the Array" do @@ -169,7 +169,7 @@ describe "A block yielded a single" do obj = mock("destructure block arguments") obj.should_receive(:to_ary).and_return(1) - lambda { m(obj) { |a, b| } }.should raise_error(TypeError) + -> { m(obj) { |a, b| } }.should raise_error(TypeError) end end end @@ -332,14 +332,14 @@ describe "A block" do obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @y.s(obj) { |a, b| } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, b| } }.should raise_error(TypeError) end it "raises the original exception if #to_ary raises an exception" do obj = mock("block yield to_ary raising an exception") obj.should_receive(:to_ary).and_raise(ZeroDivisionError) - lambda { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError) + -> { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError) end end @@ -396,7 +396,7 @@ describe "A block" do obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @y.s(obj) { |a, *b| } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, *b| } }.should raise_error(TypeError) end end @@ -521,7 +521,7 @@ describe "A block" do obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @y.s(obj) { |a, | } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, | } }.should raise_error(TypeError) end end @@ -563,7 +563,7 @@ describe "A block" do obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @y.s(obj) { |(a, b)| } }.should raise_error(TypeError) + -> { @y.s(obj) { |(a, b)| } }.should raise_error(TypeError) end end @@ -604,7 +604,7 @@ describe "A block" do obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @y.s(obj) { |(a, b), c| } }.should raise_error(TypeError) + -> { @y.s(obj) { |(a, b), c| } }.should raise_error(TypeError) end end @@ -663,9 +663,9 @@ describe "A block" do describe "taking identically-named arguments" do it "raises a SyntaxError for standard arguments" do - lambda { eval "lambda { |x,x| }" }.should raise_error(SyntaxError) - lambda { eval "->(x,x) {}" }.should raise_error(SyntaxError) - lambda { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError) + -> { eval "lambda { |x,x| }" }.should raise_error(SyntaxError) + -> { eval "->(x,x) {}" }.should raise_error(SyntaxError) + -> { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError) end it "accepts unnamed arguments" do @@ -686,27 +686,27 @@ describe "Block-local variables" do end it "can not have the same name as one of the standard parameters" do - lambda { eval "[1].each {|foo; foo| }" }.should raise_error(SyntaxError) - lambda { eval "[1].each {|foo, bar; glark, bar| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; foo| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo, bar; glark, bar| }" }.should raise_error(SyntaxError) end it "can not be prefixed with an asterisk" do - lambda { eval "[1].each {|foo; *bar| }" }.should raise_error(SyntaxError) - lambda do + -> { eval "[1].each {|foo; *bar| }" }.should raise_error(SyntaxError) + -> do eval "[1].each {|foo, bar; glark, *fnord| }" end.should raise_error(SyntaxError) end it "can not be prefixed with an ampersand" do - lambda { eval "[1].each {|foo; &bar| }" }.should raise_error(SyntaxError) - lambda do + -> { eval "[1].each {|foo; &bar| }" }.should raise_error(SyntaxError) + -> do eval "[1].each {|foo, bar; glark, &fnord| }" end.should raise_error(SyntaxError) end it "can not be assigned default values" do - lambda { eval "[1].each {|foo; bar=1| }" }.should raise_error(SyntaxError) - lambda do + -> { eval "[1].each {|foo; bar=1| }" }.should raise_error(SyntaxError) + -> do eval "[1].each {|foo, bar; glark, fnord=:fnord| }" end.should raise_error(SyntaxError) end @@ -717,8 +717,8 @@ describe "Block-local variables" do end it "only allow a single semi-colon in the parameter list" do - lambda { eval "[1].each {|foo; bar; glark| }" }.should raise_error(SyntaxError) - lambda { eval "[1].each {|; bar; glark| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; bar; glark| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|; bar; glark| }" }.should raise_error(SyntaxError) end it "override shadowed variables from the outer scope" do @@ -781,8 +781,8 @@ describe "Post-args" do end it "are required" do - lambda { - lambda do |*a, b| + -> { + -> *a, b do [a, b] end.call }.should raise_error(ArgumentError) diff --git a/spec/ruby/language/break_spec.rb b/spec/ruby/language/break_spec.rb index 8fd6cc6f05..754d5d3c49 100644 --- a/spec/ruby/language/break_spec.rb +++ b/spec/ruby/language/break_spec.rb @@ -52,29 +52,29 @@ describe "The break statement in a captured block" do describe "when the invocation of the scope creating the block is still active" do it "raises a LocalJumpError when invoking the block from the scope creating the block" do - lambda { @program.break_in_method }.should raise_error(LocalJumpError) + -> { @program.break_in_method }.should raise_error(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :d, :b] end it "raises a LocalJumpError when invoking the block from a method" do - lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) + -> { @program.break_in_nested_method }.should raise_error(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end it "raises a LocalJumpError when yielding to the block" do - lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) + -> { @program.break_in_yielding_method }.should raise_error(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end end describe "from a scope that has returned" do it "raises a LocalJumpError when calling the block from a method" do - lambda { @program.break_in_method_captured }.should raise_error(LocalJumpError) + -> { @program.break_in_method_captured }.should raise_error(LocalJumpError) ScratchPad.recorded.should == [:a, :za, :xa, :zd, :zb] end it "raises a LocalJumpError when yielding to the block" do - lambda { @program.break_in_yield_captured }.should raise_error(LocalJumpError) + -> { @program.break_in_yield_captured }.should raise_error(LocalJumpError) ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb] end end @@ -100,7 +100,7 @@ describe "The break statement in a lambda" do end it "returns from the lambda" do - l = lambda { + l = -> { ScratchPad << :before break :foo ScratchPad << :after @@ -111,7 +111,7 @@ describe "The break statement in a lambda" do it "returns from the call site if the lambda is passed as a block" do def mid(&b) - lambda { + -> { ScratchPad << :before b.call ScratchPad << :unreachable1 @@ -208,7 +208,7 @@ describe "Break inside a while loop" do it "passes the value returned by a method with omitted parenthesis and passed block" do obj = BreakSpecs::Block.new - lambda { break obj.method :value do |x| x end }.call.should == :value + -> { break obj.method :value do |x| x end }.call.should == :value end end diff --git a/spec/ruby/language/case_spec.rb b/spec/ruby/language/case_spec.rb index 0b74efa257..1475e20f75 100644 --- a/spec/ruby/language/case_spec.rb +++ b/spec/ruby/language/case_spec.rb @@ -252,7 +252,7 @@ describe "The 'case'-construct" do end it "raises a SyntaxError when 'else' is used when no 'when' is given" do - lambda { + -> { eval <<-CODE case 4 else @@ -263,7 +263,7 @@ describe "The 'case'-construct" do end it "raises a SyntaxError when 'else' is used before a 'when' was given" do - lambda { + -> { eval <<-CODE case 4 else diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb index d07454a3a7..88b7a6a74f 100644 --- a/spec/ruby/language/class_spec.rb +++ b/spec/ruby/language/class_spec.rb @@ -30,7 +30,7 @@ describe "A class definition" do end it "raises TypeError if constant given as class name exists and is not a Module" do - lambda { + -> { class ClassSpecsNumber end }.should raise_error(TypeError) @@ -38,19 +38,19 @@ describe "A class definition" do # test case known to be detecting bugs (JRuby, MRI) it "raises TypeError if the constant qualifying the class is nil" do - lambda { + -> { class nil::Foo end }.should raise_error(TypeError) end it "raises TypeError if any constant qualifying the class is not a Module" do - lambda { + -> { class ClassSpecs::Number::MyClass end }.should raise_error(TypeError) - lambda { + -> { class ClassSpecsNumber::MyClass end }.should raise_error(TypeError) @@ -64,7 +64,7 @@ describe "A class definition" do module ClassSpecs class SuperclassResetToSubclass < L end - lambda { + -> { class SuperclassResetToSubclass < M end }.should raise_error(TypeError, /superclass mismatch/) @@ -77,7 +77,7 @@ describe "A class definition" do end SuperclassReopenedBasicObject.superclass.should == A - lambda { + -> { class SuperclassReopenedBasicObject < BasicObject end }.should raise_error(TypeError, /superclass mismatch/) @@ -92,7 +92,7 @@ describe "A class definition" do end SuperclassReopenedObject.superclass.should == A - lambda { + -> { class SuperclassReopenedObject < Object end }.should raise_error(TypeError, /superclass mismatch/) @@ -117,7 +117,7 @@ describe "A class definition" do class NoSuperclassSet end - lambda { + -> { class NoSuperclassSet < String end }.should raise_error(TypeError, /superclass mismatch/) @@ -127,7 +127,7 @@ describe "A class definition" do it "allows using self as the superclass if self is a class" do ClassSpecs::I::J.superclass.should == ClassSpecs::I - lambda { + -> { class ShouldNotWork < self; end }.should raise_error(TypeError) end @@ -148,7 +148,7 @@ describe "A class definition" do it "raises a TypeError if inheriting from a metaclass" do obj = mock("metaclass super") meta = obj.singleton_class - lambda { class ClassSpecs::MetaclassSuper < meta; end }.should raise_error(TypeError) + -> { class ClassSpecs::MetaclassSuper < meta; end }.should raise_error(TypeError) end it "allows the declaration of class variables in the body" do @@ -274,7 +274,7 @@ describe "A class definition extending an object (sclass)" do end it "raises a TypeError when trying to extend numbers" do - lambda { + -> { eval <<-CODE class << 1 def xyz @@ -310,11 +310,11 @@ describe "Reopening a class" do end it "raises a TypeError when superclasses mismatch" do - lambda { class ClassSpecs::A < Array; end }.should raise_error(TypeError) + -> { class ClassSpecs::A < Array; end }.should raise_error(TypeError) end it "adds new methods to subclasses" do - lambda { ClassSpecs::M.m }.should raise_error(NoMethodError) + -> { ClassSpecs::M.m }.should raise_error(NoMethodError) class ClassSpecs::L def self.m 1 diff --git a/spec/ruby/language/class_variable_spec.rb b/spec/ruby/language/class_variable_spec.rb index 98954023a2..dffab47a6b 100644 --- a/spec/ruby/language/class_variable_spec.rb +++ b/spec/ruby/language/class_variable_spec.rb @@ -70,14 +70,14 @@ describe 'A class variable definition' do c = Class.new(b) b.class_variable_set(:@@cv, :value) - lambda { a.class_variable_get(:@@cv) }.should raise_error(NameError) + -> { a.class_variable_get(:@@cv) }.should raise_error(NameError) b.class_variable_get(:@@cv).should == :value c.class_variable_get(:@@cv).should == :value # updates the same variable c.class_variable_set(:@@cv, :next) - lambda { a.class_variable_get(:@@cv) }.should raise_error(NameError) + -> { a.class_variable_get(:@@cv) }.should raise_error(NameError) b.class_variable_get(:@@cv).should == :next c.class_variable_get(:@@cv).should == :next end diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb index 4d848ae889..c4cf940cba 100644 --- a/spec/ruby/language/constants_spec.rb +++ b/spec/ruby/language/constants_spec.rb @@ -49,10 +49,10 @@ describe "Literal (A::X) constant resolution" do end it "does not search the singleton class of the class or module" do - lambda do + -> do ConstantSpecs::ContainerA::ChildA::CS_CONST14 end.should raise_error(NameError) - lambda { ConstantSpecs::CS_CONST14 }.should raise_error(NameError) + -> { ConstantSpecs::CS_CONST14 }.should raise_error(NameError) end end @@ -112,7 +112,7 @@ describe "Literal (A::X) constant resolution" do CS_CONST108 = :const108_1 end - lambda do + -> do ConstantSpecs::ContainerB::ChildB::CS_CONST108 end.should raise_error(NameError) @@ -122,7 +122,7 @@ describe "Literal (A::X) constant resolution" do end end - lambda { ConstantSpecs::CS_CONST108 }.should raise_error(NameError) + -> { ConstantSpecs::CS_CONST108 }.should raise_error(NameError) end it "returns the updated value when a constant is reassigned" do @@ -151,7 +151,7 @@ describe "Literal (A::X) constant resolution" do end it "raises a NameError if no constant is defined in the search path" do - lambda { ConstantSpecs::ParentA::CS_CONSTX }.should raise_error(NameError) + -> { ConstantSpecs::ParentA::CS_CONSTX }.should raise_error(NameError) end it "sends #const_missing to the original class or module scope" do @@ -163,10 +163,10 @@ describe "Literal (A::X) constant resolution" do end it "raises a TypeError if a non-class or non-module qualifier is given" do - lambda { CS_CONST1::CS_CONST }.should raise_error(TypeError) - lambda { 1::CS_CONST }.should raise_error(TypeError) - lambda { "mod"::CS_CONST }.should raise_error(TypeError) - lambda { false::CS_CONST }.should raise_error(TypeError) + -> { CS_CONST1::CS_CONST }.should raise_error(TypeError) + -> { 1::CS_CONST }.should raise_error(TypeError) + -> { "mod"::CS_CONST }.should raise_error(TypeError) + -> { false::CS_CONST }.should raise_error(TypeError) end end @@ -212,7 +212,7 @@ describe "Constant resolution within methods" do end it "does not search the lexical scope of the caller" do - lambda { ConstantSpecs::ClassA.const16 }.should raise_error(NameError) + -> { ConstantSpecs::ClassA.const16 }.should raise_error(NameError) end it "searches the lexical scope of a block" do @@ -225,7 +225,7 @@ describe "Constant resolution within methods" do end it "does not search the lexical scope of qualifying modules" do - lambda do + -> do ConstantSpecs::ContainerA::ChildA.const23 end.should raise_error(NameError) end @@ -302,7 +302,7 @@ describe "Constant resolution within methods" do it "does not search the lexical scope of the caller" do ConstantSpecs::ClassB::CS_CONST209 = :const209 - lambda { ConstantSpecs::ClassB.const209 }.should raise_error(NameError) + -> { ConstantSpecs::ClassB.const209 }.should raise_error(NameError) end it "searches the lexical scope of a block" do @@ -337,14 +337,14 @@ describe "Constant resolution within methods" do it "does not search the lexical scope of qualifying modules" do ConstantSpecs::ContainerB::CS_CONST214 = :const214 - lambda do + -> do ConstantSpecs::ContainerB::ChildB.const214 end.should raise_error(NameError) end end it "raises a NameError if no constant is defined in the search path" do - lambda { ConstantSpecs::ParentA.constx }.should raise_error(NameError) + -> { ConstantSpecs::ParentA.constx }.should raise_error(NameError) end it "sends #const_missing to the original class or module scope" do @@ -427,7 +427,7 @@ describe "top-level constant lookup" do context "on a class" do ruby_version_is "" ... "2.5" do it "searches Object successfully after searching other scopes" do - ->() { + -> { String::Hash.should == Hash }.should complain(/toplevel constant Hash referenced by/) end @@ -435,13 +435,13 @@ describe "top-level constant lookup" do ruby_version_is "2.5" do it "does not search Object after searching other scopes" do - ->() { String::Hash }.should raise_error(NameError) + -> { String::Hash }.should raise_error(NameError) end end end it "searches Object unsuccessfully when searches on a module" do - ->() { Enumerable::Hash }.should raise_error(NameError) + -> { Enumerable::Hash }.should raise_error(NameError) end end @@ -455,7 +455,7 @@ describe "Module#private_constant marked constants" do mod.const_set :Foo, false }.should complain(/already initialized constant/) - lambda {mod::Foo}.should raise_error(NameError) + -> {mod::Foo}.should raise_error(NameError) end ruby_version_is "2.6" do @@ -473,19 +473,19 @@ describe "Module#private_constant marked constants" do describe "in a module" do it "cannot be accessed from outside the module" do - lambda do + -> do ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE end.should raise_error(NameError) end it "cannot be reopened as a module from scope where constant would be private" do - lambda do + -> do module ConstantVisibility::ModuleContainer::PrivateModule; end end.should raise_error(NameError) end it "cannot be reopened as a class from scope where constant would be private" do - lambda do + -> do class ConstantVisibility::ModuleContainer::PrivateClass; end end.should raise_error(NameError) end @@ -541,19 +541,19 @@ describe "Module#private_constant marked constants" do describe "in a class" do it "cannot be accessed from outside the class" do - lambda do + -> do ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS end.should raise_error(NameError) end it "cannot be reopened as a module" do - lambda do + -> do module ConstantVisibility::ClassContainer::PrivateModule; end end.should raise_error(NameError) end it "cannot be reopened as a class" do - lambda do + -> do class ConstantVisibility::ClassContainer::PrivateClass; end end.should raise_error(NameError) end @@ -609,7 +609,7 @@ describe "Module#private_constant marked constants" do describe "in Object" do it "cannot be accessed using ::Const form" do - lambda do + -> do ::PRIVATE_CONSTANT_IN_OBJECT end.should raise_error(NameError) end @@ -629,14 +629,14 @@ describe "Module#private_constant marked constants" do describe "NameError by #private_constant" do it "has :receiver and :name attributes" do - lambda do + -> do ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS end.should raise_error(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstClass e.name.should == :PRIVATE_CONSTANT_CLASS } - lambda do + -> do ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE end.should raise_error(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstModule @@ -645,14 +645,14 @@ describe "Module#private_constant marked constants" do end it "has the defined class as the :name attribute" do - lambda do + -> do ConstantVisibility::PrivConstClassChild::PRIVATE_CONSTANT_CLASS end.should raise_error(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstClass e.name.should == :PRIVATE_CONSTANT_CLASS } - lambda do + -> do ConstantVisibility::PrivConstModuleChild::PRIVATE_CONSTANT_MODULE end.should raise_error(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstModule diff --git a/spec/ruby/language/def_spec.rb b/spec/ruby/language/def_spec.rb index dee60c9adf..82813bd36c 100644 --- a/spec/ruby/language/def_spec.rb +++ b/spec/ruby/language/def_spec.rb @@ -82,12 +82,12 @@ end describe "An instance method" do it "raises an error with too few arguments" do def foo(a, b); end - lambda { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2)') + -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2)') end it "raises an error with too many arguments" do def foo(a); end - lambda { foo 1, 2 }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') + -> { foo 1, 2 }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') end end @@ -113,12 +113,12 @@ describe "An instance method definition with a splat" do end it "allows only a single * argument" do - lambda { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError) + -> { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError) end it "requires the presence of any arguments that precede the *" do def foo(a, b, *c); end - lambda { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2+)') + -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2+)') end end @@ -151,7 +151,7 @@ describe "An instance method with a default argument" do def foo(a, b = 2) [a,b] end - lambda { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1..2)') + -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1..2)') foo(1).should == [1, 2] end @@ -159,7 +159,7 @@ describe "An instance method with a default argument" do def foo(a, b = 2, *c) [a,b,c] end - lambda { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1+)') + -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1+)') foo(1).should == [1,2,[]] end @@ -249,7 +249,7 @@ describe "A singleton method definition" do it "raises #{frozen_error_class} if frozen" do obj = Object.new obj.freeze - lambda { def obj.foo; end }.should raise_error(frozen_error_class) + -> { def obj.foo; end }.should raise_error(frozen_error_class) end end @@ -322,7 +322,7 @@ describe "A method defined with extreme default arguments" do end it "may use a lambda as a default" do - def foo(output = 'a', prc = lambda {|n| output * n}) + def foo(output = 'a', prc = -> n { output * n }) prc.call(5) end foo.should == 'aaaaa' @@ -368,7 +368,7 @@ describe "A singleton method defined with extreme default arguments" do it "may use a lambda as a default" do a = Object.new - def a.foo(output = 'a', prc = lambda {|n| output * n}) + def a.foo(output = 'a', prc = -> n { output * n }) prc.call(5) end a.foo.should == 'aaaaa' @@ -384,7 +384,7 @@ describe "A method definition inside a metaclass scope" do end DefSpecSingleton.a_class_method.should == DefSpecSingleton - lambda { Object.a_class_method }.should raise_error(NoMethodError) + -> { Object.a_class_method }.should raise_error(NoMethodError) end it "can create a singleton method" do @@ -394,7 +394,7 @@ describe "A method definition inside a metaclass scope" do end obj.a_singleton_method.should == obj - lambda { Object.new.a_singleton_method }.should raise_error(NoMethodError) + -> { Object.new.a_singleton_method }.should raise_error(NoMethodError) end it "raises #{frozen_error_class} if frozen" do @@ -402,7 +402,7 @@ describe "A method definition inside a metaclass scope" do obj.freeze class << obj - lambda { def foo; end }.should raise_error(frozen_error_class) + -> { def foo; end }.should raise_error(frozen_error_class) end end end @@ -438,11 +438,11 @@ describe "A nested method definition" do end end - lambda { DefSpecNested.a_class_method }.should raise_error(NoMethodError) + -> { DefSpecNested.a_class_method }.should raise_error(NoMethodError) DefSpecNested.create_class_method.should == DefSpecNested DefSpecNested.a_class_method.should == DefSpecNested - lambda { Object.a_class_method }.should raise_error(NoMethodError) - lambda { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError) + -> { Object.a_class_method }.should raise_error(NoMethodError) + -> { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError) end it "creates a singleton method when evaluated in the metaclass of an instance" do @@ -460,7 +460,7 @@ describe "A nested method definition" do obj.a_singleton_method.should == obj other = DefSpecNested.new - lambda { other.a_singleton_method }.should raise_error(NoMethodError) + -> { other.a_singleton_method }.should raise_error(NoMethodError) end it "creates a method in the surrounding context when evaluated in a def expr.method" do @@ -559,7 +559,7 @@ describe "A method definition inside an instance_eval" do obj.an_instance_eval_method.should == obj other = Object.new - lambda { other.an_instance_eval_method }.should raise_error(NoMethodError) + -> { other.an_instance_eval_method }.should raise_error(NoMethodError) end it "creates a singleton method when evaluated inside a metaclass" do @@ -572,7 +572,7 @@ describe "A method definition inside an instance_eval" do obj.a_metaclass_eval_method.should == obj other = Object.new - lambda { other.a_metaclass_eval_method }.should raise_error(NoMethodError) + -> { other.a_metaclass_eval_method }.should raise_error(NoMethodError) end it "creates a class method when the receiver is a class" do @@ -581,7 +581,7 @@ describe "A method definition inside an instance_eval" do end DefSpecNested.an_instance_eval_class_method.should == DefSpecNested - lambda { Object.an_instance_eval_class_method }.should raise_error(NoMethodError) + -> { Object.an_instance_eval_class_method }.should raise_error(NoMethodError) end it "creates a class method when the receiver is an anonymous class" do @@ -593,7 +593,7 @@ describe "A method definition inside an instance_eval" do end m.klass_method.should == :test - lambda { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should raise_error(NoMethodError) end it "creates a class method when instance_eval is within class" do @@ -606,7 +606,7 @@ describe "A method definition inside an instance_eval" do end m.klass_method.should == :test - lambda { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should raise_error(NoMethodError) end end @@ -619,7 +619,7 @@ describe "A method definition inside an instance_exec" do end DefSpecNested.an_instance_exec_class_method.should == 1 - lambda { Object.an_instance_exec_class_method }.should raise_error(NoMethodError) + -> { Object.an_instance_exec_class_method }.should raise_error(NoMethodError) end it "creates a class method when the receiver is an anonymous class" do @@ -633,7 +633,7 @@ describe "A method definition inside an instance_exec" do end m.klass_method.should == 1 - lambda { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should raise_error(NoMethodError) end it "creates a class method when instance_exec is within class" do @@ -648,7 +648,7 @@ describe "A method definition inside an instance_exec" do end m.klass_method.should == 2 - lambda { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should raise_error(NoMethodError) end end @@ -668,7 +668,7 @@ describe "A method definition in an eval" do other = DefSpecNested.new other.an_eval_instance_method.should == other - lambda { Object.new.an_eval_instance_method }.should raise_error(NoMethodError) + -> { Object.new.an_eval_instance_method }.should raise_error(NoMethodError) end it "creates a class method" do @@ -684,8 +684,8 @@ describe "A method definition in an eval" do DefSpecNestedB.eval_class_method.should == DefSpecNestedB DefSpecNestedB.an_eval_class_method.should == DefSpecNestedB - lambda { Object.an_eval_class_method }.should raise_error(NoMethodError) - lambda { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError) + -> { Object.an_eval_class_method }.should raise_error(NoMethodError) + -> { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError) end it "creates a singleton method" do @@ -703,7 +703,7 @@ describe "A method definition in an eval" do obj.an_eval_singleton_method.should == obj other = DefSpecNested.new - lambda { other.an_eval_singleton_method }.should raise_error(NoMethodError) + -> { other.an_eval_singleton_method }.should raise_error(NoMethodError) end end @@ -729,7 +729,7 @@ describe "a method definition that sets more than one default parameter all to t end it "only allows overriding the default value of the first such parameter in each set" do - lambda { foo(1,2) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0..1)') + -> { foo(1,2) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0..1)') end def bar(a=b=c=1,d=2) @@ -740,7 +740,7 @@ describe "a method definition that sets more than one default parameter all to t bar.should == [1,1,1,2] bar(3).should == [3,nil,nil,2] bar(3,4).should == [3,nil,nil,4] - lambda { bar(3,4,5) }.should raise_error(ArgumentError, 'wrong number of arguments (given 3, expected 0..2)') + -> { bar(3,4,5) }.should raise_error(ArgumentError, 'wrong number of arguments (given 3, expected 0..2)') end end @@ -750,7 +750,7 @@ describe "The def keyword" do module DefSpecsLambdaVisibility private - lambda { + -> { def some_method; end }.call end diff --git a/spec/ruby/language/encoding_spec.rb b/spec/ruby/language/encoding_spec.rb index fb36a9618e..5430c9cb98 100644 --- a/spec/ruby/language/encoding_spec.rb +++ b/spec/ruby/language/encoding_spec.rb @@ -31,6 +31,6 @@ describe "The __ENCODING__ pseudo-variable" do end it "raises a SyntaxError if assigned to" do - lambda { eval("__ENCODING__ = 1") }.should raise_error(SyntaxError) + -> { eval("__ENCODING__ = 1") }.should raise_error(SyntaxError) end end diff --git a/spec/ruby/language/ensure_spec.rb b/spec/ruby/language/ensure_spec.rb index 064627b2f7..a930bda36b 100644 --- a/spec/ruby/language/ensure_spec.rb +++ b/spec/ruby/language/ensure_spec.rb @@ -7,7 +7,7 @@ describe "An ensure block inside a begin block" do end it "is executed when an exception is raised in it's corresponding begin block" do - lambda { + -> { begin ScratchPad << :begin raise EnsureSpec::Error @@ -108,7 +108,7 @@ describe "An ensure block inside a method" do end it "is executed when an exception is raised in the method" do - lambda { @obj.raise_in_method_with_ensure }.should raise_error(EnsureSpec::Error) + -> { @obj.raise_in_method_with_ensure }.should raise_error(EnsureSpec::Error) @obj.executed.should == [:method, :ensure] end @@ -165,7 +165,7 @@ describe "An ensure block inside a class" do end it "is executed when an exception is raised" do - lambda { + -> { eval <<-ruby class EnsureInClassExample ScratchPad << :class @@ -240,7 +240,7 @@ end describe "An ensure block inside {} block" do it "is not allowed" do - lambda { + -> { eval <<-ruby lambda { raise @@ -258,7 +258,7 @@ ruby_version_is "2.5" do end it "is executed when an exception is raised in it's corresponding begin block" do - lambda { + -> { eval(<<-ruby).call lambda do ScratchPad << :begin diff --git a/spec/ruby/language/file_spec.rb b/spec/ruby/language/file_spec.rb index bf7175a9bc..729dee1008 100644 --- a/spec/ruby/language/file_spec.rb +++ b/spec/ruby/language/file_spec.rb @@ -4,7 +4,7 @@ require_relative 'shared/__FILE__' describe "The __FILE__ pseudo-variable" do it "raises a SyntaxError if assigned to" do - lambda { eval("__FILE__ = 1") }.should raise_error(SyntaxError) + -> { eval("__FILE__ = 1") }.should raise_error(SyntaxError) end it "equals (eval) inside an eval" do diff --git a/spec/ruby/language/fixtures/break.rb b/spec/ruby/language/fixtures/break.rb index 2d07cc3d48..217c20a2c0 100644 --- a/spec/ruby/language/fixtures/break.rb +++ b/spec/ruby/language/fixtures/break.rb @@ -163,7 +163,7 @@ module BreakSpecs # on the call stack when the lambda is invoked. def break_in_defining_scope(value=true) note :a - note lambda { + note -> { note :b if value break :break @@ -177,7 +177,7 @@ module BreakSpecs def break_in_nested_scope note :a - l = lambda do + l = -> do note :b break :break note :c @@ -197,7 +197,7 @@ module BreakSpecs def break_in_nested_scope_yield note :a - l = lambda do + l = -> do note :b break :break note :c @@ -217,7 +217,7 @@ module BreakSpecs def break_in_nested_scope_block note :a - l = lambda do + l = -> do note :b break :break note :c @@ -251,7 +251,7 @@ module BreakSpecs # active on the call stack when the lambda is invoked. def create_lambda note :la - l = lambda do + l = -> do note :lb break :break note :lc diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel.rb b/spec/ruby/language/fixtures/break_lambda_toplevel.rb index 05af1d3fdc..da5abbaf00 100644 --- a/spec/ruby/language/fixtures/break_lambda_toplevel.rb +++ b/spec/ruby/language/fixtures/break_lambda_toplevel.rb @@ -1,6 +1,6 @@ print "a," -print lambda { +print -> { print "b," break "break," print "c," diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb b/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb index a35cb8a8a1..3dcee62424 100644 --- a/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb +++ b/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb @@ -1,6 +1,6 @@ print "a," -l = lambda { +l = -> { print "b," break "break," print "c," diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb b/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb index 200040d614..a5936a3d70 100644 --- a/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb +++ b/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb @@ -1,6 +1,6 @@ print "a," -l = lambda { +l = -> { print "b," break "break," print "c," diff --git a/spec/ruby/language/fixtures/super.rb b/spec/ruby/language/fixtures/super.rb index 93cb9f13b7..6a024cae23 100644 --- a/spec/ruby/language/fixtures/super.rb +++ b/spec/ruby/language/fixtures/super.rb @@ -282,7 +282,7 @@ module SuperSpecs # # When name3 is called then, Alias2 (NOT Alias3) is presented as the # current module to Alias2#name, so that when super is called, - # Alias2->superclass is next. + # Alias2's superclass is next. # # Otherwise, Alias2 is next, which is where name was to begin with, # causing the wrong #name method to be called. @@ -377,12 +377,12 @@ module SuperSpecs end def b - block_ref = lambda { 15 } + block_ref = -> { 15 } [super { 14 }, super(&block_ref)] end def c - block_ref = lambda { 16 } + block_ref = -> { 16 } super(&block_ref) end end diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb index 3d29f4bc72..4bce241e76 100644 --- a/spec/ruby/language/hash_spec.rb +++ b/spec/ruby/language/hash_spec.rb @@ -63,7 +63,7 @@ describe "Hash literal" do end it "with '==>' in the middle raises SyntaxError" do - lambda { eval("{:a ==> 1}") }.should raise_error(SyntaxError) + -> { eval("{:a ==> 1}") }.should raise_error(SyntaxError) end it "constructs a new hash with the given elements" do @@ -130,14 +130,14 @@ describe "Hash literal" do it "raises a TypeError if any splatted elements keys are not symbols" do h = {1 => 2, b: 3} - lambda { {a: 1, **h} }.should raise_error(TypeError) + -> { {a: 1, **h} }.should raise_error(TypeError) end it "raises a TypeError if #to_hash does not return a Hash" do obj = mock("hash splat") obj.should_receive(:to_hash).and_return(obj) - lambda { {**obj} }.should raise_error(TypeError) + -> { {**obj} }.should raise_error(TypeError) end it "does not change encoding of literal string keys during creation" do diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb index a1140552bf..a4c265d80c 100644 --- a/spec/ruby/language/lambda_spec.rb +++ b/spec/ruby/language/lambda_spec.rb @@ -7,7 +7,7 @@ describe "A lambda literal -> () { }" do it "returns a Proc object when used in a BasicObject method" do klass = Class.new(BasicObject) do def create_lambda - -> () { } + -> { } end end @@ -15,11 +15,11 @@ describe "A lambda literal -> () { }" do end it "does not execute the block" do - ->() { fail }.should be_an_instance_of(Proc) + -> { fail }.should be_an_instance_of(Proc) end it "returns a lambda" do - -> () { }.lambda?.should be_true + -> { }.lambda?.should be_true end ruby_version_is "2.6" do @@ -111,7 +111,7 @@ describe "A lambda literal -> () { }" do @a = -> (a:) { a } ruby - lambda { @a.() }.should raise_error(ArgumentError) + -> { @a.() }.should raise_error(ArgumentError) @a.(a: 1).should == 1 end @@ -129,7 +129,7 @@ describe "A lambda literal -> () { }" do @a.().should be_nil @a.(a: 1, b: 2).should be_nil - lambda { @a.(1) }.should raise_error(ArgumentError) + -> { @a.(1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -153,8 +153,8 @@ describe "A lambda literal -> () { }" do ruby @a.(1, 2).should == [1, 2] - lambda { @a.() }.should raise_error(ArgumentError) - lambda { @a.(1) }.should raise_error(ArgumentError) + -> { @a.() }.should raise_error(ArgumentError) + -> { @a.(1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -283,7 +283,7 @@ describe "A lambda literal -> () { }" do it "calls an existing method with the same name as the argument if explicitly using ()" do def a; 1; end - -> (a=a()) { a }.call.should == 1 + -> a=a() { a }.call.should == 1 end end end diff --git a/spec/ruby/language/line_spec.rb b/spec/ruby/language/line_spec.rb index aac039a941..fcadaa71d7 100644 --- a/spec/ruby/language/line_spec.rb +++ b/spec/ruby/language/line_spec.rb @@ -4,7 +4,7 @@ require_relative 'shared/__LINE__' describe "The __LINE__ pseudo-variable" do it "raises a SyntaxError if assigned to" do - lambda { eval("__LINE__ = 1") }.should raise_error(SyntaxError) + -> { eval("__LINE__ = 1") }.should raise_error(SyntaxError) end before :each do diff --git a/spec/ruby/language/loop_spec.rb b/spec/ruby/language/loop_spec.rb index 121872a104..fd17b53910 100644 --- a/spec/ruby/language/loop_spec.rb +++ b/spec/ruby/language/loop_spec.rb @@ -15,7 +15,7 @@ describe "The loop expression" do inner_loop = 123 break end - lambda { inner_loop }.should raise_error(NameError) + -> { inner_loop }.should raise_error(NameError) end it "returns the value passed to break if interrupted by break" do diff --git a/spec/ruby/language/metaclass_spec.rb b/spec/ruby/language/metaclass_spec.rb index a6525a3ef2..fc83067977 100644 --- a/spec/ruby/language/metaclass_spec.rb +++ b/spec/ruby/language/metaclass_spec.rb @@ -16,11 +16,11 @@ describe "self in a metaclass body (class << obj)" do end it "raises a TypeError for numbers" do - lambda { class << 1; self; end }.should raise_error(TypeError) + -> { class << 1; self; end }.should raise_error(TypeError) end it "raises a TypeError for symbols" do - lambda { class << :symbol; self; end }.should raise_error(TypeError) + -> { class << :symbol; self; end }.should raise_error(TypeError) end it "is a singleton Class instance" do @@ -64,11 +64,11 @@ describe "A constant on a metaclass" do class << @object CONST end - lambda { CONST }.should raise_error(NameError) + -> { CONST }.should raise_error(NameError) end it "cannot be accessed via object::CONST" do - lambda do + -> do @object::CONST end.should raise_error(TypeError) end @@ -79,7 +79,7 @@ describe "A constant on a metaclass" do CONST = 100 end - lambda do + -> do @object::CONST end.should raise_error(NameError) end @@ -96,7 +96,7 @@ describe "A constant on a metaclass" do it "is not preserved when the object is duped" do @object = @object.dup - lambda do + -> do class << @object; CONST; end end.should raise_error(NameError) end diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb index b0fc521d69..3e5ff3fbb5 100644 --- a/spec/ruby/language/method_spec.rb +++ b/spec/ruby/language/method_spec.rb @@ -40,7 +40,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(*x) }.should raise_error(TypeError) + -> { m(*x) }.should raise_error(TypeError) end end @@ -74,7 +74,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(*x, 2, 3) }.should raise_error(TypeError) + -> { m(*x, 2, 3) }.should raise_error(TypeError) end end @@ -108,7 +108,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(1, *x, 2, 3) }.should raise_error(TypeError) + -> { m(1, *x, 2, 3) }.should raise_error(TypeError) end it "copies the splatted array" do @@ -153,7 +153,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(1, 2, *x) }.should raise_error(TypeError) + -> { m(1, 2, *x) }.should raise_error(TypeError) end end end @@ -197,7 +197,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[*x] = 1 }.should raise_error(TypeError) + -> { @o[*x] = 1 }.should raise_error(TypeError) end end @@ -235,7 +235,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[*x, 2, 3] = 4 }.should raise_error(TypeError) + -> { @o[*x, 2, 3] = 4 }.should raise_error(TypeError) end end @@ -273,7 +273,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError) end end @@ -311,7 +311,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError) end end end @@ -348,7 +348,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, *x, 1 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 1 }.should raise_error(TypeError) end end @@ -383,7 +383,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError) end end @@ -418,7 +418,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError) end end @@ -453,7 +453,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError) end end end @@ -544,9 +544,9 @@ describe "A method" do def m(a:) a end ruby - lambda { m() }.should raise_error(ArgumentError) + -> { m() }.should raise_error(ArgumentError) m(a: 1).should == 1 - lambda { m("a" => 1, a: 1) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -563,7 +563,7 @@ describe "A method" do m().should be_nil m(a: 1, b: 2).should be_nil - lambda { m(1) }.should raise_error(ArgumentError) + -> { m(1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -575,7 +575,7 @@ describe "A method" do m(*[]).should == {} m(**{}).should == {} m(**{a: 1, b: 2}, **{a: 4, c: 7}).should == { a: 4, b: 2, c: 7 } - lambda { m(2) }.should raise_error(ArgumentError) + -> { m(2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -614,7 +614,7 @@ describe "A method" do m(2, 3).should be_nil m([2, 3, 4], [5, 6]).should be_nil - lambda { m a: 1 }.should raise_error(ArgumentError) + -> { m a: 1 }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -706,7 +706,7 @@ describe "A method" do ruby m(1, b: 2).should == [1, 2] - lambda { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -808,8 +808,8 @@ describe "A method" do def m(a=1, (*b), (*c)) [a, b, c] end ruby - lambda { m() }.should raise_error(ArgumentError) - lambda { m(2) }.should raise_error(ArgumentError) + -> { m() }.should raise_error(ArgumentError) + -> { m(2) }.should raise_error(ArgumentError) m(2, 3).should == [1, [2], [3]] m(2, [3, 4], [5, 6]).should == [2, [3, 4], [5, 6]] end @@ -966,7 +966,7 @@ describe "A method" do h = mock("keyword splat") error = RuntimeError.new("error while converting to a hash") h.should_receive(:to_hash).and_raise(error) - lambda { m(h) }.should raise_error(error) + -> { m(h) }.should raise_error(error) end evaluate <<-ruby do @@ -980,7 +980,7 @@ describe "A method" do h = mock("keyword splat") h.should_receive(:to_hash) - lambda { m(**h) }.should raise_error(TypeError) + -> { m(**h) }.should raise_error(TypeError) end evaluate <<-ruby do @@ -1077,7 +1077,7 @@ describe "A method" do ruby m(a: 1, b: 2).should == [1, 2] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1086,7 +1086,7 @@ describe "A method" do m(a: 1).should == [1, 1] m(a: 1, b: 2).should == [1, 2] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1095,7 +1095,7 @@ describe "A method" do m(a: 1).should == 1 m(a: 1, b: 2).should == 1 - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1104,7 +1104,7 @@ describe "A method" do m(a: 1).should == [1, {}] m(a: 1, b: 2, c: 3).should == [1, {b: 2, c: 3}] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1224,7 +1224,7 @@ describe "A method" do ruby options = {a: 1}.freeze - lambda do + -> do m(options).should == 1 end.should_not raise_error options.should == {a: 1} @@ -1259,11 +1259,11 @@ describe "A method call with a space between method name and parentheses" do context "when 2+ arguments provided" do it "raises a syntax error" do - lambda { + -> { eval("m (1, 2)") }.should raise_error(SyntaxError) - lambda { + -> { eval("m (1, 2, 3)") }.should raise_error(SyntaxError) end diff --git a/spec/ruby/language/module_spec.rb b/spec/ruby/language/module_spec.rb index 72d0046fb8..1b41e184bb 100644 --- a/spec/ruby/language/module_spec.rb +++ b/spec/ruby/language/module_spec.rb @@ -34,29 +34,29 @@ describe "The module keyword" do end it "raises a TypeError if the constant is a Class" do - lambda do + -> do module ModuleSpecs::Modules::Klass; end end.should raise_error(TypeError) end it "raises a TypeError if the constant is a String" do - lambda { module ModuleSpecs::Modules::A; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::A; end }.should raise_error(TypeError) end it "raises a TypeError if the constant is a Fixnum" do - lambda { module ModuleSpecs::Modules::B; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::B; end }.should raise_error(TypeError) end it "raises a TypeError if the constant is nil" do - lambda { module ModuleSpecs::Modules::C; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::C; end }.should raise_error(TypeError) end it "raises a TypeError if the constant is true" do - lambda { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) end it "raises a TypeError if the constant is false" do - lambda { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) end end diff --git a/spec/ruby/language/next_spec.rb b/spec/ruby/language/next_spec.rb index e0a0265ac6..6fbfc4a54d 100644 --- a/spec/ruby/language/next_spec.rb +++ b/spec/ruby/language/next_spec.rb @@ -8,7 +8,7 @@ describe "The next statement from within the block" do it "ends block execution" do a = [] - lambda { + -> { a << 1 next a << 2 @@ -17,15 +17,15 @@ describe "The next statement from within the block" do end it "causes block to return nil if invoked without arguments" do - lambda { 123; next; 456 }.call.should == nil + -> { 123; next; 456 }.call.should == nil end it "causes block to return nil if invoked with an empty expression" do - lambda { next (); 456 }.call.should be_nil + -> { next (); 456 }.call.should be_nil end it "returns the argument passed" do - lambda { 123; next 234; 345 }.call.should == 234 + -> { 123; next 234; 345 }.call.should == 234 end it "returns to the invoking method" do @@ -102,14 +102,14 @@ describe "The next statement from within the block" do it "passes the value returned by a method with omitted parenthesis and passed block" do obj = NextSpecs::Block.new - lambda { next obj.method :value do |x| x end }.call.should == :value + -> { next obj.method :value do |x| x end }.call.should == :value end end describe "The next statement" do describe "in a method" do it "is invalid and raises a SyntaxError" do - lambda { + -> { eval("def m; next; end") }.should raise_error(SyntaxError) end diff --git a/spec/ruby/language/numbers_spec.rb b/spec/ruby/language/numbers_spec.rb index 080c4ae6a3..c82a630632 100644 --- a/spec/ruby/language/numbers_spec.rb +++ b/spec/ruby/language/numbers_spec.rb @@ -11,7 +11,7 @@ describe "A number literal" do end it "cannot have a leading underscore" do - lambda { eval("_4_2") }.should raise_error(NameError) + -> { eval("_4_2") }.should raise_error(NameError) end it "can have a decimal point" do @@ -20,8 +20,8 @@ describe "A number literal" do it "must have a digit before the decimal point" do 0.75.should == 0.75 - lambda { eval(".75") }.should raise_error(SyntaxError) - lambda { eval("-.75") }.should raise_error(SyntaxError) + -> { eval(".75") }.should raise_error(SyntaxError) + -> { eval("-.75") }.should raise_error(SyntaxError) end it "can have an exponent" do diff --git a/spec/ruby/language/optional_assignments_spec.rb b/spec/ruby/language/optional_assignments_spec.rb index 29103c67fd..04abc2496b 100644 --- a/spec/ruby/language/optional_assignments_spec.rb +++ b/spec/ruby/language/optional_assignments_spec.rb @@ -280,7 +280,7 @@ describe 'Optional variable assignments' do end it 'with &&= assignments will fail with non-existent constants' do - lambda { Object::A &&= 10 }.should raise_error(NameError) + -> { Object::A &&= 10 }.should raise_error(NameError) end it 'with operator assignments' do @@ -292,7 +292,7 @@ describe 'Optional variable assignments' do end it 'with operator assignments will fail with non-existent constants' do - lambda { Object::A += 10 }.should raise_error(NameError) + -> { Object::A += 10 }.should raise_error(NameError) end end end diff --git a/spec/ruby/language/or_spec.rb b/spec/ruby/language/or_spec.rb index 88241f39e6..fb75e788f1 100644 --- a/spec/ruby/language/or_spec.rb +++ b/spec/ruby/language/or_spec.rb @@ -35,15 +35,15 @@ describe "The || operator" do it "has a higher precedence than 'break' in 'break true || false'" do # see also 'break true or false' below - lambda { break false || true }.call.should be_true + -> { break false || true }.call.should be_true end it "has a higher precedence than 'next' in 'next true || false'" do - lambda { next false || true }.call.should be_true + -> { next false || true }.call.should be_true end it "has a higher precedence than 'return' in 'return true || false'" do - lambda { return false || true }.call.should be_true + -> { return false || true }.call.should be_true end end @@ -77,14 +77,14 @@ describe "The or operator" do it "has a lower precedence than 'break' in 'break true or false'" do # see also 'break true || false' above - lambda { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/) end it "has a lower precedence than 'next' in 'next true or false'" do - lambda { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/) end it "has a lower precedence than 'return' in 'return true or false'" do - lambda { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/) end end diff --git a/spec/ruby/language/precedence_spec.rb b/spec/ruby/language/precedence_spec.rb index a342c82156..a911f765b0 100644 --- a/spec/ruby/language/precedence_spec.rb +++ b/spec/ruby/language/precedence_spec.rb @@ -253,12 +253,12 @@ describe "Operators" do end it "<=> == === != =~ !~ are non-associative" do - lambda { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError) - lambda { eval("1 == 2 == 3") }.should raise_error(SyntaxError) - lambda { eval("1 === 2 === 3") }.should raise_error(SyntaxError) - lambda { eval("1 != 2 != 3") }.should raise_error(SyntaxError) - lambda { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError) - lambda { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError) + -> { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError) + -> { eval("1 == 2 == 3") }.should raise_error(SyntaxError) + -> { eval("1 === 2 === 3") }.should raise_error(SyntaxError) + -> { eval("1 != 2 != 3") }.should raise_error(SyntaxError) + -> { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError) + -> { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError) end it "<=> == === != =~ !~ have higher precedence than &&" do @@ -292,8 +292,8 @@ describe "Operators" do end it ".. ... are non-associative" do - lambda { eval("1..2..3") }.should raise_error(SyntaxError) - lambda { eval("1...2...3") }.should raise_error(SyntaxError) + -> { eval("1..2..3") }.should raise_error(SyntaxError) + -> { eval("1...2...3") }.should raise_error(SyntaxError) end it ".. ... have higher precedence than ? :" do diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb index 61ca0d8237..90ea8c6bb1 100644 --- a/spec/ruby/language/predefined_spec.rb +++ b/spec/ruby/language/predefined_spec.rb @@ -92,8 +92,8 @@ describe "Predefined global $~" do $~ = /foo/.match("foo") $~.should be_an_instance_of(MatchData) - lambda { $~ = Object.new }.should raise_error(TypeError) - lambda { $~ = 1 }.should raise_error(TypeError) + -> { $~ = Object.new }.should raise_error(TypeError) + -> { $~ = 1 }.should raise_error(TypeError) end it "changes the value of derived capture globals when assigned" do @@ -233,12 +233,12 @@ describe "Predefined global $stdout" do end it "raises TypeError error if assigned to nil" do - lambda { $stdout = nil }.should raise_error(TypeError) + -> { $stdout = nil }.should raise_error(TypeError) end it "raises TypeError error if assigned to object that doesn't respond to #write" do obj = mock('object') - lambda { $stdout = obj }.should raise_error(TypeError) + -> { $stdout = obj }.should raise_error(TypeError) obj.stub!(:write) $stdout = obj @@ -562,15 +562,15 @@ describe "Predefined global $/" do obj = mock("$/ value") obj.should_not_receive(:to_str) - lambda { $/ = obj }.should raise_error(TypeError) + -> { $/ = obj }.should raise_error(TypeError) end it "raises a TypeError if assigned a Fixnum" do - lambda { $/ = 1 }.should raise_error(TypeError) + -> { $/ = 1 }.should raise_error(TypeError) end it "raises a TypeError if assigned a boolean" do - lambda { $/ = true }.should raise_error(TypeError) + -> { $/ = true }.should raise_error(TypeError) end end @@ -609,15 +609,15 @@ describe "Predefined global $-0" do obj = mock("$-0 value") obj.should_not_receive(:to_str) - lambda { $-0 = obj }.should raise_error(TypeError) + -> { $-0 = obj }.should raise_error(TypeError) end it "raises a TypeError if assigned a Fixnum" do - lambda { $-0 = 1 }.should raise_error(TypeError) + -> { $-0 = 1 }.should raise_error(TypeError) end it "raises a TypeError if assigned a boolean" do - lambda { $-0 = true }.should raise_error(TypeError) + -> { $-0 = true }.should raise_error(TypeError) end end @@ -631,7 +631,7 @@ describe "Predefined global $," do end it "raises TypeError if assigned a non-String" do - lambda { $, = Object.new }.should raise_error(TypeError) + -> { $, = Object.new }.should raise_error(TypeError) end end @@ -658,7 +658,7 @@ describe "Predefined global $." do obj = mock("bad-value") obj.should_receive(:to_int).and_return('abc') - lambda { $. = obj }.should raise_error(TypeError) + -> { $. = obj }.should raise_error(TypeError) end end @@ -802,15 +802,15 @@ describe "Execution variable $:" do end it "is read-only" do - lambda { + -> { $: = [] }.should raise_error(NameError) - lambda { + -> { $LOAD_PATH = [] }.should raise_error(NameError) - lambda { + -> { $-I = [] }.should raise_error(NameError) end @@ -822,11 +822,11 @@ describe "Global variable $\"" do end it "is read-only" do - lambda { + -> { $" = [] }.should raise_error(NameError) - lambda { + -> { $LOADED_FEATURES = [] }.should raise_error(NameError) end @@ -834,7 +834,7 @@ end describe "Global variable $<" do it "is read-only" do - lambda { + -> { $< = nil }.should raise_error(NameError) end @@ -842,7 +842,7 @@ end describe "Global variable $FILENAME" do it "is read-only" do - lambda { + -> { $FILENAME = "-" }.should raise_error(NameError) end @@ -850,7 +850,7 @@ end describe "Global variable $?" do it "is read-only" do - lambda { + -> { $? = nil }.should raise_error(NameError) end @@ -863,19 +863,19 @@ end describe "Global variable $-a" do it "is read-only" do - lambda { $-a = true }.should raise_error(NameError) + -> { $-a = true }.should raise_error(NameError) end end describe "Global variable $-l" do it "is read-only" do - lambda { $-l = true }.should raise_error(NameError) + -> { $-l = true }.should raise_error(NameError) end end describe "Global variable $-p" do it "is read-only" do - lambda { $-p = true }.should raise_error(NameError) + -> { $-p = true }.should raise_error(NameError) end end @@ -974,7 +974,7 @@ describe "Global variable $0" do end it "raises a TypeError when not given an object that can be coerced to a String" do - lambda { $0 = nil }.should raise_error(TypeError) + -> { $0 = nil }.should raise_error(TypeError) end end @@ -1016,7 +1016,7 @@ describe "The predefined standard object nil" do end it "raises a SyntaxError if assigned to" do - lambda { eval("nil = true") }.should raise_error(SyntaxError) + -> { eval("nil = true") }.should raise_error(SyntaxError) end end @@ -1026,7 +1026,7 @@ describe "The predefined standard object true" do end it "raises a SyntaxError if assigned to" do - lambda { eval("true = false") }.should raise_error(SyntaxError) + -> { eval("true = false") }.should raise_error(SyntaxError) end end @@ -1036,13 +1036,13 @@ describe "The predefined standard object false" do end it "raises a SyntaxError if assigned to" do - lambda { eval("false = nil") }.should raise_error(SyntaxError) + -> { eval("false = nil") }.should raise_error(SyntaxError) end end describe "The self pseudo-variable" do it "raises a SyntaxError if assigned to" do - lambda { eval("self = 1") }.should raise_error(SyntaxError) + -> { eval("self = 1") }.should raise_error(SyntaxError) end end diff --git a/spec/ruby/language/private_spec.rb b/spec/ruby/language/private_spec.rb index e7a871b09b..ddf185e6d2 100644 --- a/spec/ruby/language/private_spec.rb +++ b/spec/ruby/language/private_spec.rb @@ -5,11 +5,11 @@ describe "The private keyword" do it "marks following methods as being private" do a = Private::A.new a.methods.should_not include(:bar) - lambda { a.bar }.should raise_error(NoMethodError) + -> { a.bar }.should raise_error(NoMethodError) b = Private::B.new b.methods.should_not include(:bar) - lambda { b.bar }.should raise_error(NoMethodError) + -> { b.bar }.should raise_error(NoMethodError) end # def expr.meth() methods are always public @@ -22,7 +22,7 @@ describe "The private keyword" do c.methods.should include(:baz) c.baz Private::B.public_class_method1.should == 1 - lambda { Private::B.private_class_method1 }.should raise_error(NoMethodError) + -> { Private::B.private_class_method1 }.should raise_error(NoMethodError) end it "is no longer in effect when the class is closed" do @@ -42,12 +42,12 @@ describe "The private keyword" do klass.class_eval do private :foo end - lambda { f.foo }.should raise_error(NoMethodError) + -> { f.foo }.should raise_error(NoMethodError) end it "changes visibility of previously called methods with same send/call site" do g = ::Private::G.new - lambda { + -> { 2.times do g.foo module ::Private @@ -61,7 +61,7 @@ describe "The private keyword" do it "changes the visibility of the existing method in the subclass" do ::Private::A.new.foo.should == 'foo' - lambda {::Private::H.new.foo}.should raise_error(NoMethodError) + -> { ::Private::H.new.foo }.should raise_error(NoMethodError) ::Private::H.new.send(:foo).should == 'foo' end end diff --git a/spec/ruby/language/redo_spec.rb b/spec/ruby/language/redo_spec.rb index fe1bcef0a1..57532553b3 100644 --- a/spec/ruby/language/redo_spec.rb +++ b/spec/ruby/language/redo_spec.rb @@ -3,7 +3,7 @@ require_relative '../spec_helper' describe "The redo statement" do it "restarts block execution if used within block" do a = [] - lambda { + -> { a << 1 redo if a.size < 2 a << 2 @@ -58,7 +58,7 @@ describe "The redo statement" do describe "in a method" do it "is invalid and raises a SyntaxError" do - lambda { + -> { eval("def m; redo; end") }.should raise_error(SyntaxError) end diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb index c0f69bea9b..5f4221e213 100644 --- a/spec/ruby/language/regexp/character_classes_spec.rb +++ b/spec/ruby/language/regexp/character_classes_spec.rb @@ -89,7 +89,7 @@ describe "Regexp with character classes" do /[^[:lower:]A-C]+/.match("abcABCDEF123def").to_a.should == ["DEF123"] # negated character class /[:alnum:]+/.match("a:l:n:u:m").to_a.should == ["a:l:n:u:m"] # should behave like regular character class composed of the individual letters /[\[:alnum:]+/.match("[:a:l:n:u:m").to_a.should == ["[:a:l:n:u:m"] # should behave like regular character class composed of the individual letters - lambda { eval('/[[:alpha:]-[:digit:]]/') }.should raise_error(SyntaxError) # can't use character class as a start value of range + -> { eval('/[[:alpha:]-[:digit:]]/') }.should raise_error(SyntaxError) # can't use character class as a start value of range end it "matches ASCII characters with [[:ascii:]]" do diff --git a/spec/ruby/language/regexp/escapes_spec.rb b/spec/ruby/language/regexp/escapes_spec.rb index 17501af8c6..14e1424d47 100644 --- a/spec/ruby/language/regexp/escapes_spec.rb +++ b/spec/ruby/language/regexp/escapes_spec.rb @@ -48,7 +48,7 @@ describe "Regexps with escape characters" do /\x0AA/.match("\nA").to_a.should == ["\nA"] /\xAG/.match("\nG").to_a.should == ["\nG"] # Non-matches - lambda { eval('/\xG/') }.should raise_error(SyntaxError) + -> { eval('/\xG/') }.should raise_error(SyntaxError) # \x{7HHHHHHH} wide hexadecimal char (character code point value) end @@ -69,9 +69,9 @@ describe "Regexps with escape characters" do # Parsing precedence /\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifiers apply to entire escape sequence /\\cJ/.match("\\cJ").to_a.should == ["\\cJ"] - lambda { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class + -> { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class # Syntax error - lambda { eval('/\c/') }.should raise_error(SyntaxError) + -> { eval('/\c/') }.should raise_error(SyntaxError) # \cx control char (character code point value) # \C-x control char (character code point value) diff --git a/spec/ruby/language/regexp/grouping_spec.rb b/spec/ruby/language/regexp/grouping_spec.rb index 61a52cba15..8806d06746 100644 --- a/spec/ruby/language/regexp/grouping_spec.rb +++ b/spec/ruby/language/regexp/grouping_spec.rb @@ -12,7 +12,7 @@ describe "Regexps with grouping" do end it "raises a SyntaxError when parentheses aren't balanced" do - lambda { eval "/(hay(st)ack/" }.should raise_error(SyntaxError) + -> { eval "/(hay(st)ack/" }.should raise_error(SyntaxError) end it "supports (?: ) (non-capturing group)" do diff --git a/spec/ruby/language/regexp/interpolation_spec.rb b/spec/ruby/language/regexp/interpolation_spec.rb index c25a3cdb78..ed0b724763 100644 --- a/spec/ruby/language/regexp/interpolation_spec.rb +++ b/spec/ruby/language/regexp/interpolation_spec.rb @@ -41,9 +41,9 @@ describe "Regexps with interpolation" do it "throws RegexpError for malformed interpolation" do s = "" - lambda { /(#{s}/ }.should raise_error(RegexpError) + -> { /(#{s}/ }.should raise_error(RegexpError) s = "(" - lambda { /#{s}/ }.should raise_error(RegexpError) + -> { /#{s}/ }.should raise_error(RegexpError) end it "allows interpolation in extended mode" do diff --git a/spec/ruby/language/regexp/modifiers_spec.rb b/spec/ruby/language/regexp/modifiers_spec.rb index f0051ca55d..9f3cf8acf8 100644 --- a/spec/ruby/language/regexp/modifiers_spec.rb +++ b/spec/ruby/language/regexp/modifiers_spec.rb @@ -36,7 +36,7 @@ describe "Regexps with modifiers" do /foo/imox.match("foo").to_a.should == ["foo"] /foo/imoximox.match("foo").to_a.should == ["foo"] - lambda { eval('/foo/a') }.should raise_error(SyntaxError) + -> { eval('/foo/a') }.should raise_error(SyntaxError) end it "supports (?~) (absent operator)" do @@ -76,7 +76,7 @@ describe "Regexps with modifiers" do /(?i-i)foo/.match("FOO").should be_nil /(?ii)foo/.match("FOO").to_a.should == ["FOO"] /(?-)foo/.match("foo").to_a.should == ["foo"] - lambda { eval('/(?o)/') }.should raise_error(SyntaxError) + -> { eval('/(?o)/') }.should raise_error(SyntaxError) end it "supports (?imx-imx:expr) (scoped inline modifiers)" do @@ -96,7 +96,7 @@ describe "Regexps with modifiers" do /(?i-i:foo)/.match("FOO").should be_nil /(?ii:foo)/.match("FOO").to_a.should == ["FOO"] /(?-:)foo/.match("foo").to_a.should == ["foo"] - lambda { eval('/(?o:)/') }.should raise_error(SyntaxError) + -> { eval('/(?o:)/') }.should raise_error(SyntaxError) end it "supports . with /m" do diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb index aae5156dcd..67c7c034e9 100644 --- a/spec/ruby/language/regexp_spec.rb +++ b/spec/ruby/language/regexp_spec.rb @@ -27,7 +27,7 @@ describe "Literal Regexps" do end it "throws SyntaxError for malformed literals" do - lambda { eval('/(/') }.should raise_error(SyntaxError) + -> { eval('/(/') }.should raise_error(SyntaxError) end ############################################################################# @@ -54,7 +54,7 @@ describe "Literal Regexps" do it "disallows first part of paired delimiters to be used as non-paired delimiters" do LanguageSpecs.paired_delimiters.each do |p0, p1| - lambda { eval("%r#{p0} foo #{p0}") }.should raise_error(SyntaxError) + -> { eval("%r#{p0} foo #{p0}") }.should raise_error(SyntaxError) end end @@ -65,11 +65,11 @@ describe "Literal Regexps" do end it "disallows alphabets as non-paired delimiter with %r" do - lambda { eval('%ra foo a') }.should raise_error(SyntaxError) + -> { eval('%ra foo a') }.should raise_error(SyntaxError) end it "disallows spaces after %r and delimiter" do - lambda { eval('%r !foo!') }.should raise_error(SyntaxError) + -> { eval('%r !foo!') }.should raise_error(SyntaxError) end it "allows unescaped / to be used with %r" do diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb index b0eb949c1a..a912e17431 100644 --- a/spec/ruby/language/rescue_spec.rb +++ b/spec/ruby/language/rescue_spec.rb @@ -54,7 +54,7 @@ describe "The rescue keyword" do end it "can rescue multiple raised exceptions with a single rescue block" do - [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].map do |block| + [->{raise ArbitraryException}, ->{raise SpecificExampleException}].map do |block| begin block.call rescue SpecificExampleException, ArbitraryException @@ -72,7 +72,7 @@ describe "The rescue keyword" do end caught_it.should be_true caught = [] - [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].each do |block| + [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block| begin block.call rescue *exception_list @@ -94,7 +94,7 @@ describe "The rescue keyword" do end caught_it.should be_true caught = [] - [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].each do |block| + [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block| begin block.call rescue ArbitraryException, *exception_list @@ -108,7 +108,7 @@ describe "The rescue keyword" do end it "will only rescue the specified exceptions when doing a splat rescue" do - lambda do + -> do begin raise OtherCustomException, "not rescued!" rescue *exception_list @@ -210,7 +210,7 @@ describe "The rescue keyword" do ruby_version_is ''...'2.6' do it "will execute an else block even without rescue and ensure" do - lambda { + -> { eval <<-ruby begin ScratchPad << :begin @@ -226,7 +226,7 @@ describe "The rescue keyword" do ruby_version_is '2.6' do it "raises SyntaxError when else is used without rescue and ensure" do - lambda { + -> { eval <<-ruby begin ScratchPad << :begin @@ -294,7 +294,7 @@ describe "The rescue keyword" do end it "will not rescue errors raised in an else block in the rescue block above it" do - lambda do + -> do begin ScratchPad << :one rescue Exception @@ -329,7 +329,7 @@ describe "The rescue keyword" do [ Exception.new, NoMemoryError.new, ScriptError.new, SecurityError.new, SignalException.new('INT'), SystemExit.new, SystemStackError.new ].each do |exception| - lambda { + -> { begin raise exception rescue @@ -361,7 +361,7 @@ describe "The rescue keyword" do it "only accepts Module or Class in rescue clauses" do rescuer = 42 - lambda { + -> { begin raise "error" rescue rescuer @@ -373,7 +373,7 @@ describe "The rescue keyword" do it "only accepts Module or Class in splatted rescue clauses" do rescuer = [42] - lambda { + -> { begin raise "error" rescue *rescuer @@ -424,7 +424,7 @@ describe "The rescue keyword" do end it "does not allow rescue in {} block" do - lambda { + -> { eval <<-ruby lambda { raise SpecificExampleException @@ -455,7 +455,7 @@ describe "The rescue keyword" do end it "requires the 'rescue' in method arguments to be wrapped in parens" do - lambda { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError) + -> { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError) eval('1.+((1 rescue 1))').should == 2 end @@ -466,7 +466,7 @@ describe "The rescue keyword" do end it "doesn't except rescue expression" do - lambda { + -> { eval <<-ruby a = 1 rescue RuntimeError 2 ruby @@ -477,7 +477,7 @@ describe "The rescue keyword" do a = raise(StandardError) rescue 1 a.should == 1 - lambda { + -> { a = raise(Exception) rescue 1 }.should raise_error(Exception) end diff --git a/spec/ruby/language/retry_spec.rb b/spec/ruby/language/retry_spec.rb index 0b816daa5c..ee5377946f 100644 --- a/spec/ruby/language/retry_spec.rb +++ b/spec/ruby/language/retry_spec.rb @@ -32,7 +32,7 @@ describe "The retry statement" do end it "raises a SyntaxError when used outside of a begin statement" do - lambda { eval 'retry' }.should raise_error(SyntaxError) + -> { eval 'retry' }.should raise_error(SyntaxError) end end diff --git a/spec/ruby/language/return_spec.rb b/spec/ruby/language/return_spec.rb index e697b0b44c..1af88c55cd 100644 --- a/spec/ruby/language/return_spec.rb +++ b/spec/ruby/language/return_spec.rb @@ -159,7 +159,7 @@ describe "The return keyword" do end it "executes the ensure clause when begin/ensure are inside a lambda" do - lambda do + -> do begin return ensure @@ -176,15 +176,15 @@ describe "The return keyword" do end it "causes lambda to return nil if invoked without any arguments" do - lambda { return; 456 }.call.should be_nil + -> { return; 456 }.call.should be_nil end it "causes lambda to return nil if invoked with an empty expression" do - lambda { return (); 456 }.call.should be_nil + -> { return (); 456 }.call.should be_nil end it "causes lambda to return the value passed to return" do - lambda { return 123; 456 }.call.should == 123 + -> { return 123; 456 }.call.should == 123 end it "causes the method that lexically encloses the block to return" do diff --git a/spec/ruby/language/safe_navigator_spec.rb b/spec/ruby/language/safe_navigator_spec.rb index 46a1a012d1..c3aecff2dd 100644 --- a/spec/ruby/language/safe_navigator_spec.rb +++ b/spec/ruby/language/safe_navigator_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' describe "Safe navigator" do it "requires a method name to be provided" do - lambda { eval("obj&. {}") }.should raise_error(SyntaxError) + -> { eval("obj&. {}") }.should raise_error(SyntaxError) end context "when context is nil" do @@ -26,7 +26,7 @@ describe "Safe navigator" do it "calls the method" do eval("false&.to_s").should == "false" - lambda { eval("false&.unknown") }.should raise_error(NoMethodError) + -> { eval("false&.unknown") }.should raise_error(NoMethodError) end end @@ -34,7 +34,7 @@ describe "Safe navigator" do it "calls the method" do eval("1&.to_s").should == "1" - lambda { eval("1&.unknown") }.should raise_error(NoMethodError) + -> { eval("1&.unknown") }.should raise_error(NoMethodError) end end @@ -90,7 +90,7 @@ describe "Safe navigator" do end obj = klass.new - lambda { + -> { eval("obj&.foo += 3") }.should raise_error(NoMethodError) { |e| e.name.should == :+ diff --git a/spec/ruby/language/safe_spec.rb b/spec/ruby/language/safe_spec.rb index 9b8350c892..be150df9d1 100644 --- a/spec/ruby/language/safe_spec.rb +++ b/spec/ruby/language/safe_spec.rb @@ -31,7 +31,7 @@ describe "The $SAFE variable" do [2, 3, 4].each do |n| it "cannot be set to #{n}" do - lambda { + -> { proc { $SAFE = n }.call @@ -41,7 +41,7 @@ describe "The $SAFE variable" do ruby_version_is ""..."2.6" do it "cannot be set to values below 0" do - lambda { + -> { proc { $SAFE = -100 }.call @@ -51,7 +51,7 @@ describe "The $SAFE variable" do ruby_version_is "2.6" do it "raises ArgumentError when set to values below 0" do - lambda { + -> { proc { $SAFE = -100 }.call @@ -60,7 +60,7 @@ describe "The $SAFE variable" do end it "cannot be set to values above 4" do - lambda { + -> { proc { $SAFE = 100 }.call @@ -71,7 +71,7 @@ describe "The $SAFE variable" do it "cannot be manually lowered" do proc { $SAFE = 1 - lambda { + -> { $SAFE = 0 }.should raise_error(SecurityError, /tried to downgrade safe level from 1 to 0/) }.call @@ -87,7 +87,7 @@ describe "The $SAFE variable" do it "is automatically lowered when leaving a lambda" do $SAFE.should == 0 - lambda { + -> { $SAFE = 1 }.call $SAFE.should == 0 @@ -111,7 +111,7 @@ describe "The $SAFE variable" do it "is not lambda local" do $SAFE.should == 0 - lambda { + -> { $SAFE = 1 }.call $SAFE.should == 1 diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb index 84d02afb82..4ba3dcc9c2 100644 --- a/spec/ruby/language/send_spec.rb +++ b/spec/ruby/language/send_spec.rb @@ -20,7 +20,7 @@ describe "Invoking a method" do end it "raises ArgumentError if the method has a positive arity" do - lambda { + -> { specs.fooM1 }.should raise_error(ArgumentError) end @@ -36,7 +36,7 @@ describe "Invoking a method" do end it "raises ArgumentError if the methods arity doesn't match" do - lambda { + -> { specs.fooM1(1,2) }.should raise_error(ArgumentError) end @@ -52,7 +52,7 @@ describe "Invoking a method" do end it "raises ArgumentError if extra arguments are passed" do - lambda { + -> { specs.fooM0O1(2,3) }.should raise_error(ArgumentError) end @@ -64,13 +64,13 @@ describe "Invoking a method" do end it "raises an ArgumentError if there are no values for the mandatory args" do - lambda { + -> { specs.fooM1O1 }.should raise_error(ArgumentError) end it "raises an ArgumentError if too many values are passed" do - lambda { + -> { specs.fooM1O1(1,2,3) }.should raise_error(ArgumentError) end @@ -107,7 +107,7 @@ describe "Invoking a method" do end it "raises a SyntaxError with both a literal block and an object as block" do - lambda { + -> { eval "specs.oneb(10, &l){ 42 }" }.should raise_error(SyntaxError) end @@ -195,20 +195,20 @@ describe "Invoking a method" do end it "raises NameError if invoked as a vcall" do - lambda { no_such_method }.should raise_error NameError + -> { no_such_method }.should raise_error NameError end it "should omit the method_missing call from the backtrace for NameError" do - lambda { no_such_method }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } + -> { no_such_method }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } end it "raises NoMethodError if invoked as an unambiguous method call" do - lambda { no_such_method() }.should raise_error NoMethodError - lambda { no_such_method(1,2,3) }.should raise_error NoMethodError + -> { no_such_method() }.should raise_error NoMethodError + -> { no_such_method(1,2,3) }.should raise_error NoMethodError end it "should omit the method_missing call from the backtrace for NoMethodError" do - lambda { no_such_method() }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } + -> { no_such_method() }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } end end @@ -260,8 +260,8 @@ end describe "Invoking a private getter method" do it "does not permit self as a receiver" do receiver = LangSendSpecs::PrivateGetter.new - lambda { receiver.call_self_foo }.should raise_error(NoMethodError) - lambda { receiver.call_self_foo_or_equals(6) }.should raise_error(NoMethodError) + -> { receiver.call_self_foo }.should raise_error(NoMethodError) + -> { receiver.call_self_foo_or_equals(6) }.should raise_error(NoMethodError) end end diff --git a/spec/ruby/language/singleton_class_spec.rb b/spec/ruby/language/singleton_class_spec.rb index e3a0d2870b..df735018af 100644 --- a/spec/ruby/language/singleton_class_spec.rb +++ b/spec/ruby/language/singleton_class_spec.rb @@ -15,11 +15,11 @@ describe "A singleton class" do end it "raises a TypeError for Fixnum's" do - lambda { 1.singleton_class }.should raise_error(TypeError) + -> { 1.singleton_class }.should raise_error(TypeError) end it "raises a TypeError for symbols" do - lambda { :symbol.singleton_class }.should raise_error(TypeError) + -> { :symbol.singleton_class }.should raise_error(TypeError) end it "is a singleton Class instance" do @@ -74,7 +74,7 @@ describe "A singleton class" do end it "doesn't have singleton class" do - lambda { bignum_value.singleton_class.superclass.should == Bignum }.should raise_error(TypeError) + -> { bignum_value.singleton_class.superclass.should == Bignum }.should raise_error(TypeError) end end @@ -112,11 +112,11 @@ describe "A constant on a singleton class" do class << @object CONST end - lambda { CONST }.should raise_error(NameError) + -> { CONST }.should raise_error(NameError) end it "cannot be accessed via object::CONST" do - lambda do + -> do @object::CONST end.should raise_error(TypeError) end @@ -127,7 +127,7 @@ describe "A constant on a singleton class" do CONST = 100 end - lambda do + -> do @object::CONST end.should raise_error(NameError) end @@ -143,7 +143,7 @@ describe "A constant on a singleton class" do it "is not preserved when the object is duped" do @object = @object.dup - lambda do + -> do class << @object; CONST; end end.should raise_error(NameError) end @@ -280,13 +280,13 @@ end describe "Instantiating a singleton class" do it "raises a TypeError when new is called" do - lambda { + -> { Object.new.singleton_class.new }.should raise_error(TypeError) end it "raises a TypeError when allocate is called" do - lambda { + -> { Object.new.singleton_class.allocate }.should raise_error(TypeError) end diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb index 308485d546..a7ca00ef03 100644 --- a/spec/ruby/language/string_spec.rb +++ b/spec/ruby/language/string_spec.rb @@ -282,6 +282,6 @@ describe "Ruby String interpolation" do a = "\u3042" b = "\xff".force_encoding "binary" - lambda { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError) + -> { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError) end end diff --git a/spec/ruby/language/super_spec.rb b/spec/ruby/language/super_spec.rb index 5aff5e8eea..66a1ec7592 100644 --- a/spec/ruby/language/super_spec.rb +++ b/spec/ruby/language/super_spec.rb @@ -83,8 +83,8 @@ describe "The super keyword" do end end - lambda {sub_normal.new.foo}.should raise_error(NoMethodError, /super/) - lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/) + -> {sub_normal.new.foo}.should raise_error(NoMethodError, /super/) + -> {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/) end it "uses given block even if arguments are passed explicitly" do @@ -169,7 +169,7 @@ describe "The super keyword" do end end - lambda { klass.new.a(:a_called) }.should raise_error(RuntimeError) + -> { klass.new.a(:a_called) }.should raise_error(RuntimeError) end # Rubinius ticket github#157 diff --git a/spec/ruby/language/throw_spec.rb b/spec/ruby/language/throw_spec.rb index 1662789da4..d723843688 100644 --- a/spec/ruby/language/throw_spec.rb +++ b/spec/ruby/language/throw_spec.rb @@ -45,7 +45,7 @@ describe "The throw keyword" do end it "does not convert strings to a symbol" do - lambda { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError) + -> { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError) end it "unwinds stack from within a method" do @@ -59,13 +59,13 @@ describe "The throw keyword" do end it "unwinds stack from within a lambda" do - c = lambda { throw :foo, :msg } + c = -> { throw :foo, :msg } catch(:foo) { c.call }.should == :msg end it "raises an ArgumentError if outside of scope of a matching catch" do - lambda { throw :test, 5 }.should raise_error(ArgumentError) - lambda { catch(:different) { throw :test, 5 } }.should raise_error(ArgumentError) + -> { throw :test, 5 }.should raise_error(ArgumentError) + -> { catch(:different) { throw :test, 5 } }.should raise_error(ArgumentError) end it "raises an UncaughtThrowError if used to exit a thread" do diff --git a/spec/ruby/language/undef_spec.rb b/spec/ruby/language/undef_spec.rb index 7a333c46ef..4e473b803f 100644 --- a/spec/ruby/language/undef_spec.rb +++ b/spec/ruby/language/undef_spec.rb @@ -14,35 +14,35 @@ describe "The undef keyword" do @undef_class.class_eval do undef meth end - lambda { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should raise_error(NoMethodError) end it "with a simple symbol" do @undef_class.class_eval do undef :meth end - lambda { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should raise_error(NoMethodError) end it "with a single quoted symbol" do @undef_class.class_eval do undef :'meth' end - lambda { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should raise_error(NoMethodError) end it "with a double quoted symbol" do @undef_class.class_eval do undef :"meth" end - lambda { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should raise_error(NoMethodError) end it "with a interpolated symbol" do @undef_class.class_eval do undef :"#{'meth'}" end - lambda { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should raise_error(NoMethodError) end end @@ -61,7 +61,7 @@ describe "The undef keyword" do it "raises a NameError when passed a missing name" do Class.new do - lambda { + -> { undef not_exist }.should raise_error(NameError) { |e| # a NameError and not a NoMethodError diff --git a/spec/ruby/language/variables_spec.rb b/spec/ruby/language/variables_spec.rb index 640c9e49ac..868603eb88 100644 --- a/spec/ruby/language/variables_spec.rb +++ b/spec/ruby/language/variables_spec.rb @@ -46,7 +46,7 @@ describe "Multiple assignment" do x = mock("multi-assign single RHS") x.should_receive(:to_ary).and_return(1) - lambda { a, b, c = x }.should raise_error(TypeError) + -> { a, b, c = x }.should raise_error(TypeError) end it "does not call #to_a to convert an Object RHS when assigning a simple MLHS" do @@ -127,7 +127,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat") x.should_receive(:to_ary).and_return(1) - lambda { *a = x }.should raise_error(TypeError) + -> { *a = x }.should raise_error(TypeError) end it "does not call #to_ary on an Array subclass" do @@ -160,7 +160,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat") x.should_receive(:to_ary).and_return(1) - lambda { a, *b, c = x }.should raise_error(TypeError) + -> { a, *b, c = x }.should raise_error(TypeError) end it "does not call #to_a to convert an Object RHS with a MLHS" do @@ -256,7 +256,7 @@ describe "Multiple assignment" do x = mock("multi-assign attributes") x.should_receive(:m).and_return(y) - lambda { a, b = x.m }.should raise_error(TypeError) + -> { a, b = x.m }.should raise_error(TypeError) end it "assigns values from a RHS method call with receiver and arguments" do @@ -407,7 +407,7 @@ describe "Multiple assignment" do x = mock("multi-assign RHS splat") x.should_receive(:to_a).and_return(1) - lambda { *a = *x }.should raise_error(TypeError) + -> { *a = *x }.should raise_error(TypeError) end it "does not call #to_ary to convert an Object RHS with a single splat LHS" do @@ -453,7 +453,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - lambda { a = *x }.should raise_error(TypeError) + -> { a = *x }.should raise_error(TypeError) end it "calls #to_a to convert an Object splat RHS when assigned to a simple MLHS" do @@ -468,7 +468,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - lambda { a, b, c = *x }.should raise_error(TypeError) + -> { a, b, c = *x }.should raise_error(TypeError) end it "does not call #to_ary to convert an Object splat RHS when assigned to a simple MLHS" do @@ -491,7 +491,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - lambda { a, *b, c = *x }.should raise_error(TypeError) + -> { a, *b, c = *x }.should raise_error(TypeError) end it "does not call #to_ary to convert an Object RHS with a MLHS" do @@ -569,7 +569,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat MRHS") x.should_receive(:to_a).and_return(1) - lambda { a, *b = 1, *x }.should raise_error(TypeError) + -> { a, *b = 1, *x }.should raise_error(TypeError) end it "does not call #to_ary to convert a splatted Object as part of a MRHS with a splat MRHS" do @@ -592,7 +592,7 @@ describe "Multiple assignment" do x = mock("multi-assign splat MRHS") x.should_receive(:to_a).and_return(1) - lambda { a, *b = *x, 1 }.should raise_error(TypeError) + -> { a, *b = *x, 1 }.should raise_error(TypeError) end it "does not call #to_ary to convert a splatted Object with a splat MRHS" do @@ -641,7 +641,7 @@ describe "Multiple assignment" do x = mock("multi-assign mixed RHS") x.should_receive(:to_ary).and_return(x) - lambda { a, (b, c), d = 1, x, 3, 4 }.should raise_error(TypeError) + -> { a, (b, c), d = 1, x, 3, 4 }.should raise_error(TypeError) end it "calls #to_a to convert a splatted Object value in a MRHS" do @@ -665,7 +665,7 @@ describe "Multiple assignment" do x = mock("multi-assign mixed splatted RHS") x.should_receive(:to_ary).and_return(x) - lambda { a, *b, (c, d) = 1, 2, 3, *x }.should raise_error(TypeError) + -> { a, *b, (c, d) = 1, 2, 3, *x }.should raise_error(TypeError) end it "does not call #to_ary to convert an Object when the position receiving the value is a simple variable" do diff --git a/spec/ruby/language/yield_spec.rb b/spec/ruby/language/yield_spec.rb index 8ab698196a..5fad7cb176 100644 --- a/spec/ruby/language/yield_spec.rb +++ b/spec/ruby/language/yield_spec.rb @@ -13,7 +13,7 @@ describe "The yield call" do describe "taking no arguments" do it "raises a LocalJumpError when the method is not passed a block" do - lambda { @y.z }.should raise_error(LocalJumpError) + -> { @y.z }.should raise_error(LocalJumpError) end it "ignores assignment to the explicit block argument and calls the passed block" do @@ -28,7 +28,7 @@ describe "The yield call" do describe "taking a single argument" do describe "when no block is given" do it "raises a LocalJumpError" do - lambda { @y.s(1) }.should raise_error(LocalJumpError) + -> { @y.s(1) }.should raise_error(LocalJumpError) end end @@ -52,30 +52,30 @@ describe "The yield call" do describe "yielding to a lambda" do it "passes an empty Array when the argument is an empty Array" do - @y.s([], &lambda { |*a| a }).should == [[]] + @y.s([], &-> *a { a }).should == [[]] end it "passes nil as a value" do - @y.s(nil, &lambda { |*a| a }).should == [nil] + @y.s(nil, &-> *a { a }).should == [nil] end it "passes a single value" do - @y.s(1, &lambda { |*a| a }).should == [1] + @y.s(1, &-> *a { a }).should == [1] end it "passes a single, multi-value Array" do - @y.s([1, 2, 3], &lambda { |*a| a }).should == [[1, 2, 3]] + @y.s([1, 2, 3], &-> *a { a }).should == [[1, 2, 3]] end it "raises an ArgumentError if too few arguments are passed" do - lambda { - @y.s(1, &lambda { |a,b| [a,b] }) + -> { + @y.s(1, &-> a, b { [a,b] }) }.should raise_error(ArgumentError) end it "should not destructure an Array into multiple arguments" do - lambda { - @y.s([1, 2], &lambda { |a,b| [a,b] }) + -> { + @y.s([1, 2], &-> a, b { [a,b] }) }.should raise_error(ArgumentError) end end @@ -83,7 +83,7 @@ describe "The yield call" do describe "taking multiple arguments" do it "raises a LocalJumpError when the method is not passed a block" do - lambda { @y.m(1, 2, 3) }.should raise_error(LocalJumpError) + -> { @y.m(1, 2, 3) }.should raise_error(LocalJumpError) end it "passes the arguments to the block" do @@ -95,21 +95,21 @@ describe "The yield call" do end it "raises an ArgumentError if too many arguments are passed to a lambda" do - lambda { - @y.m(1, 2, 3, &lambda { |a| }) + -> { + @y.m(1, 2, 3, &-> a { }) }.should raise_error(ArgumentError) end it "raises an ArgumentError if too few arguments are passed to a lambda" do - lambda { - @y.m(1, 2, 3, &lambda { |a,b,c,d| }) + -> { + @y.m(1, 2, 3, &-> a, b, c, d { }) }.should raise_error(ArgumentError) end end describe "taking a single splatted argument" do it "raises a LocalJumpError when the method is not passed a block" do - lambda { @y.r(0) }.should raise_error(LocalJumpError) + -> { @y.r(0) }.should raise_error(LocalJumpError) end it "passes a single value" do @@ -141,7 +141,7 @@ describe "The yield call" do describe "taking multiple arguments with a splat" do it "raises a LocalJumpError when the method is not passed a block" do - lambda { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) + -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) end it "passes the arguments to the block" do @@ -166,7 +166,7 @@ describe "The yield call" do describe "taking matching arguments with splats and post args" do it "raises a LocalJumpError when the method is not passed a block" do - lambda { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) + -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) end it "passes the arguments to the block" do |