Sha256: 2d20053732f9c04af889850c6557a48b645062523e0fb31afe339d7a4f1a7bff

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'parslet/rig/rspec'

describe DpllSolver::Parsers::Grammar do
  let(:g){ DpllSolver::Parsers::Grammar.new }

  describe '#verum' do
    let(:verum){ g.verum }
    it 'should parse verum' do
      verum.should parse('T')
      verum.should parse('1')
    end
  end
  describe '#falsum' do
    let(:falsum){ g.falsum }
    it 'should parse falsum' do
      falsum.should parse('F')
      falsum.should parse('0')
    end
  end
  describe '#variable' do
    let(:var){ g.variable }
    it 'should parse variable' do
      var.should parse('x')
      var.should parse('x1')
      var.should parse('x12')
      var.should_not parse('xy')
    end
  end
  describe '#not' do
    let(:not_op){ g.not_operation }
    it 'should parse not_operation' do
      not_op.should parse('-x')
      not_op.should parse('-(x+y)')
      not_op.should parse('--x')
    end
  end
  describe '#or' do
    let(:or_op){ g.or_operation }
    it 'should parse or_operation' do
      or_op.should parse('(x + y)')
      or_op.should parse('(x | y)')
      or_op.should parse('(x OR y)')
    end
  end
  describe '#and' do
    let(:and_op){ g.and_operation }
    it 'should parse and_operation' do
      and_op.should parse('(x * y)')
      and_op.should parse('(x & y)')
      and_op.should parse('(x AND y)')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dpll_solver-0.0.1 spec/parsers/grammar_spec.rb