summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-06-11 18:35:14 -0500
committerLuke Kanies <luke@madstop.com>2009-06-11 18:35:14 -0500
commite4ae870f6103aacbba48a06e366168aaaa67402b (patch)
tree879e195375b9935ad7cbf8956804f2d1d63cd406 /test
parent607b01e82ea294068fdd554e59bc8e5fe3f9761a (diff)
downloadpuppet-e4ae870f6103aacbba48a06e366168aaaa67402b.tar.gz
puppet-e4ae870f6103aacbba48a06e366168aaaa67402b.tar.xz
puppet-e4ae870f6103aacbba48a06e366168aaaa67402b.zip
Fixing #2336 - qualified variables only throw warnings
We were previously throwing exceptions. This also ports all of the tests for variable lookup over to rspec. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/scope.rb50
1 files changed, 0 insertions, 50 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb
index debef44bf..403e569f7 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -83,56 +83,6 @@ class TestScope < Test::Unit::TestCase
"botscope values shadow parent scope values")
end
- def test_lookupvar
- parser = mkparser
- scope = mkscope :parser => parser
-
- # first do the plain lookups
- assert_equal("", scope.lookupvar("var"), "scope did not default to string")
- assert_equal("", scope.lookupvar("var", true), "scope ignored usestring setting")
- assert_equal(:undefined, scope.lookupvar("var", false), "scope ignored usestring setting when false")
-
- # Now set the var
- scope.setvar("var", "yep")
- assert_equal("yep", scope.lookupvar("var"), "did not retrieve value correctly")
-
- # Now test the parent lookups
- subscope = mkscope :parser => parser
- subscope.parent = scope
- assert_equal("", subscope.lookupvar("nope"), "scope did not default to string with parent")
- assert_equal("", subscope.lookupvar("nope", true), "scope ignored usestring setting with parent")
- assert_equal(:undefined, subscope.lookupvar("nope", false), "scope ignored usestring setting when false with parent")
-
- assert_equal("yep", subscope.lookupvar("var"), "did not retrieve value correctly from parent")
-
- # Now override the value in the subscope
- subscope.setvar("var", "sub")
- assert_equal("sub", subscope.lookupvar("var"), "did not retrieve overridden value correctly")
-
- # Make sure we punt when the var is qualified. Specify the usestring value, so we know it propagates.
- scope.expects(:lookup_qualified_var).with("one::two", false).returns(:punted)
- assert_equal(:punted, scope.lookupvar("one::two", false), "did not return the value of lookup_qualified_var")
- end
-
- def test_lookup_qualified_var
- parser = mkparser
- scope = mkscope :parser => parser
-
- scopes = {}
- classes = ["", "one", "one::two", "one::two::three"].each do |name|
- klass = parser.newclass(name)
- Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
- scopes[name] = scope.compiler.class_scope(klass)
- end
-
- classes.each do |name|
- var = [name, "var"].join("::")
- scopes[name].expects(:lookupvar).with("var", false).returns(name)
-
- assert_equal(name, scope.send(:lookup_qualified_var, var, false), "did not get correct value from lookupvar")
- end
- end
-
def test_declarative
# set to declarative
top = mkscope