|
| 1 | +(: |
| 2 | + : eXist-db Open Source Native XML Database |
| 3 | + : Copyright (C) 2001 The eXist-db Authors |
| 4 | + : |
| 5 | + |
| 6 | + : http://www.exist-db.org |
| 7 | + : |
| 8 | + : This library is free software; you can redistribute it and/or |
| 9 | + : modify it under the terms of the GNU Lesser General Public |
| 10 | + : License as published by the Free Software Foundation; either |
| 11 | + : version 2.1 of the License, or (at your option) any later version. |
| 12 | + : |
| 13 | + : This library is distributed in the hope that it will be useful, |
| 14 | + : but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | + : Lesser General Public License for more details. |
| 17 | + : |
| 18 | + : You should have received a copy of the GNU Lesser General Public |
| 19 | + : License along with this library; if not, write to the Free Software |
| 20 | + : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | + :) |
| 22 | +xquery version "3.1"; |
| 23 | + |
| 24 | +module namespace cc="http://exist-db.org/xquery/test/cast-constructor"; |
| 25 | + |
| 26 | +declare namespace test="http://exist-db.org/xquery/xqsuite"; |
| 27 | + |
| 28 | +(:~ |
| 29 | + check if CastExpression#toFunction has correct cardinality check |
| 30 | + see https://github.com/eXist-db/exist/issues/4971 |
| 31 | +:) |
| 32 | +declare |
| 33 | + %test:assertEmpty |
| 34 | +function cc:after-arrow-empty-sequence () { |
| 35 | + () => xs:string() |
| 36 | +}; |
| 37 | + |
| 38 | +declare |
| 39 | + %test:assertEquals("1") |
| 40 | +function cc:after-arrow-integer () { |
| 41 | + 1 => xs:string() |
| 42 | +}; |
| 43 | + |
| 44 | +declare |
| 45 | + %test:assertError("XPTY0004") |
| 46 | +function cc:after-arrow-integer-sequence () { |
| 47 | + (1,2) => xs:string() |
| 48 | +}; |
| 49 | + |
| 50 | +declare |
| 51 | + %test:assertEquals("test") |
| 52 | +function cc:atomize-element () as xs:string { |
| 53 | + xs:string(<div>test</div>) |
| 54 | +}; |
| 55 | + |
| 56 | +declare |
| 57 | + %test:assertEquals("1970-01-01") |
| 58 | +function cc:atomize-attribute () as xs:date { |
| 59 | + xs:date(attribute when { "1970-01-01" }) |
| 60 | +}; |
| 61 | + |
| 62 | +declare |
| 63 | + %test:assertEquals(1) |
| 64 | +function cc:atomize-array () as xs:integer { |
| 65 | + xs:integer([1]) |
| 66 | +}; |
| 67 | + |
| 68 | +declare |
| 69 | + %test:assertError("XPTY0004") |
| 70 | +function cc:atomize-array-2 () as xs:string { |
| 71 | + xs:string([1,2]) |
| 72 | +}; |
| 73 | + |
| 74 | +declare |
| 75 | + %test:assertError("FOTY0013") |
| 76 | +function cc:atomize-map-fails () { |
| 77 | + xs:integer(map { 0 : 1 }) |
| 78 | +}; |
0 commit comments