Sha256: bf0bb3a6d66f54b229f80ce51117782ef6b7860aec7f142638258816419406fc

Contents?: true

Size: 1.92 KB

Versions: 83

Compression:

Stored size: 1.92 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'

describe "Proc#arity" do
  it "returns the number of arguments, using Proc.new" do
    Proc.new { || }.arity.should == 0
    Proc.new { |a| }.arity.should == 1
    Proc.new { |_| }.arity.should == 1
    Proc.new { |a, b| }.arity.should == 2
    Proc.new { |a, b, c| }.arity.should == 3
  end
  
  it "returns the number of arguments, using Kernel#lambda" do
    lambda { || }.arity.should == 0
    lambda { |a| }.arity.should == 1
    lambda { |_| }.arity.should == 1
    lambda { |a, b| }.arity.should == 2
    lambda { |a, b, c| }.arity.should == 3
  end
  
  it "return the number of arguments, using Kernel#proc" do
    proc { || }.arity.should == 0
    proc { |a| }.arity.should == 1
    proc { |_| }.arity.should == 1
    proc { |a, b| }.arity.should == 2
    proc { |a, b, c| }.arity.should == 3
  end
  
  it "if optional arguments, return the negative number of mandatory arguments using Proc.new " do
    Proc.new { |*a| }.arity.should == -1
    Proc.new { |a, *b| }.arity.should == -2
    Proc.new { |a, b, *c| }.arity.should == -3
  end
  
  it "if optional arguments, return the negative number of mandatory arguments using Kernel#lambda" do
    lambda { |*a| }.arity.should == -1
    lambda { |a, *b| }.arity.should == -2
    lambda { |a, b, *c| }.arity.should == -3
  end
  
  it "if optional arguments, return the negative number of mandatory arguments using Kernel#proc" do
    proc { |*a| }.arity.should == -1
    proc { |a, *b| }.arity.should == -2
    proc { |a, b, *c| }.arity.should == -3
  end
  
  it "returns -1 if no argument declaration is made, using Proc.new" do
    Proc.new { }.arity.should == -1
  end
  
  it "returns -1 if no argument declaration is made, using Kernel#lambda" do
    lambda { }.arity.should == -1
  end
  
  it "returns -1 if no argument declaration is made, using Kernel#proc" do
    proc { }.arity.should == -1
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/proc/arity_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/proc/arity_spec.rb