Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstarkos <none@none>2009-08-18 23:09:17 +0400
committerstarkos <none@none>2009-08-18 23:09:17 +0400
commitfa0208431a817cbad1cbac916c62440f90fe693c (patch)
tree7547a52bb799248d93d6eb83150e137910a9c39b /tests/base
parent2ec723489b666a5f4742d67d86062ec244c9716f (diff)
Added source file tree builder
Diffstat (limited to 'tests/base')
-rw-r--r--tests/base/test_tree.lua69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/base/test_tree.lua b/tests/base/test_tree.lua
new file mode 100644
index 0000000..d689631
--- /dev/null
+++ b/tests/base/test_tree.lua
@@ -0,0 +1,69 @@
+--
+-- tests/base/test_tree.lua
+-- Automated test suite source code tree handling.
+-- Copyright (c) 2009 Jason Perkins and the Premake project
+--
+
+ T.tree = { }
+ local tree = premake.tree
+
+
+--
+-- Setup/teardown
+--
+
+ local tr, nodes
+
+ function T.tree.setup()
+ tr = tree.new()
+ nodes = { }
+ end
+
+ local function getresult()
+ tree.traverse(tr, {
+ onnode = function(node, depth)
+ table.insert(nodes, string.rep(".", depth) .. node.name)
+ end
+ })
+ return table.concat(nodes)
+ end
+
+
+
+--
+-- Tests for tree.new()
+--
+
+ function T.tree.NewReturnsObject()
+ test.isnotnil(tr)
+ end
+
+
+--
+-- Tests for tree.add()
+--
+
+ function T.tree.CanAddAtRoot()
+ tree.add(tr, "Root")
+ test.isequal(""
+ .. "Root",
+ getresult())
+ end
+
+ function T.tree.CanAddAtChild()
+ tree.add(tr, "Root/Child")
+ test.isequal(""
+ .. "Root"
+ .. ".Child",
+ getresult())
+ end
+
+ function T.tree.CanAddAtGrandchild()
+ tree.add(tr, "Root/Child/Grandchild")
+ test.isequal(""
+ .. "Root"
+ .. ".Child"
+ .. "..Grandchild",
+ getresult())
+ end
+