Sha256: 20b98cf4644f7edc8ba681b37b5e5b592245b94aa5cf21b93662ed0456c65e02

Contents?: true

Size: 1.23 KB

Versions: 9

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::Parser::Parser do
  it "should instantiate a parser" do
    parser = Puppet::Pops::Parser::Parser.new()
    parser.class.should == Puppet::Pops::Parser::Parser
  end

  it "should parse a code string and return a model" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("$a = 10").current
    model.class.should == Puppet::Pops::Model::Program
    model.body.class.should == Puppet::Pops::Model::AssignmentExpression
  end

  it "should accept empty input and return a model" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("").current
    model.class.should == Puppet::Pops::Model::Program
    model.body.class.should == Puppet::Pops::Model::Nop
  end

  it "should accept empty input containing only comments and report location at end of input" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("# comment\n").current
    model.class.should == Puppet::Pops::Model::Program
    model.body.class.should == Puppet::Pops::Model::Nop
    adapter = Puppet::Pops::Adapters::SourcePosAdapter.adapt(model.body)
    expect(adapter.offset).to eq(10)
    expect(adapter.length).to eq(0)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
puppet-3.7.2 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.2-x86-mingw32 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.2-x64-mingw32 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.1 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.1-x86-mingw32 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.1-x64-mingw32 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.0 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.0-x86-mingw32 spec/unit/pops/parser/parser_spec.rb
puppet-3.7.0-x64-mingw32 spec/unit/pops/parser/parser_spec.rb