Sha256: a25d9001dd8376f0053c5e9cac6ca6672c106c478dba310143506c6bda0ec63a

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

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

      subject{
        compiler.call(expr)
      }

      shared_examples_for "a compacted compilation result" do

        it_should_behave_like "a traceable compiled"

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

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

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

      let(:allbut){ false }

      context 'when keys not available' do
        let(:expr){
          project(an_operand(leaf), [:a])
        }

        it_should_behave_like "a compacted compilation result"
      end

      context 'when keys not available (allbut)' do
        let(:expr){
          project(an_operand(leaf), [:a], allbut: true)
        }
        let(:allbut){ true }

        it_should_behave_like "a compacted compilation result"
      end

      context 'when keys are available and not preserving' do
        let(:expr){
          project(an_operand(leaf).with_keys([:b]), [:a])
        }

        it_should_behave_like "a compacted compilation result"
      end

      context 'when keys are available and preserving' do
        let(:expr){
          project(an_operand(leaf).with_keys([:a]), [:a])
        }

        it_should_behave_like "a traceable cog"

        it 'has a Clip cog' do
          subject.should be_a(Engine::Clip)
          subject.attributes.should eq(AttrList[:a])
          subject.allbut.should be_false
        end

        it 'has the correct sub cog' do
          subject.operand.should be(leaf)
        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_project.rb