Sha256: ce67d8e9c431b80bc49a1e04c81248dadd6552ec5211a309ddab61a0e4a37580

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 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 in with an opaque right term" do
      let(:p){ Predicate.in(:x, Predicate.opaque([2])) }

      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

3 entries across 3 versions & 1 rubygems

Version Path
predicate-2.2.1 spec/predicate/test_constant_variables.rb
predicate-2.2.0 spec/predicate/test_constant_variables.rb
predicate-2.1.0 spec/predicate/test_constant_variables.rb