summaryrefslogtreecommitdiffstats
path: root/test/parser/node.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-04 23:30:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-04 23:30:56 +0000
commit8db837ad7663c611f1fe92189e36158404a452cc (patch)
tree4353df4b7c670128d15be578b4ac8f63da57db86 /test/parser/node.rb
parentd4a5b480f2451041109d867052db2285990d01a6 (diff)
downloadpuppet-8db837ad7663c611f1fe92189e36158404a452cc.tar.gz
puppet-8db837ad7663c611f1fe92189e36158404a452cc.tar.xz
puppet-8db837ad7663c611f1fe92189e36158404a452cc.zip
getting rid of the parser tree, and moving everything into the language dir
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1070 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/parser/node.rb')
-rw-r--r--test/parser/node.rb84
1 files changed, 0 insertions, 84 deletions
diff --git a/test/parser/node.rb b/test/parser/node.rb
deleted file mode 100644
index 5013b190d..000000000
--- a/test/parser/node.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-if __FILE__ == $0
- $:.unshift '../../lib'
- $:.unshift '..'
- $puppetbase = "../.."
-end
-
-require 'puppet'
-require 'puppet/parser/parser'
-require 'test/unit'
-require 'puppettest'
-
-class TestParser < Test::Unit::TestCase
- include ParserTesting
-
- def setup
- super
- Puppet[:parseonly] = true
- @parser = Puppet::Parser::Parser.new()
- end
-
- def test_simple_hostname
- check_parseable "host1"
- check_parseable "'host2'"
- check_parseable [ "'host1'", "host2" ]
- check_parseable [ "'host1'", "'host2'" ]
- end
-
- def test_qualified_hostname
- check_parseable "'host.example.com'"
- check_parseable [ "'host.example.com'", "host1" ]
- check_parseable "'host-1.37examples.example.com'"
- check_parseable "'svn.23.nu'"
- check_parseable "'HOST'"
- end
-
- def test_reject_hostname
- check_nonparseable "host.example.com"
- check_nonparseable "host@example.com"
- check_nonparseable "\"host\""
- check_nonparseable "'$foo.example.com'"
- check_nonparseable "'host1 host2'"
- check_nonparseable "HOST"
- end
-
- AST = Puppet::Parser::AST
-
- def check_parseable(hostnames)
- unless hostnames.is_a?(Array)
- hostnames = [ hostnames ]
- end
- assert_nothing_raised {
- @parser.string = "node #{hostnames.join(" ")} { }"
- }
- # Strip quotes
- hostnames.map! { |s| s.sub(/^'(.*)'$/, "\\1") }
- ast = nil
- assert_nothing_raised {
- ast = @parser.parse
- }
- # Verify that the AST has the expected structure
- # and that the leaves have the right hostnames in them
- assert_kind_of(AST::ASTArray, ast)
- assert_equal(1, ast.children.size)
- nodedef = ast.children[0]
- assert_kind_of(AST::NodeDef, nodedef)
- assert_kind_of(AST::ASTArray, nodedef.names)
- assert_equal(hostnames.size, nodedef.names.children.size)
- hostnames.size.times do |i|
- hostnode = nodedef.names.children[i]
- assert_kind_of(AST::HostName, hostnode)
- assert_equal(hostnames[i], hostnode.value)
- end
- end
-
- def check_nonparseable(hostname)
- assert_nothing_raised {
- @parser.string = "node #{hostname} { }"
- }
-
- assert_raise(Puppet::DevError, Puppet::ParseError) {
- @parser.parse
- }
- end
-end