Sha256: 6eee3048801cba23a0dfba6ee1ed1b4b8df68b140a27ebfc64c5bc3bc58e3a88

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require_relative '../spec_helper' # Use the RSpec framework

require_relative '../../lib/mini_kraken/core/all_core'

module MiniKraken
  module Core
    # Integration-in-the-small testing
    describe 'Core Classes' do
      let(:ctx) { Context.new }

      context 'Executing nullary goals:' do
        def var(aName)
          LogVar.new(aName)
        end

        it 'should execute nullary fail goal' do
          # Equivalent to frame 1:7
          goal = Goal.new(Fail.instance, [])
          ctx.insert(var('q'))
          result = goal.achieve(ctx)
          expect(result.resume).to eq(ctx)
          expect(ctx).to be_failure
          expect(ctx.associations_for('q')).to be_empty
        end

        it 'should execute nullary succeed goal' do
          # Equivalent to frame 1:17
          goal = Goal.new(Succeed.instance, [])
          ctx.insert(var('q'))
          result = goal.achieve(ctx)
          expect(result.resume).to eq(ctx)
          expect(ctx).to be_success
          expect(ctx.associations_for('q')).to be_empty # RS: (_0)
        end
      end # context
    end # describe
  end # module
end # module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mini_kraken-0.3.03 spec/core/core_spec.rb
mini_kraken-0.3.02 spec/core/core_spec.rb
mini_kraken-0.3.01 spec/core/core_spec.rb
mini_kraken-0.3.00 spec/core/core_spec.rb