Sha256: db6f72949ce2b0ecd16418c0503024a9a8c8b5aa42f1d84ef321d7baaf5b342e

Contents?: true

Size: 1.52 KB

Versions: 340

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::Model do
  it "should be possible to create an instance of a model object" do
    nop = Puppet::Pops::Model::Nop.new(Puppet::Pops::Parser::Locator.locator('code', 'file'), 0, 0)
    expect(nop.class).to eq(Puppet::Pops::Model::Nop)
  end
end

describe Puppet::Pops::Model::Factory do
  Factory = Puppet::Pops::Model::Factory
  Model = Puppet::Pops::Model

  it "construct an arithmetic expression" do
    x = Factory.literal(10) + Factory.literal(20)
    expect(x.is_a?(Factory)).to eq(true)
    model = x.model
    expect(model.is_a?(Model::ArithmeticExpression)).to eq(true)
    expect(model.operator).to eq('+')
    expect(model.left_expr.class).to eq(Model::LiteralInteger)
    expect(model.right_expr.class).to eq(Model::LiteralInteger)
    expect(model.left_expr.value).to eq(10)
    expect(model.right_expr.value).to eq(20)
  end

  it "should be easy to compare using a model tree dumper" do
    x = Factory.literal(10) + Factory.literal(20)
    expect(Puppet::Pops::Model::ModelTreeDumper.new.dump(x.model)).to eq("(+ 10 20)")
  end

  it "builder should apply precedence" do
    x = Factory.literal(2) * Factory.literal(10) + Factory.literal(20)
    expect(Puppet::Pops::Model::ModelTreeDumper.new.dump(x.model)).to eq("(+ (* 2 10) 20)")
  end

describe "should be describable with labels"
  it 'describes a PlanDefinition as "Plan Definition"' do
    expect(Puppet::Pops::Model::ModelLabelProvider.new.label(Factory.PLAN('test', [], nil))).to eq("Plan Definition")
  end
end

Version data entries

340 entries across 340 versions & 1 rubygems

Version Path
puppet-7.24.0 spec/unit/pops/model/model_spec.rb
puppet-7.24.0-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.24.0-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.24.0-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-7.23.0 spec/unit/pops/model/model_spec.rb
puppet-7.23.0-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.23.0-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.23.0-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-7.22.0 spec/unit/pops/model/model_spec.rb
puppet-7.22.0-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.22.0-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.22.0-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-6.29.0 spec/unit/pops/model/model_spec.rb
puppet-6.29.0-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-6.29.0-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-6.29.0-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-7.21.0 spec/unit/pops/model/model_spec.rb
puppet-7.21.0-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.21.0-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-7.21.0-universal-darwin spec/unit/pops/model/model_spec.rb