From e160f9f67afc4117246a4f02dd0431490a4e4ce7 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Wed, 4 Dec 2024 11:08:03 +0000 Subject: [PATCH] [refactor] Remove duplicate tests --- .../xquery/nested-positional-predicate.xqm | 158 ++++++++++++++++++ exist-core/src/test/xquery/npt.xqm | 117 ------------- .../src/test/xquery/positional-nested.xql | 157 ----------------- 3 files changed, 158 insertions(+), 274 deletions(-) create mode 100644 exist-core/src/test/xquery/nested-positional-predicate.xqm delete mode 100644 exist-core/src/test/xquery/npt.xqm delete mode 100644 exist-core/src/test/xquery/positional-nested.xql diff --git a/exist-core/src/test/xquery/nested-positional-predicate.xqm b/exist-core/src/test/xquery/nested-positional-predicate.xqm new file mode 100644 index 00000000000..4c6a24dc6df --- /dev/null +++ b/exist-core/src/test/xquery/nested-positional-predicate.xqm @@ -0,0 +1,158 @@ +(: + : eXist-db Open Source Native XML Database + : Copyright (C) 2001 The eXist-db Authors + : + : info@exist-db.org + : http://www.exist-db.org + : + : This library is free software; you can redistribute it and/or + : modify it under the terms of the GNU Lesser General Public + : License as published by the Free Software Foundation; either + : version 2.1 of the License, or (at your option) any later version. + : + : This library is distributed in the hope that it will be useful, + : but WITHOUT ANY WARRANTY; without even the implied warranty of + : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + : Lesser General Public License for more details. + : + : You should have received a copy of the GNU Lesser General Public + : License along with this library; if not, write to the Free Software + : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + :) +xquery version "3.1"; + +module namespace npp="http://exist-db.org/test/nested-positional-predicate"; + +declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace test="http://exist-db.org/xquery/xqsuite"; + +declare variable $npp:TEST_COLLECTION_NAME := "test-positional-nested"; +declare variable $npp:TEST_COLLECTION_URI := "/db/" || $npp:TEST_COLLECTION_NAME; +declare variable $npp:TEST_DOC_NAME := "test.xml"; +declare variable $npp:TEST_DOC_URI := $npp:TEST_COLLECTION_URI || "/" || $npp:TEST_DOC_NAME; + +declare variable $npp:DATA := + document { + + + B1 + + + B2 + correct + + + B3 + wrong + + + }; + +declare + %test:setUp +function npp:setup() { + xmldb:create-collection("/db", $npp:TEST_COLLECTION_NAME), + xmldb:store($npp:TEST_COLLECTION_URI, $npp:TEST_DOC_NAME, $npp:DATA) +}; + +declare + %test:tearDown +function npp:cleanup() { + xmldb:remove($npp:TEST_COLLECTION_URI) +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-1() { + {$npp:DATA//c[../preceding-sibling::a]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-2() { + {$npp:DATA//c[parent::node()/preceding-sibling::a]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-3() { + {$npp:DATA//c/..[preceding-sibling::a]/c} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-4() { + {$npp:DATA//c/parent::node()[preceding-sibling::a]/c} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-1() { + {doc($npp:TEST_DOC_URI)//c[../preceding-sibling::a]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-2() { + {doc($npp:TEST_DOC_URI)//c[parent::node()/preceding-sibling::a]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-3() { + {doc($npp:TEST_DOC_URI)//c/..[preceding-sibling::a]/c} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-4() { + {doc($npp:TEST_DOC_URI)//c/parent::node()[preceding-sibling::a]/c} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-predicate() { + {$npp:DATA//c[../preceding-sibling::a[1]]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-predicate() { + {doc($npp:TEST_DOC_URI)//c[../preceding-sibling::a[1]]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-memory-position() { + {$npp:DATA//c[../preceding-sibling::a[position() eq 1]]} +}; + +declare + %test:assertEquals("correctwrong") +function npp:in-database-position() { + {doc($npp:TEST_DOC_URI)//c[../preceding-sibling::a[position() eq 1]]} +}; + +declare + %test:assertEquals("correct") +function npp:in-memory-predicate-and-path() { + {$npp:DATA//c[../preceding-sibling::a[1]/b = 'B1']} +}; + +declare + %test:assertEquals("correct") +function npp:in-database-predicate-and-path() { + {doc($npp:TEST_DOC_URI)//c[../preceding-sibling::a[1]/b = 'B1']} +}; + +declare + %test:assertEquals("correct") +function npp:in-memory-position-and-path() { + {$npp:DATA//c[../preceding-sibling::a[position() eq 1]/b = 'B1']} +}; + +declare + %test:assertEquals("correct") +function npp:in-database-position-and-path() { + {doc($npp:TEST_DOC_URI)//c[../preceding-sibling::a[position() eq 1]/b = 'B1']} +}; diff --git a/exist-core/src/test/xquery/npt.xqm b/exist-core/src/test/xquery/npt.xqm deleted file mode 100644 index 51f32ba4209..00000000000 --- a/exist-core/src/test/xquery/npt.xqm +++ /dev/null @@ -1,117 +0,0 @@ -(: - : eXist-db Open Source Native XML Database - : Copyright (C) 2001 The eXist-db Authors - : - : info@exist-db.org - : http://www.exist-db.org - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public - : License as published by the Free Software Foundation; either - : version 2.1 of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - : Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public - : License along with this library; if not, write to the Free Software - : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - :) -xquery version "3.1"; - -module namespace npt="http://exist-db.org/test/nested-positional-predicate"; - -declare namespace test="http://exist-db.org/xquery/xqsuite"; - -declare variable $npt:DATA := - document { - - - B1 - - - B2 - correct - - - B3 - wrong - - - }; - -declare - %test:setUp -function npt:setup() { - xmldb:create-collection("/db", "test"), - xmldb:store("/db/test", "test.xml", $npt:DATA) -}; - -declare - %test:tearDown -function npt:cleanup() { - xmldb:remove("/db/test") -}; - -declare - %test:assertEquals("correctwrong") -function npt:in-memory() { - {$npt:DATA//c[../preceding-sibling::a]} -}; - -declare - %test:assertEquals("correctwrong") -function npt:in-database() { - {doc("/db/test/test.xml")//c[../preceding-sibling::a]} -}; - - -declare - %test:assertEquals("correctwrong") -function npt:in-memory-predicate() { - {$npt:DATA//c[../preceding-sibling::a[1]]} -}; - -declare - %test:assertEquals("correctwrong") -function npt:in-database-predicate() { - {doc("/db/test/test.xml")//c[../preceding-sibling::a[1]]} -}; - -declare - %test:assertEquals("correctwrong") -function npt:in-memory-position() { - {$npt:DATA//c[../preceding-sibling::a[position() eq 1]]} -}; - -declare - %test:assertEquals("correctwrong") -function npt:in-database-position() { - {doc("/db/test/test.xml")//c[../preceding-sibling::a[position() eq 1]]} -}; - -declare - %test:assertEquals("correct") -function npt:in-memory-predicate-and-path() { - {$npt:DATA//c[../preceding-sibling::a[1]/b = 'B1']} -}; - -declare - %test:assertEquals("correct") -function npt:in-database-predicate-and-path() { - {doc("/db/test/test.xml")//c[../preceding-sibling::a[1]/b = 'B1']} -}; - -declare - %test:assertEquals("correct") -function npt:in-memory-position-and-path() { - {$npt:DATA//c[../preceding-sibling::a[position() eq 1]/b = 'B1']} -}; - -declare - %test:assertEquals("correct") -function npt:in-database-position-and-path() { - {doc("/db/test/test.xml")//c[../preceding-sibling::a[position() eq 1]/b = 'B1']} -}; diff --git a/exist-core/src/test/xquery/positional-nested.xql b/exist-core/src/test/xquery/positional-nested.xql deleted file mode 100644 index 671aab2b9d8..00000000000 --- a/exist-core/src/test/xquery/positional-nested.xql +++ /dev/null @@ -1,157 +0,0 @@ -(: - : eXist-db Open Source Native XML Database - : Copyright (C) 2001 The eXist-db Authors - : - : info@exist-db.org - : http://www.exist-db.org - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public - : License as published by the Free Software Foundation; either - : version 2.1 of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - : Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public - : License along with this library; if not, write to the Free Software - : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - :) -xquery version "3.1"; - -module namespace npt="http://exist-db.org/test/nested-positional-predicate"; - -declare namespace test="http://exist-db.org/xquery/xqsuite"; - -declare variable $npt:TEST_COLLECTION_NAME := "test-positional-nested"; -declare variable $npt:TEST_COLLECTION_URI := "/db/" || $npt:TEST_COLLECTION_NAME; -declare variable $npt:TEST_DOC_NAME := "test.xml"; -declare variable $npt:TEST_DOC_URI := $npt:TEST_COLLECTION_URI || "/" || $npt:TEST_DOC_NAME; - -declare variable $npt:DATA := - document { - - - B1 - - - B2 - correct - - - B3 - wrong - - - }; - -declare - %test:setUp -function npt:setup() { - xmldb:create-collection("/db", $npt:TEST_COLLECTION_NAME), - xmldb:store($npt:TEST_COLLECTION_URI, $npt:TEST_DOC_NAME, $npt:DATA) -}; - -declare - %test:tearDown -function npt:cleanup() { - xmldb:remove($npt:TEST_COLLECTION_URI) -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-1() { - $npt:DATA//c[../preceding-sibling::a] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-2() { - $npt:DATA//c[parent::node()/preceding-sibling::a] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-3() { - $npt:DATA//c/..[preceding-sibling::a]/c -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-4() { - $npt:DATA//c/parent::node()[preceding-sibling::a]/c -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-1() { - doc($npt:TEST_DOC_URI)//c[../preceding-sibling::a] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-2() { - doc($npt:TEST_DOC_URI)//c[parent::node()/preceding-sibling::a] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-3() { - doc($npt:TEST_DOC_URI)//c/..[preceding-sibling::a]/c -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-4() { - doc($npt:TEST_DOC_URI)//c/parent::node()[preceding-sibling::a]/c -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-predicate() { - $npt:DATA//c[../preceding-sibling::a[1]] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-predicate() { - doc($npt:TEST_DOC_URI)//c[../preceding-sibling::a[1]] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-memory-position() { - $npt:DATA//c[../preceding-sibling::a[position() eq 1]] -}; - -declare - %test:assertEquals("correct", "wrong") -function npt:in-database-position() { - doc($npt:TEST_DOC_URI)//c[../preceding-sibling::a[position() eq 1]] -}; - -declare - %test:assertEquals("correct") -function npt:in-memory-predicate-and-path() { - $npt:DATA//c[../preceding-sibling::a[1]/b = 'B1'] -}; - -declare - %test:assertEquals("correct") -function npt:in-database-predicate-and-path() { - doc($npt:TEST_DOC_URI)//c[../preceding-sibling::a[1]/b = 'B1'] -}; - -declare - %test:assertEquals("correct") -function npt:in-memory-position-and-path() { - $npt:DATA//c[../preceding-sibling::a[position() eq 1]/b = 'B1'] -}; - -declare - %test:assertEquals("correct") -function npt:in-database-position-and-path() { - doc($npt:TEST_DOC_URI)//c[../preceding-sibling::a[position() eq 1]/b = 'B1'] -};