Sha256: 30d0b872e6be150a9c4aceb929ea3dbafc50ae443ca8f297d2f016b8ab359cd4

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
class Predicate
  describe Predicate, "constant_variables" do

    subject{ p.constant_variables }

    describe "on a comp(:eq)" do
      let(:p){ Predicate.coerce(x: 2, y: 3) }

      it{ expect(subject).to eql([:x, :y]) }
    end

    describe "on a in with one value" do
      let(:p){ Predicate.in(:x, [2]) }

      it{ expect(subject).to eql([:x]) }
    end

    describe "on a in with mutiple values" do
      let(:p){ Predicate.in(:x, [2, 3]) }

      it{ expect(subject).to eql([]) }
    end

    describe "on a NOT" do
      let(:p){ !Predicate.coerce(x: 2) }

      it{ expect(subject).to eql([]) }
    end

    describe "on a AND" do
      let(:p){ Predicate.coerce(x: 2) & Predicate.coerce(y: 3) }

      it{ expect(subject).to eql([:x, :y]) }
    end

    describe "on a OR" do
      let(:p){ Predicate.coerce(x: 2) | Predicate.coerce(y: 3) }

      it{ expect(subject).to eql([]) }
    end

    describe "on a negated OR" do
      let(:p){ !(Predicate.coerce(x: 2) | Predicate.coerce(y: 3)) }

      pending("NNF would make constant_variables smarter"){
        expect(subject).to eql([:x, :y])
      }
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
predicate-2.0.1 spec/predicate/test_constant_variables.rb
predicate-2.0.0 spec/predicate/test_constant_variables.rb
predicate-1.3.4 spec/predicate/test_constant_variables.rb
predicate-1.3.3 spec/predicate/test_constant_variables.rb
predicate-1.3.2 spec/predicate/test_constant_variables.rb
predicate-1.3.1 spec/predicate/test_constant_variables.rb
predicate-1.3.0 spec/predicate/test_constant_variables.rb
predicate-1.2.0 spec/predicate/test_constant_variables.rb
predicate-1.1.3 spec/predicate/test_constant_variables.rb
predicate-1.1.2 spec/predicate/test_constant_variables.rb
predicate-1.1.1 spec/predicate/test_constant_variables.rb
predicate-1.1.0 spec/predicate/test_constant_variables.rb
predicate-1.0.0 spec/predicate/test_constant_variables.rb