aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-03 19:21:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-03 19:21:50 +0200
commite4f4f0bed9befbde2117af6f128d9323be3f1638 (patch)
tree6c41709cdc5fa51b0354b68897a8cc1651b8eb9c /tests
parentca2bc859cf0001848224ff00a92fcc5d60a16e7f (diff)
Add union information to the semantics graph
New test: union.
Diffstat (limited to 'tests')
-rw-r--r--tests/dump/driver.cxx60
-rw-r--r--tests/schema/annotation/test-000.std2
-rw-r--r--tests/schema/anonymous/test-000.std6
-rw-r--r--tests/schema/anonymous/test-001.std6
-rw-r--r--tests/schema/makefile2
-rw-r--r--tests/schema/union/makefile35
-rw-r--r--tests/schema/union/test-000.std37
-rw-r--r--tests/schema/union/test-000.xsd40
8 files changed, 173 insertions, 15 deletions
diff --git a/tests/dump/driver.cxx b/tests/dump/driver.cxx
index d9917d3..ccfe5aa 100644
--- a/tests/dump/driver.cxx
+++ b/tests/dump/driver.cxx
@@ -55,8 +55,23 @@ namespace
<< endl;
wcout << ind << "list " <<
- (l.named () ? l.name () : String ("<anonymous>"))
- << " " << ref_name (l.argumented ().type ()) << endl;
+ (l.named () ? l.name () : String ("<anonymous>"));
+
+ SemanticGraph::Type& t (l.argumented ().type ());
+
+ if (t.named ())
+ wcout << " " << ref_name (t) << endl;
+ else
+ {
+ wcout << endl
+ << ind << "{" << endl;
+ indent++;
+
+ edge_traverser ().dispatch (l.argumented ());
+
+ indent--;
+ wcout << ind << "}" << endl;
+ }
}
};
@@ -70,7 +85,29 @@ namespace
<< endl;
wcout << ind << "union " <<
- (u.named () ? u.name () : String ("<anonymous>")) << endl;
+ (u.named () ? u.name () : String ("<anonymous>")) << " ";
+
+ for (Type::ArgumentedIterator i (u.argumented_begin ());
+ i != u.argumented_end (); ++i)
+ {
+ SemanticGraph::Type& t (i->type ());
+
+ if (t.named ())
+ wcout << ref_name (t) << " ";
+ else
+ {
+ wcout << endl
+ << ind << "{" << endl;
+ indent++;
+
+ edge_traverser ().dispatch (*i);
+
+ indent--;
+ wcout << ind << "}" << endl;
+ }
+ }
+
+ wcout << endl;
}
};
@@ -508,14 +545,12 @@ namespace
struct AnonymousNameTranslator: Transformations::AnonymousNameTranslator
{
virtual WideString
- translate (WideString const& file,
+ translate (WideString const& /*file*/,
WideString const& ns,
WideString const& name,
WideString const& xpath)
{
- wcout << "anonymous: " << file << " " << ns << " " << name << " " <<
- xpath << endl;
-
+ wcout << "anonymous: " << ns << " " << name << " " << xpath << endl;
return name;
}
};
@@ -647,6 +682,17 @@ main (Int argc, Char* argv[])
//
//
+ Traversal::Argumented argumented;
+ list >> argumented;
+ union_ >> argumented;
+
+ argumented >> list;
+ argumented >> union_;
+ argumented >> complex;
+ argumented >> enumeration;
+
+ //
+ //
Enumerator enumerator;
enumeration_names >> enumerator;
diff --git a/tests/schema/annotation/test-000.std b/tests/schema/annotation/test-000.std
index ed7f1e1..15f3e89 100644
--- a/tests/schema/annotation/test-000.std
+++ b/tests/schema/annotation/test-000.std
@@ -6,7 +6,7 @@ primary
<list type documentation>
list list http://www.w3.org/2001/XMLSchema#string
<union type documentation>
- union union
+ union union http://www.w3.org/2001/XMLSchema#int http://www.w3.org/2001/XMLSchema#string
<enumeration type documentation>
enumeration enum: http://www.w3.org/2001/XMLSchema#string
{
diff --git a/tests/schema/anonymous/test-000.std b/tests/schema/anonymous/test-000.std
index 7acb22b..1f33cb0 100644
--- a/tests/schema/anonymous/test-000.std
+++ b/tests/schema/anonymous/test-000.std
@@ -1,6 +1,6 @@
-anonymous: test anon_item anon
-anonymous: test anon_nested_item anon_nested
-anonymous: test anon_nested_item_base anon_nested_item
+anonymous: test anon_item anon
+anonymous: test anon_nested_item anon_nested
+anonymous: test anon_nested_item_base anon_nested_item
primary
{
namespace test
diff --git a/tests/schema/anonymous/test-001.std b/tests/schema/anonymous/test-001.std
index 11a2aed..cc3f2d1 100644
--- a/tests/schema/anonymous/test-001.std
+++ b/tests/schema/anonymous/test-001.std
@@ -1,6 +1,6 @@
-anonymous: test anon_base anon
-anonymous: test anon_nested_base anon_nested
-anonymous: test anon_nested_base_base anon_nested_base
+anonymous: test anon_base anon
+anonymous: test anon_nested_base anon_nested
+anonymous: test anon_nested_base_base anon_nested_base
primary
{
namespace test
diff --git a/tests/schema/makefile b/tests/schema/makefile
index 9b69ea7..b0fab92 100644
--- a/tests/schema/makefile
+++ b/tests/schema/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
-tests := annotation anonymous attribute-group element-group default
+tests := annotation anonymous attribute-group element-group default union
default := $(out_base)/
test := $(out_base)/.test
diff --git a/tests/schema/union/makefile b/tests/schema/union/makefile
new file mode 100644
index 0000000..498c3cc
--- /dev/null
+++ b/tests/schema/union/makefile
@@ -0,0 +1,35 @@
+# file : tests/schema/union/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
+
+tests := 000
+
+driver := $(out_root)/tests/dump/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Test.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+$(test): $(test_targets)
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test-%.xsd $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xsd | diff -u $(src_base)/test-$*.std -)
+
+# Clean.
+#
+$(clean):
+
+# Dependencies.
+#
+$(call import,$(src_root)/tests/dump/makefile)
diff --git a/tests/schema/union/test-000.std b/tests/schema/union/test-000.std
new file mode 100644
index 0000000..6f95b0c
--- /dev/null
+++ b/tests/schema/union/test-000.std
@@ -0,0 +1,37 @@
+primary
+{
+ namespace test
+ {
+ union u1 http://www.w3.org/2001/XMLSchema#int http://www.w3.org/2001/XMLSchema#string
+ union u2
+ {
+ enumeration <anonymous>: http://www.w3.org/2001/XMLSchema#token
+ {
+ enumerator one
+ }
+ }
+
+ {
+ enumeration <anonymous>: http://www.w3.org/2001/XMLSchema#string
+ {
+ enumerator two
+ }
+ }
+
+ union u3 http://www.w3.org/2001/XMLSchema#int test#u1
+ {
+ enumeration <anonymous>: http://www.w3.org/2001/XMLSchema#token
+ {
+ enumerator one
+ }
+ }
+
+ {
+ enumeration <anonymous>: http://www.w3.org/2001/XMLSchema#string
+ {
+ enumerator two
+ }
+ }
+
+ }
+}
diff --git a/tests/schema/union/test-000.xsd b/tests/schema/union/test-000.xsd
new file mode 100644
index 0000000..99535de
--- /dev/null
+++ b/tests/schema/union/test-000.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="u1">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <simpleType name="u2">
+ <union>
+ <simpleType>
+ <restriction base="token">
+ <enumeration value="one"/>
+ </restriction>
+ </simpleType>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="two"/>
+ </restriction>
+ </simpleType>
+ </union>
+ </simpleType>
+
+ <simpleType name="u3">
+ <union memberTypes=" int
+
+t:u1 ">
+ <simpleType>
+ <restriction base="token">
+ <enumeration value="one"/>
+ </restriction>
+ </simpleType>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="two"/>
+ </restriction>
+ </simpleType>
+ </union>
+ </simpleType>
+
+</schema>