summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-15 07:09:28 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-15 07:09:28 +0000
commit08499b10c1bdccbcaeeacf1826cc156a80524e0e (patch)
tree14ca449c5bade630726f9acf39e7b327a327bd4a /test
parent26bf373eee9d5ac09296bd5eab3af11b44f28826 (diff)
downloadpuppet-08499b10c1bdccbcaeeacf1826cc156a80524e0e.tar.gz
puppet-08499b10c1bdccbcaeeacf1826cc156a80524e0e.tar.xz
puppet-08499b10c1bdccbcaeeacf1826cc156a80524e0e.zip
Adding the feature from #259. I had to rework the Scope#lookupvar a bit, but everything now works as expected when variables are either undefined or set to empty strings.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1609 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/functions.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/language/functions.rb b/test/language/functions.rb
index b35a1ac4a..d9364f996 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -241,6 +241,45 @@ class TestLangFunctions < Test::Unit::TestCase
assert(parsedate != newdate, "Parse date did not change")
end
+ def test_template_defined_vars
+ template = tempfile()
+
+ File.open(template, "w") do |f|
+ f.puts "template <%= yayness %>"
+ end
+
+ func = nil
+ assert_nothing_raised do
+ func = Puppet::Parser::AST::Function.new(
+ :name => "template",
+ :ftype => :rvalue,
+ :arguments => AST::ASTArray.new(
+ :children => [stringobj(template)]
+ )
+ )
+ end
+ ast = varobj("output", func)
+
+ {
+ "" => "",
+ false => "false",
+ }.each do |string, value|
+ scope = Puppet::Parser::Scope.new()
+ assert_raise(Puppet::ParseError) do
+ ast.evaluate(:scope => scope)
+ end
+
+ scope.setvar("yayness", string)
+
+ assert_nothing_raised("An empty string was not a valid variable value") do
+ ast.evaluate(:scope => scope)
+ end
+
+ assert_equal("template #{value}\n", scope.lookupvar("output"),
+ "%s did not get evaluated correctly" % string.inspect)
+ end
+ end
+
def test_autoloading_functions
assert_equal(false, Puppet::Parser::Functions.function(:autofunc),
"Got told autofunc already exists")