Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitm@lovullo.com>2016-07-05 16:14:15 -0400
committerMike Gerwitz <gerwitm@lovullo.com>2016-07-06 00:16:12 -0400
commit641147cd8ff84755b640869e55c8be48cc566b31 (patch)
treeb6ab16e5013b9bc308e8ef56b9455f5ccd992192
parentbcf1e0457fc3f8a41d9c8e7692228b33649d777a (diff)
downloadtame-641147cd8ff84755b640869e55c8be48cc566b31.tar.gz
tame-641147cd8ff84755b640869e55c8be48cc566b31.tar.bz2
tame-641147cd8ff84755b640869e55c8be48cc566b31.zip
graph:union normalize/dedupe test
This was already happening, but formally test and document it, since it's a very useful property. * src/graph.xsl (graph:union): Document dedupe behavior * test/graph-test.xsl: Add test data * test/graph.xspec: Add dedupe test for graph:union
-rw-r--r--src/graph.xsl5
-rw-r--r--test/graph-test.xsl25
2 files changed, 30 insertions, 0 deletions
diff --git a/src/graph.xsl b/src/graph.xsl
index 0a80861..6950c03 100644
--- a/src/graph.xsl
+++ b/src/graph.xsl
@@ -136,6 +136,11 @@
@end verbatim
@caption{(G₁ ∪ G₂ ∪ G₃)}
@end float
+
+ This function also removes duplicate vertices and edges,
+ so it can be used with a single (or multiple) graphs to normalize
+ and tidy things up.
+ Any unknown XML nodes are removed.
-->
<function name="graph:union" as="element( preproc:sym-deps )*">
<param name="graphs" as="element( preproc:sym-deps )*" />
diff --git a/test/graph-test.xsl b/test/graph-test.xsl
index 63cf618..e8f7b5b 100644
--- a/test/graph-test.xsl
+++ b/test/graph-test.xsl
@@ -169,6 +169,31 @@
</variable>
+<variable name="foo:graph-with-dupes" as="element( preproc:sym-deps )">
+ <preproc:sym-deps>
+ <preproc:sym-dep name="dup">
+ <preproc:sym-ref name="a" />
+ </preproc:sym-dep>
+
+ <preproc:sym-dep name="dup">
+ <preproc:sym-ref name="b" />
+ <preproc:sym-ref name="b" />
+ <preproc:sym-ref name="b" />
+ </preproc:sym-dep>
+ </preproc:sym-deps>
+</variable>
+
+
+<variable name="foo:graph-deduped" as="element( preproc:sym-deps )">
+ <preproc:sym-deps>
+ <preproc:sym-dep name="dup">
+ <preproc:sym-ref name="a" />
+ <preproc:sym-ref name="b" />
+ </preproc:sym-dep>
+ </preproc:sym-deps>
+</variable>
+
+
<function name="foo:lookup">
<param name="yield" as="element()" />
<param name="symbol" as="element( preproc:sym )" />