Sha256: 681f33ee46228b3774f01d899f9cbe46058a9e1b0823c9a437cc3a41adeaf53e

Contents?: true

Size: 1.28 KB

Versions: 150

Compression:

Stored size: 1.28 KB

Contents

#! /usr/bin/env ruby
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
    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)
    current = x.current
    expect(current.is_a?(Model::ArithmeticExpression)).to eq(true)
    expect(current.operator).to eq(:'+')
    expect(current.left_expr.class).to eq(Model::LiteralInteger)
    expect(current.right_expr.class).to eq(Model::LiteralInteger)
    expect(current.left_expr.value).to eq(10)
    expect(current.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.current)).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.current)).to eq("(+ (* 2 10) 20)")
  end
end

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
puppet-4.10.7 spec/unit/pops/model/model_spec.rb
puppet-4.10.7-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.7-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.7-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-4.10.6 spec/unit/pops/model/model_spec.rb
puppet-4.10.6-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.6-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.6-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-4.10.5 spec/unit/pops/model/model_spec.rb
puppet-4.10.5-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.5-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.5-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-4.10.4 spec/unit/pops/model/model_spec.rb
puppet-4.10.4-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.4-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.4-universal-darwin spec/unit/pops/model/model_spec.rb
puppet-4.10.1 spec/unit/pops/model/model_spec.rb
puppet-4.10.1-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.1-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-4.10.1-universal-darwin spec/unit/pops/model/model_spec.rb