From 25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Wed, 1 Sep 2010 14:18:41 -0700 Subject: [#4685] Classes, defines, and nodes allowed inside of non-evaluated conditionals Previously, ASTArray#evaluate() was responsible for checking whether the user had tried to declare a class, define, or node in a prohibited location (such as a conditional construct). This meant that errors would only be reported to the user if the conditional code was actually evaluated. Moved the checking into the parser, so that errors are always reported. --- spec/integration/parser/compiler_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'spec/integration/parser') diff --git a/spec/integration/parser/compiler_spec.rb b/spec/integration/parser/compiler_spec.rb index 266347c60..ffff4d845 100755 --- a/spec/integration/parser/compiler_spec.rb +++ b/spec/integration/parser/compiler_spec.rb @@ -81,7 +81,7 @@ describe Puppet::Parser::Compiler do Puppet::Parser::Compiler.compile(node).version.should == 2 end - it "should not allow classes inside conditional constructs" do + it "should not allow classes inside evaluated conditional constructs" do Puppet[:code] = <<-PP if true { class foo { @@ -91,4 +91,15 @@ describe Puppet::Parser::Compiler do lambda { Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode")) }.should raise_error(Puppet::Error) end + + it "should not allow classes inside unevaluated conditional constructs" do + Puppet[:code] = <<-PP + if false { + class foo { + } + } + PP + + lambda { Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode")) }.should raise_error(Puppet::Error) + end end -- cgit