Sha256: c6663644bc21f0035a7edb105637536e151fe192d9bb87496b2604f3baa86902

Contents?: true

Size: 465 Bytes

Versions: 5

Compression:

Stored size: 465 Bytes

Contents

require 'spec_helper'
module Alf
  describe Tools, "coalesce" do
    
    it "should support a varargs variant" do
      Tools.coalesce(:a, nil, :b, :c).should eql(:a)
      Tools.coalesce(nil, :a, nil, :b, :c).should eql(:a)
    end
    
    it "should support a block for costly computations" do
      Tools.coalesce(nil){ :hello }.should eql(:hello)
    end
    
    it "should return nil otherwise" do
      Tools.coalesce(nil).should be_nil
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/tools/test_coalesce.rb
alf-0.12.1 spec/unit/alf-core/tools/test_coalesce.rb
alf-0.12.0 spec/unit/alf-core/tools/test_coalesce.rb
alf-0.11.1 spec/unit/alf-core/tools/test_coalesce.rb
alf-0.11.0 spec/unit/alf-core/tools/test_coalesce.rb