diff options
Diffstat (limited to 'tests/auto/xmlpatterns/queries')
33 files changed, 291 insertions, 0 deletions
diff --git a/tests/auto/xmlpatterns/queries/README b/tests/auto/xmlpatterns/queries/README new file mode 100644 index 0000000..ab0726f --- /dev/null +++ b/tests/auto/xmlpatterns/queries/README @@ -0,0 +1,4 @@ +The queries in this directory are used by several tests, at least: cli/ and +qxmlquery/. When adding queries, make sure the correct baselines have been +generated for the auto tests that use them. + diff --git a/tests/auto/xmlpatterns/queries/allAtomics.xq b/tests/auto/xmlpatterns/queries/allAtomics.xq new file mode 100644 index 0000000..f2ea459 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/allAtomics.xq @@ -0,0 +1,50 @@ +xs:untypedAtomic("xs:untypedAtomic"), +xs:dateTime("2002-10-10T23:02:11Z"), +xs:date("2002-10-10Z"), +xs:time("23:02:12Z"), +xs:duration("P12M"), + +(: Sub-types of xs:duration :) +xs:dayTimeDuration("PT1S"), +xs:yearMonthDuration("P1M"), + +xs:float("3e3"), +xs:double("4e4"), +xs:decimal("2.0"), +(: Sub-types of xs:decimal :) +xs:integer("16"), +xs:nonPositiveInteger("-6"), +xs:negativeInteger("-4"), +xs:long("5"), +xs:int("6"), +xs:short("7"), +xs:byte("8"), +xs:nonNegativeInteger("9"), +xs:unsignedLong("10"), +xs:unsignedInt("11"), +xs:unsignedShort("12"), +xs:unsignedByte("13"), +xs:positiveInteger("14"), + +xs:gYearMonth("1976-02Z"), +xs:gYear("2005-12:00"), +xs:gMonthDay("--12-25-14:00"), +xs:gDay("---25-14:00"), +xs:gMonth("--12-14:00"), +xs:boolean("true"), +xs:base64Binary("aaaa"), +xs:hexBinary("FFFF"), +xs:anyURI("http://example.com/"), +QName("http://example.com/2", "prefix:localName"), + +xs:string("An xs:string"), +(: Sub-types of xs:string :) +xs:normalizedString("normalizedString"), +xs:token("token"), +xs:language("language"), +xs:NMTOKEN("NMTOKEN"), +xs:Name("Name"), +xs:NCName("NCName"), +xs:ID("ID"), +xs:IDREF("IDREF"), +xs:ENTITY("ENTITY") diff --git a/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq b/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq new file mode 100644 index 0000000..e3f8686 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq @@ -0,0 +1,33 @@ +(: fromQTime is intentionally not here, since + we don't support it. :) + +string-join(for $i in ( + $fromFloat, + $fromBool, + $fromDouble, + $fromIntLiteral, + $fromLongLong, + $fromQByteArray, + $fromQChar, + $fromQDate, + $fromQDateTime, + $fromQString, + $fromQUrl, + $fromUInt, + $fromULongLong, + $fromBool instance of xs:boolean, + $fromDouble instance of xs:double, + $fromFloat instance of xs:double, + $fromIntLiteral instance of xs:integer, + $fromLongLong instance of xs:integer, + $fromQByteArray instance of xs:base64Binary, + $fromQChar instance of xs:string, + $fromQDate instance of xs:date, + $fromQDateTime instance of xs:dateTime, + $fromQString instance of xs:string, + $fromQUrl instance of xs:string, + $fromUInt instance of xs:integer, + $fromULongLong instance of xs:unsignedLong) + return string($i), + " ") + diff --git a/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq b/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq diff --git a/tests/auto/xmlpatterns/queries/concat.xq b/tests/auto/xmlpatterns/queries/concat.xq new file mode 100644 index 0000000..08acf55 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/concat.xq @@ -0,0 +1 @@ +concat("abc", "def") diff --git a/tests/auto/xmlpatterns/queries/emptySequence.xq b/tests/auto/xmlpatterns/queries/emptySequence.xq new file mode 100644 index 0000000..df672d0 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/emptySequence.xq @@ -0,0 +1,2 @@ +(: This query evaluates to nothing. :) +() diff --git a/tests/auto/xmlpatterns/queries/errorFunction.xq b/tests/auto/xmlpatterns/queries/errorFunction.xq new file mode 100644 index 0000000..a77884a --- /dev/null +++ b/tests/auto/xmlpatterns/queries/errorFunction.xq @@ -0,0 +1 @@ +fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000')) diff --git a/tests/auto/xmlpatterns/queries/externalStringVariable.xq b/tests/auto/xmlpatterns/queries/externalStringVariable.xq new file mode 100644 index 0000000..1133714 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/externalStringVariable.xq @@ -0,0 +1 @@ +concat("START ", $externalString, " END") diff --git a/tests/auto/xmlpatterns/queries/externalVariable.xq b/tests/auto/xmlpatterns/queries/externalVariable.xq new file mode 100644 index 0000000..edff16e --- /dev/null +++ b/tests/auto/xmlpatterns/queries/externalVariable.xq @@ -0,0 +1,2 @@ +declare variable $externalVariableAsInt as xs:integer := xs:integer($externalVariable); +$externalVariable, $externalVariableAsInt + 3, <e>{$externalVariable}</e>, $externalVariable instance of xs:string diff --git a/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq b/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq new file mode 100644 index 0000000..ba13875 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq @@ -0,0 +1 @@ +$externalVariable, $externalVariable diff --git a/tests/auto/xmlpatterns/queries/flwor.xq b/tests/auto/xmlpatterns/queries/flwor.xq new file mode 100644 index 0000000..16e3b2c --- /dev/null +++ b/tests/auto/xmlpatterns/queries/flwor.xq @@ -0,0 +1,4 @@ +for $a in (1, 4, 2) +let $i := (1, 3, 2) +order by $i +return $i diff --git a/tests/auto/xmlpatterns/queries/globals.gccxml b/tests/auto/xmlpatterns/queries/globals.gccxml new file mode 100644 index 0000000..81bcb22 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/globals.gccxml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<GCC_XML> + <Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 " mangled="_Z2::"/> + <Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/> + <Function id="_3" name="_GLOBAL__D_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/> + <Function id="_4" name="_GLOBAL__I_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/> + <Function id="_5" name="__static_initialization_and_destruction_0" returns="_16" context="_1" mangled="_Z41__static_initialization_and_destruction_0ii" location="f0:23" file="f0" line="23" endline="14"> + <Argument name="__initialize_p" type="_17"/> + <Argument name="__priority" type="_17"/> + </Function> + <Function id="_6" name="main" returns="_17" context="_1" location="f0:20" file="f0" line="20" endline="24"/> + <Variable id="_7" name="constComplex2" type="_11c" context="_1" location="f0:17" file="f0" line="17"/> + <Variable id="_8" name="constComplex1" type="_11c" context="_1" location="f0:16" file="f0" line="16"/> + <Variable id="_9" name="mutableComplex2" type="_11" context="_1" location="f0:15" file="f0" line="15"/> + <Variable id="_10" name="mutableComplex1" type="_11" context="_1" location="f0:14" file="f0" line="14"/> + <Class id="_11" name="ComplexClass" context="_1" mangled="12ComplexClass" location="f0:7" file="f0" line="7" members="_19 _20 _21 " bases=""/> + <Variable id="_12" name="constPrimitive2" type="_17c" init="3" context="_1" location="f0:4" file="f0" line="4"/> + <Variable id="_13" name="constPrimitive1" type="_17c" init="4" context="_1" location="f0:3" file="f0" line="3"/> + <Variable id="_14" name="mutablePrimitive2" type="_17" context="_1" location="f0:2" file="f0" line="2"/> + <Variable id="_15" name="mutablePrimitive1" type="_17" context="_1" location="f0:1" file="f0" line="1"/> + <FundamentalType id="_16" name="void"/> + <FundamentalType id="_17" name="int"/> + <CvQualifiedType id="_11c" type="_11" const="1"/> + <Constructor id="_19" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1Ev *INTERNAL* " location="f0:9" file="f0" line="9" extern="1"/> + <Constructor id="_20" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1ERKS_ *INTERNAL* " location="f0:10" file="f0" line="10" extern="1"> + <Argument type="_23"/> + </Constructor> + <Destructor id="_21" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassD1Ev *INTERNAL* " location="f0:11" file="f0" line="11" extern="1"> + </Destructor> + <CvQualifiedType id="_17c" type="_17" const="1"/> + <ReferenceType id="_23" type="_11c"/> + <File id="f0" name="globals.cpp"/> +</GCC_XML> diff --git a/tests/auto/xmlpatterns/queries/invalidRegexp.xq b/tests/auto/xmlpatterns/queries/invalidRegexp.xq new file mode 100644 index 0000000..fa89b22 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/invalidRegexp.xq @@ -0,0 +1 @@ +tokenize("input", "\") diff --git a/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq b/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq new file mode 100644 index 0000000..b15f8ad --- /dev/null +++ b/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq @@ -0,0 +1 @@ +tokenize("input", "pattern", "INVALID") diff --git a/tests/auto/xmlpatterns/queries/nodeSequence.xq b/tests/auto/xmlpatterns/queries/nodeSequence.xq new file mode 100644 index 0000000..721cb86 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/nodeSequence.xq @@ -0,0 +1,31 @@ +document{()}, +document{()}, +document{()}, +document{""}, +document{""}, +document{text{()}}, +document{text{()}}, +document{text{"text1"}}, +document{text{"text2"}}, +document{<f/>}, +<e1/>, +<e2/>, +<e3/>, +<e3 attr1="value1"/>, +attribute name {"value"}, +text{()}, +text{"text3"}, +<e5> + text4 + <e/> + text5 + <?target data?> + <!-- comment --> + <e6 attr2="value2" attr3="value2"/> + <e6 attr2="value3" attr3="value3"/> + <e6 attr2="value4" attr3="value4"/> +</e5>, +<?target data?>, +<!-- comment -->, +<e xmlns="http://example.com/"/>, +<p:e xmlns:p="http://example.com/"/> diff --git a/tests/auto/xmlpatterns/queries/nonexistingCollection.xq b/tests/auto/xmlpatterns/queries/nonexistingCollection.xq new file mode 100644 index 0000000..1c18cc4 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/nonexistingCollection.xq @@ -0,0 +1 @@ +collection("doesNotExistForSure") diff --git a/tests/auto/xmlpatterns/queries/oneElement.xq b/tests/auto/xmlpatterns/queries/oneElement.xq new file mode 100644 index 0000000..10a7e70 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/oneElement.xq @@ -0,0 +1 @@ +<e/> diff --git a/tests/auto/xmlpatterns/queries/onePlusOne.xq b/tests/auto/xmlpatterns/queries/onePlusOne.xq new file mode 100644 index 0000000..8d2f097 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/onePlusOne.xq @@ -0,0 +1 @@ +1 + 1 diff --git a/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq b/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq new file mode 100644 index 0000000..c0c40ee --- /dev/null +++ b/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq @@ -0,0 +1 @@ +document{ () } diff --git a/tests/auto/xmlpatterns/queries/openDocument.xq b/tests/auto/xmlpatterns/queries/openDocument.xq new file mode 100644 index 0000000..73702dd --- /dev/null +++ b/tests/auto/xmlpatterns/queries/openDocument.xq @@ -0,0 +1 @@ +doc("simpleDocument.xml") diff --git a/tests/auto/xmlpatterns/queries/reportGlobals.xq b/tests/auto/xmlpatterns/queries/reportGlobals.xq new file mode 100644 index 0000000..52fecd5 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/reportGlobals.xq @@ -0,0 +1,101 @@ +(: + This query opens a C++ GCC-XML output file, and outputs a report describing the use + of globals variables. + + Run it, by invoking, for instance: + + patternist reportGlobal.xq fileToOpen=globals.gccxml > globals.html + + "fileToOpen=globals.gccxml" binds the string "globals.gccxml" to the variable + "fileToOpen." It identifies the GCC-XML file to open. + +:) +declare variable $inDoc as document-node() := doc($fileToOpen); + +(: Determines whether the type by ID @p typeId is a complex type such as QString. :) +declare function local:isComplexType($typeID as xs:string) as xs:boolean +{ + (: We're being a bit crude here and only checks whether it's a class. We + actually should check whether it has non-synthesized, + constructors, I believe. :) + + exists($inDoc/GCC_XML/Class[@id = $typeID]) + or + (: We also want const-qualified variables. :) + exists($inDoc/GCC_XML/Class[@id = $inDoc/GCC_XML/CvQualifiedType[@id = $typeID]/@type]) +}; + +declare function local:isPrimitive($typeId as xs:string) as xs:boolean +{ + exists($inDoc/GCC_XML/FundamentalType[@id = $typeId]) +}; + +(: Returns a string for human consumption that describes + the location of @p block. :) +declare function local:location($block as element()) as xs:string +{ + concat($inDoc/GCC_XML/File[@id = $block/@file]/@name, " at line ", $block/@line) +}; + +declare function local:report() as element()+ +{ + let $complexVariables as element(Variable)* := $inDoc/GCC_XML/Variable[local:isComplexType(@type)] + return if(exists($complexVariables)) (: Is the length larger than zero? :) + + then (<p xmlns="http://www.w3.org/1999/xhtml/">The following global, complex variables were found:</p>, + <ol xmlns="http://www.w3.org/1999/xhtml/"> + { + (: For each Variable in $complexVariables... :) + $complexVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li> + } + </ol>) + + else <p xmlns="http://www.w3.org/1999/xhtml/">No global variables that are of complex types were found.</p> + + , + + (: List primitive, mutable types. :) + let $primitiveVariables as element(Variable)+ := $inDoc/GCC_XML/Variable[local:isPrimitive(@type)] + return if(exists($primitiveVariables)) + + then (<p xmlns="http://www.w3.org/1999/xhtml/">The following mutable primitives were found:</p>, + <ol xmlns="http://www.w3.org/1999/xhtml/"> + { + (: For each Variable in $complexVariables... :) + $primitiveVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li> + } + </ol>) + + else <p xmlns="http://www.w3.org/1999/xhtml/">No global variables that are of complex types were found.</p> +}; + +<html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en"> + <head> + <title>Global variables report for {$fileToOpen}</title> + </head> + <style type="text/css"> + .details + {{ + text-align: center; + font-size: 80%; + color: gray + }} + .variableName + {{ + font-family: courier + }} + </style> + + <body> + { + (: We don't want simple types that are const, but all other types. + One could frown upon const integers and say enums should be used instead, but + let's be gentle. :) + + local:report() + } + + <p class="details">This report was generated on</p> + </body> + +</html> diff --git a/tests/auto/xmlpatterns/queries/simpleDocument.xml b/tests/auto/xmlpatterns/queries/simpleDocument.xml new file mode 100644 index 0000000..9b0ff02 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/simpleDocument.xml @@ -0,0 +1 @@ +<e xmlns="http://example.com" attr="1" xmlns:p="http://example.com/P" p:attr=""><?target data?><!-- a comment --><e/><![CDATA[text]]> <f/>text node</e> diff --git a/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq b/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq new file mode 100644 index 0000000..42b4d2e --- /dev/null +++ b/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq @@ -0,0 +1,5 @@ +module namespace prefix = "http://example.com"; +declare function prefix:myFunction() +{ +1 +}; diff --git a/tests/auto/xmlpatterns/queries/staticBaseURI.xq b/tests/auto/xmlpatterns/queries/staticBaseURI.xq new file mode 100644 index 0000000..25b307a --- /dev/null +++ b/tests/auto/xmlpatterns/queries/staticBaseURI.xq @@ -0,0 +1,3 @@ +(: We convert the value to xs:string such that we can use it + with QXmlQuery::evaluateTo(QStringList) :) +string(static-base-uri()) diff --git a/tests/auto/xmlpatterns/queries/staticError.xq b/tests/auto/xmlpatterns/queries/staticError.xq new file mode 100644 index 0000000..1aff277 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/staticError.xq @@ -0,0 +1 @@ +"This string literal is never closeThis string literal is never closed diff --git a/tests/auto/xmlpatterns/queries/syntaxError.xq b/tests/auto/xmlpatterns/queries/syntaxError.xq new file mode 100644 index 0000000..5ad4982 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/syntaxError.xq @@ -0,0 +1 @@ +for 1 to 100 diff --git a/tests/auto/xmlpatterns/queries/threeVariables.xq b/tests/auto/xmlpatterns/queries/threeVariables.xq new file mode 100644 index 0000000..d0f98c1 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/threeVariables.xq @@ -0,0 +1 @@ +$var1, $var2, $var3 diff --git a/tests/auto/xmlpatterns/queries/twoVariables.xq b/tests/auto/xmlpatterns/queries/twoVariables.xq new file mode 100644 index 0000000..a3a67c8 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/twoVariables.xq @@ -0,0 +1 @@ +$var1, $var2 diff --git a/tests/auto/xmlpatterns/queries/typeError.xq b/tests/auto/xmlpatterns/queries/typeError.xq new file mode 100644 index 0000000..d91861a --- /dev/null +++ b/tests/auto/xmlpatterns/queries/typeError.xq @@ -0,0 +1 @@ +1 + "type error" diff --git a/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq b/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq new file mode 100644 index 0000000..219ba0d --- /dev/null +++ b/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq @@ -0,0 +1,2 @@ +declare variable $thisVariableIsNotBound external; +1 diff --git a/tests/auto/xmlpatterns/queries/unsupportedCollation.xq b/tests/auto/xmlpatterns/queries/unsupportedCollation.xq new file mode 100644 index 0000000..679323c --- /dev/null +++ b/tests/auto/xmlpatterns/queries/unsupportedCollation.xq @@ -0,0 +1,2 @@ +declare default collation "http://example.com/UnsupportedCollation"; +1 diff --git a/tests/auto/xmlpatterns/queries/wrongArity.xq b/tests/auto/xmlpatterns/queries/wrongArity.xq new file mode 100644 index 0000000..4e507a3 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/wrongArity.xq @@ -0,0 +1 @@ +fn:doc() diff --git a/tests/auto/xmlpatterns/queries/zeroDivision.xq b/tests/auto/xmlpatterns/queries/zeroDivision.xq new file mode 100644 index 0000000..34d5ac5 --- /dev/null +++ b/tests/auto/xmlpatterns/queries/zeroDivision.xq @@ -0,0 +1 @@ +1 div 0 |