Sha256: 9ab7e511ba0338f10e6fbdf0e188b7e0634909bc05be4bedbe67596d3712666f

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'compiler_helper'
module Alf
  class Compiler
    describe Default, "defaults" do

      subject{
        compiler.call(expr)
      }

      shared_examples_for 'the expected Defaults' do

        it_should_behave_like "a traceable compiled"

        it 'has a Defaults cog' do
          subject.should be_a(Engine::Defaults)
        end

        it 'has the correct defaults' do
          subject.defaults.to_hash.should eq(b: 1)
        end
      end

      context "when non strict" do
        let(:expr){
          defaults(an_operand(leaf), b: 1)
        }

        it_should_behave_like "the expected Defaults"

        it 'has the correct sub-cog' do
          subject.operand.should be(leaf)
        end
      end

      context "when strict" do
        let(:expr){
          defaults(an_operand(leaf), {b: 1}, strict: true)
        }

        it_should_behave_like "the expected Defaults"

        it 'has a Clip sub-sub cog' do
          subject.operand.should be_a(Engine::Clip)
          subject.operand.attributes.should eq(AttrList[:b])
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-compiler/default/test_defaults.rb