Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitm@lovullo.com>2016-07-13 11:25:34 -0400
committerMike Gerwitz <gerwitm@lovullo.com>2016-07-13 11:31:19 -0400
commitda9a16ae859e88c6463c9c0898ca48a32425a85a (patch)
tree65ffb4b9071b5011534056d12b761a066105124e /test
parentd7220f01575cef9aa82bbfeb8ca8743a5c03d7c9 (diff)
downloadtame-da9a16ae859e88c6463c9c0898ca48a32425a85a.tar.gz
tame-da9a16ae859e88c6463c9c0898ca48a32425a85a.tar.bz2
tame-da9a16ae859e88c6463c9c0898ca48a32425a85a.zip
Add graph:lookup-from-doc
* src/graph.xsl (graph:lookup-from-doc): Added * test/graph-doc.xml: Added * test/graph-test.xsl: Associated test data * test/graph.xspec: Associated tests added
Diffstat (limited to 'test')
-rw-r--r--test/graph-doc.xml10
-rw-r--r--test/graph-test.xsl8
-rw-r--r--test/graph.xspec63
3 files changed, 80 insertions, 1 deletions
diff --git a/test/graph-doc.xml b/test/graph-doc.xml
new file mode 100644
index 0000000..0fb8b98
--- /dev/null
+++ b/test/graph-doc.xml
@@ -0,0 +1,10 @@
+<!--
+ Stub document for graph test
+-->
+<root xmlns:preproc="https://www.lovullo.com/rater/preproc">
+ <preproc:sym-deps>
+ <preproc:sym-dep name="foo">
+ <preproc:sym-ref name="bar" />
+ </preproc:sym-dep>
+ </preproc:sym-deps>
+</root>
diff --git a/test/graph-test.xsl b/test/graph-test.xsl
index 416f8fb..a1cbb92 100644
--- a/test/graph-test.xsl
+++ b/test/graph-test.xsl
@@ -29,7 +29,6 @@
<!-- SUT -->
<import href="../src/graph.xsl" />
-
<import href="graph-test.xsl.apply" />
@@ -48,6 +47,13 @@
src="not-here" />
<preproc:sym name="missing-deps" />
+
+ <preproc:sym name="doc-sym"
+ src="graph-doc" />
+
+ <!-- should _not_ be defined in source document -->
+ <preproc:sym name="doc-sym-unknown"
+ src="graph-doc" />
</preproc:symtable>
<preproc:sym-deps>
diff --git a/test/graph.xspec b/test/graph.xspec
index d7fdb9a..5499430 100644
--- a/test/graph.xspec
+++ b/test/graph.xspec
@@ -286,4 +286,67 @@
satisfies
deep-equal( $vertex/*, $foo:expected-lookup )" />
</scenario>
+
+
+ <scenario label="graph:lookup-from-doc">
+ <variable name="expected-doc" as="document-node()"
+ select="document( 'graph-doc.xml', root() )" />
+
+ <scenario label="given a known external symbol">
+ <call function="graph:lookup-from-doc">
+ <param name="doc-ext"
+ select="'xml'" />
+
+ <param name="rel-node"
+ select="root()" />
+
+ <param name="symbol"
+ select="$foo:document/preproc:symtable
+ /preproc:sym[ @name = 'doc-sym' ]" />
+ </call>
+
+ <expect label="looks up subgraph from document"
+ test="deep-equal( $x:result,
+ $expected-doc/*/preproc:sym-deps )" />
+ </scenario>
+
+
+ <!-- since we're looking up the graph, we don't really care if the symbol
+ exissts in it or not (that is a caller concern) -->
+ <scenario label="given an unknown external symbol">
+ <call function="graph:lookup-from-doc">
+ <param name="doc-ext"
+ select="'xml'" />
+
+ <param name="rel-node"
+ select="root()" />
+
+ <param name="symbol"
+ select="$foo:document/preproc:symtable
+ /preproc:sym[ @name = 'doc-sym-unknown' ]" />
+ </call>
+
+ <expect label="looks up subgraph from document"
+ test="deep-equal( $x:result,
+ $expected-doc/*/preproc:sym-deps )" />
+ </scenario>
+
+
+ <scenario label="given a symbol with no @src">
+ <call function="graph:lookup-from-doc">
+ <param name="doc-ext"
+ select="'xml'" />
+
+ <param name="rel-node"
+ select="root()" />
+
+ <param name="symbol"
+ select="$foo:document/preproc:symtable
+ /preproc:sym[ @name = 'local' ]" />
+ </call>
+
+ <expect label="produces empty sequence"
+ test="empty( $x:result )" />
+ </scenario>
+ </scenario>
</description>