Sha256: 4ee87f659a567e762905f833b639f028865f23f56ce37f8caf54ee3484396fd6

Contents?: true

Size: 1007 Bytes

Versions: 44

Compression:

Stored size: 1007 Bytes

Contents

require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::Parser::Locator do

  it "multi byte characters in a comment does not interfere with AST node text extraction" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("# \u{0400}comment\nabcdef#XXXXXXXXXX").model
    expect(model.class).to eq(Puppet::Pops::Model::Program)
    expect(model.body.offset).to eq(12)
    expect(model.body.length).to eq(6)
    expect(model.body.locator.extract_text(model.body.offset, model.body.length)).to eq('abcdef')
  end

  it "multi byte characters in a comment does not interfere with AST node text extraction" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("# \u{0400}comment\n1 + 2#XXXXXXXXXX").model
    expect(model.class).to eq(Puppet::Pops::Model::Program)
    expect(model.body.offset).to eq(14) # The '+'
    expect(model.body.length).to eq(1)
    expect(model.body.locator.extract_tree_text(model.body)).to eq('1 + 2')
  end

end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
puppet-5.3.7 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.7-x86-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.7-x64-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.7-universal-darwin spec/unit/pops/parser/locator_spec.rb
puppet-5.3.6 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.6-x86-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.6-x64-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.6-universal-darwin spec/unit/pops/parser/locator_spec.rb
puppet-5.3.5 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.5-x86-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.5-x64-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.5-universal-darwin spec/unit/pops/parser/locator_spec.rb
puppet-5.3.4 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.4-x86-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.4-x64-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.4-universal-darwin spec/unit/pops/parser/locator_spec.rb
puppet-5.3.3 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.3-x86-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.3-x64-mingw32 spec/unit/pops/parser/locator_spec.rb
puppet-5.3.3-universal-darwin spec/unit/pops/parser/locator_spec.rb