Sha256: f2dd8f54f973351dbe7ebde4cf0b3987246805042ff8d9862dec8726acaa5033
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require 'compiler_helper' module Alf class Compiler describe Default, "sort" do subject{ compiler.call(expr) } let(:ordering){ Ordering.new([[:a, :asc]]) } shared_examples_for "the expected Sort" do it_should_behave_like "a traceable compiled" it{ should be_a(Engine::Sort) } end context 'when the cog is not sorted at all' do let(:expr){ sort(an_operand(leaf), ordering) } it_should_behave_like "the expected Sort" it 'should add a Sort' do subject.ordering.should be(ordering) subject.operand.should be(leaf) end end context 'when the cog is already sorted' do let(:expr){ sort(sort(an_operand(leaf), subordering), ordering) } context 'in exact same way' do let(:subordering){ Ordering.new([[:a, :asc]]) } it_should_behave_like "the expected Sort" it 'should reuse the cog itself' do subject.operand.should be(leaf) subject.ordering.should be(subordering) end end context 'in a compatible way' do let(:subordering){ Ordering.new([[:a, :asc], [:b, :desc]]) } it_should_behave_like "the expected Sort" it 'should reuse the cog itself' do subject.operand.should be(leaf) subject.ordering.should be(subordering) end end context 'in a incompatible way' do let(:subordering){ Ordering.new([[:a, :desc]]) } it_should_behave_like "the expected Sort" it 'should add a Sort' do subject.ordering.should be(ordering) subject.operand.should be_a(Engine::Sort) subject.operand.ordering.should be(subordering) end 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_sort.rb |