diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-17 21:43:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-17 21:43:51 +0000 |
| commit | eed85f41ffc31649032114b7aa89a541d239a257 (patch) | |
| tree | 72b83438166fec47d107fa6d2c98261bfde76f60 /test/language | |
| parent | 8410c4dc5bfbb450ea740be42e0f0d712bf86e7a (diff) | |
| download | puppet-eed85f41ffc31649032114b7aa89a541d239a257.tar.gz puppet-eed85f41ffc31649032114b7aa89a541d239a257.tar.xz puppet-eed85f41ffc31649032114b7aa89a541d239a257.zip | |
Adding #629 -- an undef keyword now exists
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2522 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language')
| -rwxr-xr-x | test/language/parser.rb | 13 | ||||
| -rwxr-xr-x | test/language/resource.rb | 14 | ||||
| -rwxr-xr-x | test/language/scope.rb | 15 |
3 files changed, 42 insertions, 0 deletions
diff --git a/test/language/parser.rb b/test/language/parser.rb index ce54efc7e..e4b913ab8 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -763,6 +763,19 @@ file { "/tmp/yayness": parser.import("%s/*" % dir) end end + + # #629 - undef keyword + def test_undef + parser = mkparser + result = nil + assert_nothing_raised("Could not parse assignment to undef") { + result = parser.parse %{$variable = undef} + } + + children = result.children + assert_instance_of(AST::VarDef, result.children[0]) + assert_instance_of(AST::Undef, result.children[0].value) + end end # $Id$ diff --git a/test/language/resource.rb b/test/language/resource.rb index 205d86d2c..6dee5b573 100755 --- a/test/language/resource.rb +++ b/test/language/resource.rb @@ -530,6 +530,20 @@ class TestResource < Test::Unit::TestCase end end end + + # part of #629 -- the undef keyword. Make sure 'undef' params get skipped. + def test_undef_and_to_hash + res = mkresource :type => "file", :title => "/tmp/testing", + :source => @source, :scope => @scope, + :params => {:owner => :undef, :mode => "755"} + + hash = nil + assert_nothing_raised("Could not convert resource with undef to hash") do + hash = res.to_hash + end + + assert_nil(hash[:owner], "got a value for an undef parameter") + end end # $Id$ diff --git a/test/language/scope.rb b/test/language/scope.rb index 428fe3e09..0c9881dac 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -445,6 +445,8 @@ class TestScope < Test::Unit::TestCase "Empty strings considered true") assert_equal(false, Puppet::Parser::Scope.true?(false), "false considered true") + assert_equal(false, Puppet::Parser::Scope.true?(:undef), + "undef considered true") end # Verify scope context is handled correctly. @@ -745,6 +747,19 @@ Host <<||>>" scope.add_namespace("b") assert_nothing_raised { test.call([["a", "testing"], ["b", "testing"]]) } end + + # #629 - undef should be "" or :undef + def test_lookupvar_with_undef + scope = mkscope + + scope.setvar("testing", :undef) + + assert_equal(:undef, scope.lookupvar("testing", false), + "undef was not returned as :undef when not string") + + assert_equal("", scope.lookupvar("testing", true), + "undef was not returned as '' when string") + end end # $Id$ |
