diff options
Diffstat (limited to 'spec/ruby/core/proc/curry_spec.rb')
| -rw-r--r-- | spec/ruby/core/proc/curry_spec.rb | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/spec/ruby/core/proc/curry_spec.rb b/spec/ruby/core/proc/curry_spec.rb index 24df2a8a72..de13983ca6 100644 --- a/spec/ruby/core/proc/curry_spec.rb +++ b/spec/ruby/core/proc/curry_spec.rb @@ -8,12 +8,12 @@ describe "Proc#curry" do it "returns a Proc when called on a proc" do p = proc { true } - p.curry.should be_an_instance_of(Proc) + p.curry.should.instance_of?(Proc) end it "returns a Proc when called on a lambda" do p = -> { true } - p.curry.should be_an_instance_of(Proc) + p.curry.should.instance_of?(Proc) end it "calls the curried proc with the arguments if sufficient arguments have been given" do @@ -23,11 +23,11 @@ describe "Proc#curry" do it "returns a Proc that consumes the remainder of the arguments unless sufficient arguments have been given" do proc2 = @proc_add.curry[1][2] - proc2.should be_an_instance_of(Proc) + proc2.should.instance_of?(Proc) proc2.call(3).should == 6 lambda2 = @lambda_add.curry[1][2] - lambda2.should be_an_instance_of(Proc) + lambda2.should.instance_of?(Proc) lambda2.call(3).should == 6 @proc_add.curry.call(1,2,3).should == 6 @@ -36,10 +36,10 @@ describe "Proc#curry" do it "can be called multiple times on the same Proc" do @proc_add.curry - -> { @proc_add.curry }.should_not raise_error + -> { @proc_add.curry }.should_not.raise @lambda_add.curry - -> { @lambda_add.curry }.should_not raise_error + -> { @lambda_add.curry }.should_not.raise end it "can be passed superfluous arguments if created from a proc" do @@ -49,8 +49,8 @@ describe "Proc#curry" do end it "raises an ArgumentError if passed superfluous arguments when created from a lambda" do - -> { @lambda_add.curry[1,2,3,4] }.should raise_error(ArgumentError) - -> { @lambda_add.curry[1,2].curry[3,4,5,6] }.should raise_error(ArgumentError) + -> { @lambda_add.curry[1,2,3,4] }.should.raise(ArgumentError) + -> { @lambda_add.curry[1,2].curry[3,4,5,6] }.should.raise(ArgumentError) end it "returns Procs with arities of -1" do @@ -63,7 +63,7 @@ describe "Proc#curry" do it "produces Procs that raise ArgumentError for #binding" do -> do @proc_add.curry.binding - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "produces Procs that return [[:rest]] for #parameters" do @@ -98,41 +98,41 @@ describe "Proc#curry with arity argument" do end it "accepts an optional Integer argument for the arity" do - -> { @proc_add.curry(3) }.should_not raise_error - -> { @lambda_add.curry(3) }.should_not raise_error + -> { @proc_add.curry(3) }.should_not.raise + -> { @lambda_add.curry(3) }.should_not.raise end it "returns a Proc when called on a proc" do - @proc_add.curry(3).should be_an_instance_of(Proc) + @proc_add.curry(3).should.instance_of?(Proc) end it "returns a Proc when called on a lambda" do - @lambda_add.curry(3).should be_an_instance_of(Proc) + @lambda_add.curry(3).should.instance_of?(Proc) end # [ruby-core:24127] it "retains the lambda-ness of the Proc on which its called" do - @lambda_add.curry(3).lambda?.should be_true - @proc_add.curry(3).lambda?.should be_false + @lambda_add.curry(3).lambda?.should == true + @proc_add.curry(3).lambda?.should == false end it "raises an ArgumentError if called on a lambda that requires more than _arity_ arguments" do - -> { @lambda_add.curry(2) }.should raise_error(ArgumentError) - -> { -> x, y, z, *more{}.curry(2) }.should raise_error(ArgumentError) + -> { @lambda_add.curry(2) }.should.raise(ArgumentError) + -> { -> x, y, z, *more{}.curry(2) }.should.raise(ArgumentError) end it 'returns a Proc if called on a lambda that requires fewer than _arity_ arguments but may take more' do - -> a, b, c, d=nil, e=nil {}.curry(4).should be_an_instance_of(Proc) - -> a, b, c, d=nil, *e {}.curry(4).should be_an_instance_of(Proc) - -> a, b, c, *d {}.curry(4).should be_an_instance_of(Proc) + -> a, b, c, d=nil, e=nil {}.curry(4).should.instance_of?(Proc) + -> a, b, c, d=nil, *e {}.curry(4).should.instance_of?(Proc) + -> a, b, c, *d {}.curry(4).should.instance_of?(Proc) end it "raises an ArgumentError if called on a lambda that requires fewer than _arity_ arguments" do - -> { @lambda_add.curry(4) }.should raise_error(ArgumentError) - -> { -> { true }.curry(1) }.should raise_error(ArgumentError) - -> { -> a, b=nil {}.curry(5) }.should raise_error(ArgumentError) - -> { -> a, &b {}.curry(2) }.should raise_error(ArgumentError) - -> { -> a, b=nil, &c {}.curry(3) }.should raise_error(ArgumentError) + -> { @lambda_add.curry(4) }.should.raise(ArgumentError) + -> { -> { true }.curry(1) }.should.raise(ArgumentError) + -> { -> a, b=nil {}.curry(5) }.should.raise(ArgumentError) + -> { -> a, &b {}.curry(2) }.should.raise(ArgumentError) + -> { -> a, b=nil, &c {}.curry(3) }.should.raise(ArgumentError) end it "calls the curried proc with the arguments if _arity_ arguments have been given" do @@ -142,32 +142,31 @@ describe "Proc#curry with arity argument" do it "returns a Proc that consumes the remainder of the arguments when fewer than _arity_ arguments are given" do proc2 = @proc_add.curry(3)[1][2] - proc2.should be_an_instance_of(Proc) + proc2.should.instance_of?(Proc) proc2.call(3).should == 6 lambda2 = @lambda_add.curry(3)[1][2] - lambda2.should be_an_instance_of(Proc) + lambda2.should.instance_of?(Proc) lambda2.call(3).should == 6 end it "can be specified multiple times on the same Proc" do @proc_add.curry(2) - -> { @proc_add.curry(1) }.should_not raise_error + -> { @proc_add.curry(1) }.should_not.raise @lambda_add.curry(3) - -> { @lambda_add.curry(3) }.should_not raise_error + -> { @lambda_add.curry(3) }.should_not.raise end it "can be passed more than _arity_ arguments if created from a proc" do - -> { @proc_add.curry(3)[1,2,3,4].should == 6 }.should_not - raise_error(ArgumentError) - -> { @proc_add.curry(1)[1,2].curry(3)[3,4,5,6].should == 6 }.should_not - raise_error(ArgumentError) + @proc_add.curry(3)[1,2,3,4].should == 6 + + @proc_add.curry(3)[1,2].curry(3)[3,4,5,6].should == 6 end it "raises an ArgumentError if passed more than _arity_ arguments when created from a lambda" do - -> { @lambda_add.curry(3)[1,2,3,4] }.should raise_error(ArgumentError) - -> { @lambda_add.curry(1)[1,2].curry(3)[3,4,5,6] }.should raise_error(ArgumentError) + -> { @lambda_add.curry(3)[1,2,3,4] }.should.raise(ArgumentError) + -> { @lambda_add.curry(3)[1,2].curry(3)[3,4,5,6] }.should.raise(ArgumentError) end it "returns Procs with arities of -1 regardless of the value of _arity_" do |
