diff options
| author | Luke Kanies <luke@madstop.com> | 2008-08-18 11:47:40 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-08-18 11:47:40 -0500 |
| commit | e3971b9751141cd448a8197da024be43581f6dcd (patch) | |
| tree | 3ae780db3d9dae0a4df10ec24f928bf3a844e749 /test/language/scope.rb | |
| parent | 025edc5c3737f476119df4bab73ebdc68be19430 (diff) | |
| parent | 2ec4e298c3274abc8eaad4230bca8d39a48d2e35 (diff) | |
| download | puppet-e3971b9751141cd448a8197da024be43581f6dcd.tar.gz puppet-e3971b9751141cd448a8197da024be43581f6dcd.tar.xz puppet-e3971b9751141cd448a8197da024be43581f6dcd.zip | |
Merge branch '0.24.x'
Conflicts:
CHANGELOG
test/util/posixtest.rb
Diffstat (limited to 'test/language/scope.rb')
| -rwxr-xr-x | test/language/scope.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb index c96581a23..0fa211fc3 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -53,6 +53,34 @@ class TestScope < Test::Unit::TestCase assert_equal(:undefined, scopes[name].lookupvar("third", false), "Found child var in top scope") end assert_equal("botval", scopes[:bot].lookupvar("third", false), "Could not find var in bottom scope") + + + # Test that the scopes convert to hash structures correctly. + # For topscope recursive vs non-recursive should be identical + assert_equal(topscope.to_hash(false), topscope.to_hash(true), + "Recursive and non-recursive hash is identical for topscope") + + # Check the variable we expect is present. + assert_equal({"first" => "topval"}, topscope.to_hash(), + "topscope returns the expected hash of variables") + + # Now, check that midscope does the right thing in all cases. + assert_equal({"second" => "midval"}, + midscope.to_hash(false), + "midscope non-recursive hash contains only midscope variable") + assert_equal({"first" => "topval", "second" => "midval"}, + midscope.to_hash(true), + "midscope recursive hash contains topscope variable also") + + # Finally, check the ability to shadow symbols by adding a shadow to + # bottomscope, then checking that we see the right stuff. + botscope.setvar("first", "shadowval") + assert_equal({"third" => "botval", "first" => "shadowval"}, + botscope.to_hash(false), + "botscope has the right non-recursive hash") + assert_equal({"third" => "botval", "first" => "shadowval", "second" => "midval"}, + botscope.to_hash(true), + "botscope values shadow parent scope values") end def test_lookupvar |
