Sha256: c5ee346cf5a7ae1bba32dbe5a63e61e68afe9533a1ee2485efc8da43d4924b6e

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 Bytes

Contents

RSpec.describe Operations::Implication do
  subject(:operation) { Operations::Implication.new(left, right) }

  include_context 'predicates'

  let(:left) { Rule::Predicate.build(int?) }
  let(:right) { Rule::Predicate.build(gt?).curry(18) }

  describe '#call' do
    it 'calls left and right' do
      expect(operation.('19')).to be_success
      expect(operation.(19)).to be_success
      expect(operation.(18)).to be_failure
    end
  end

  describe '#to_ast' do
    it 'returns ast' do
      expect(operation.to_ast).to eql(
        [:implication, [[:predicate, [:int?, [[:input, Undefined]]]], [:predicate, [:gt?, [[:num, 18], [:input, Undefined]]]]]]
      )
    end
  end

  describe '#to_s' do
    it 'returns string representation' do
      expect(operation.to_s).to eql('int? THEN gt?(18)')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-logic-1.0.0 spec/unit/operations/implication_spec.rb
dry-logic-0.6.1 spec/unit/operations/implication_spec.rb
dry-logic-0.6.0 spec/unit/operations/implication_spec.rb