Skip to content

Commit 6735560

Browse files
committed
[test] refactor serialize.xql
The value for each serialization option is now paremeterized.
1 parent 72f4c94 commit 6735560

File tree

1 file changed

+60
-62
lines changed

1 file changed

+60
-62
lines changed

exist-core/src/test/xquery/xquery3/serialize.xql

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ declare variable $ser:xi-doc := document {
174174
</article>
175175
};
176176

177+
declare variable $ser:in-memory-book :=
178+
<book>
179+
<author>John Doe</author>
180+
<author>Robert Smith</author>
181+
</book>
182+
;
183+
177184
declare
178185
%test:setUp
179186
function ser:setup() {
@@ -665,126 +672,117 @@ function ser:adaptive-xs-strings-map-params() {
665672
};
666673

667674
declare
675+
%test:args("true")
668676
%test:assertXPath("contains($result, '-//OASIS//DTD DITA BookMap//EN') and contains($result, 'bookmap.dtd')")
669-
function ser:exist-output-doctype-true() {
677+
%test:args("false")
678+
%test:assertXPath("not(contains($result, '-//OASIS//DTD DITA BookMap//EN')) and not(contains($result, 'bookmap.dtd'))")
679+
function ser:exist-output-doctype-QName($value as xs:boolean) {
670680
serialize(doc($ser:collection || "/test-with-doctype.xml"),
671-
map { "exist:output-doctype": true() })
681+
map { xs:QName("exist:output-doctype") : $value })
672682
};
673683

674684
declare
685+
%test:args("true")
675686
%test:assertXPath("contains($result, '-//OASIS//DTD DITA BookMap//EN') and contains($result, 'bookmap.dtd')")
676-
function ser:exist-output-doctype-true-QName() {
677-
serialize(doc($ser:collection || "/test-with-doctype.xml"),
678-
map { xs:QName("exist:output-doctype"): true() })
679-
};
680-
681-
declare
687+
%test:args("false")
682688
%test:assertXPath("not(contains($result, '-//OASIS//DTD DITA BookMap//EN')) and not(contains($result, 'bookmap.dtd'))")
683-
function ser:exist-output-doctype-false() {
689+
function ser:exist-output-doctype-string($value as xs:boolean) {
684690
serialize(doc($ser:collection || "/test-with-doctype.xml"),
685-
map { "exist:output-doctype": false() })
686-
};
687-
688-
declare
689-
%test:assertXPath("contains($result, 'include')")
690-
function ser:exist-expand-xinclude-false() {
691-
serialize($ser:xi-doc,
692-
map { "exist:expand-xincludes": false() })
691+
map { "exist:output-doctype" : $value })
693692
};
694693

695694
declare
695+
%test:args("true")
696696
%test:assertXPath("contains($result, 'comment')")
697-
function ser:exist-expand-xinclude-true() {
697+
%test:args("false")
698+
%test:assertXPath("contains($result, 'include')")
699+
function ser:exist-expand-xinclude-QName($value as xs:boolean) {
698700
serialize($ser:xi-doc,
699-
map { "exist:expand-xincludes": true() })
701+
map { xs:QName("exist:expand-xincludes"): $value })
700702
};
701703

702704
declare
705+
%test:args("true")
703706
%test:assertXPath("contains($result, 'comment')")
704-
function ser:exist-expand-xinclude-true-QName() {
707+
%test:args("false")
708+
%test:assertXPath("contains($result, 'include')")
709+
function ser:exist-expand-xinclude-string($value as xs:boolean) {
705710
serialize($ser:xi-doc,
706-
map { xs:QName("exist:expand-xincludes"): true() })
711+
map { "exist:expand-xincludes": $value })
707712
};
708713

709714
declare
715+
%test:args("all")
710716
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b exist:id="2.3">123</b></elem>')
711-
function ser:exist-add-exist-id-all() {
717+
%test:args("element")
718+
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b>123</b></elem>')
719+
%test:args("none")
720+
%test:assertXPath("not(contains($result, 'exist:id'))")
721+
function ser:exist-add-exist-id-QName($value as xs:string) {
712722
serialize(doc($ser:collection || "/test.xml"),
713-
map { "exist:add-exist-id": "all" })
723+
map { xs:QName("exist:add-exist-id"): $value })
714724
};
715725

716726
declare
727+
%test:args("all")
717728
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b exist:id="2.3">123</b></elem>')
718-
function ser:exist-add-exist-id-all-QName() {
719-
serialize(doc($ser:collection || "/test.xml"),
720-
map { xs:QName("exist:add-exist-id"): "all" })
721-
};
722-
723-
declare
729+
%test:args("element")
724730
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b>123</b></elem>')
725-
function ser:exist-add-exist-id-element() {
726-
serialize(doc($ser:collection || "/test.xml"),
727-
map { "exist:add-exist-id": "element" })
728-
};
729-
730-
declare
731-
%test:assertXPath("not(contains($result, 'exist:id'))")
732-
function ser:exist-add-exist-id-none() {
731+
%test:args("none")
732+
%test:assertXPath("not(contains($result, 'exist:id'))")
733+
function ser:exist-add-exist-id-string($value as xs:string) {
733734
serialize(doc($ser:collection || "/test.xml"),
734-
map { "exist:add-exist-id": "none" })
735+
map { "exist:add-exist-id": $value })
735736
};
736737

737738
declare
739+
%test:args("functionName")
738740
%test:assertEquals('functionName({"author":["John Doe","Robert Smith"]})')
739-
function ser:exist-jsonp() {
740-
serialize(
741-
<book>
742-
<author>John Doe</author>
743-
<author>Robert Smith</author>
744-
</book>,
741+
%test:args("anotherName")
742+
%test:assertEquals('anotherName({"author":["John Doe","Robert Smith"]})')
743+
function ser:exist-jsonp-QName($value as xs:string) {
744+
serialize($ser:in-memory-book,
745745
map {
746746
"method": "json",
747747
"media-type": "application/json",
748-
"exist:jsonp": "functionName"
748+
xs:QName("exist:jsonp"): $value
749749
}
750750
)
751751
};
752752

753753
declare
754+
%test:args("functionName")
754755
%test:assertEquals('functionName({"author":["John Doe","Robert Smith"]})')
755-
function ser:exist-jsonp-QName() {
756-
serialize(
757-
<book>
758-
<author>John Doe</author>
759-
<author>Robert Smith</author>
760-
</book>,
756+
%test:args("anotherName")
757+
%test:assertEquals('anotherName({"author":["John Doe","Robert Smith"]})')
758+
function ser:exist-jsonp-string($value as xs:string) {
759+
serialize($ser:in-memory-book,
761760
map {
762761
"method": "json",
763762
"media-type": "application/json",
764-
xs:QName("exist:jsonp"): "functionName"
763+
"exist:jsonp": $value
765764
}
766765
)
767766
};
768767

769768
declare
769+
%test:args("true")
770770
%test:assertEquals('processed')
771-
function ser:exist-process-xsl-pi-true() {
771+
%test:args("false")
772+
%test:assertXPath("contains($result, 'stylesheet')")
773+
function ser:exist-process-xsl-pi-QName($value as xs:boolean) {
772774
serialize(doc($ser:collection || "/test-xsl.xml"),
773-
map { "exist:process-xsl-pi": true() })
775+
map { xs:QName("exist:process-xsl-pi"): $value })
774776
};
775777

776778
declare
779+
%test:args("true")
777780
%test:assertEquals('processed')
778-
function ser:exist-process-xsl-pi-true-QName() {
779-
serialize(doc($ser:collection || "/test-xsl.xml"),
780-
map { xs:QName("exist:process-xsl-pi"): true() })
781-
};
782-
783-
declare
781+
%test:args("false")
784782
%test:assertXPath("contains($result, 'stylesheet')")
785-
function ser:exist-process-xsl-pi-false() {
783+
function ser:exist-process-xsl-pi-string($value as xs:boolean) {
786784
serialize(doc($ser:collection || "/test-xsl.xml"),
787-
map { "exist:process-xsl-pi": false() })
785+
map { "exist:process-xsl-pi": $value })
788786
};
789787

790788
declare

0 commit comments

Comments
 (0)