Sha256: b568b27a6a9e1efdec5a6b680899e113cb6dd9c223be97d01ac53a827c2aa491

Contents?: true

Size: 1.06 KB

Versions: 120

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::Adapters::SourcePosAdapter 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").current
    expect(model.class).to eq(Puppet::Pops::Model::Program)
    adapter = Puppet::Pops::Adapters::SourcePosAdapter.adapt(model.body)
    expect(adapter.offset).to eq(12)
    expect(adapter.length).to eq(6)
    expect(adapter.extract_text).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").current
    expect(model.class).to eq(Puppet::Pops::Model::Program)
    adapter = Puppet::Pops::Adapters::SourcePosAdapter.adapt(model.body)
    expect(adapter.offset).to eq(14) # The '+'
    expect(adapter.length).to eq(1)
    expect(adapter.extract_tree_text).to eq('1 + 2')
  end

end

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
puppet-4.10.12 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.12-x86-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.12-x64-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.12-universal-darwin spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.11 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.11-x86-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.11-x64-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.11-universal-darwin spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.10 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.10-x86-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.10-x64-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.10-universal-darwin spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.9 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.9-x86-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.9-x64-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.9-universal-darwin spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.8 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.8-x86-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.8-x64-mingw32 spec/unit/pops/parser/source_pos_adapter_spec.rb
puppet-4.10.8-universal-darwin spec/unit/pops/parser/source_pos_adapter_spec.rb