Sha256: c4f98e6e41323c63639dbe50747404366abc7fd87dfd726f6b031649f2eb656e

Contents?: true

Size: 1.23 KB

Versions: 57

Compression:

Stored size: 1.23 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
    nop.class.should == 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)
    x.is_a?(Factory).should == true
    current = x.current
    current.is_a?(Model::ArithmeticExpression).should == true
    current.operator.should == :'+'
    current.left_expr.class.should == Model::LiteralInteger
    current.right_expr.class.should == Model::LiteralInteger
    current.left_expr.value.should == 10
    current.right_expr.value.should == 20
  end

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

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

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/pops/model/model_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.6 spec/unit/pops/model/model_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.5 spec/unit/pops/model/model_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.4 spec/unit/pops/model/model_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.3 spec/unit/pops/model/model_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.2 spec/unit/pops/model/model_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/pops/model/model_spec.rb
puppet-3.8.1 spec/unit/pops/model/model_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/pops/model/model_spec.rb