Sha256: 211561a2d7206a86a3b3a9cf59caf984a7c5293b261776819ec163d1c27b0933

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

describe Ace::Compiler do
  let :file do
    <<-DOC
    %{
      test
    %}

    %require "#{VERSION}"
    %language "ruby"

    %terminal NUMBER
    %terminal SEMICOLON ";"
    %terminal ADD "+"
    %terminal LPAREN "("
    %terminal RPAREN ")"

    %%

    s: e
    e: t ADD e
    t: NUMBER | LPAREN e RPAREN

    %%

    hello
    DOC
  end

  let :tokens do
    Ace::Scanner.scan(file)
  end

  let :compiler do
    Ace::Compiler.new(tokens)
  end

  subject do
    compiler.compile
    compiler
  end

  its(:body) { should =~ /test/  }
  its(:body) { should =~ /hello/ }
  its(:options) { should have_key :type }

  it 'has the proper terminals' do
    expect(subject.options[:terminals].map(&:first)).to eq [:NUMBER,
      :SEMICOLON, :ADD, :LPAREN, :RPAREN]
  end

  context 'with an unmatched version' do
    let(:file) { "%require \"0.0.0\"\n%%\n%%\n" }

    it 'raises an error' do
      expect do
        subject
      end.to raise_error(IncompatibleVersionError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
antelope-0.4.1 spec/antelope/ace/compiler_spec.rb
antelope-0.4.0 spec/antelope/ace/compiler_spec.rb