Skip to content

Commit 45e25d2

Browse files
joewizclaude
andcommitted
[test] Add XQSuite tests demonstrating fn:dateTime-record record syntax
Per dizzzz's review on PR #6210: a query-based test demonstrating the XQuery 4.0 record type system at the language level (in addition to the existing JUnit tests in RecordTypeTest). Covers fn:dateTime-record built-in invocation, lookup-operator (?) field access, integer typing of returned fields, map(*) compatibility, and the date-plus-time arity overloads. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 5bdda68 commit 45e25d2

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
(:~
25+
: XQSuite tests for the XQuery 4.0 fn:dateTime-record built-in.
26+
:
27+
: See https://www.w3.org/TR/xquery-functions-40/#func-dateTime-record
28+
:
29+
: The record itself is a map whose keys (year, month, day, hours,
30+
: minutes, seconds, timezone) are accessed with the lookup operator.
31+
: This module exercises the function from XQuery code so that the
32+
: record-type integration is covered by an XQSuite test, in addition
33+
: to the existing JUnit tests in RecordTypeTest.
34+
:)
35+
module namespace rt = "http://exist-db.org/xquery/test/record-types";
36+
37+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
38+
39+
declare
40+
%test:assertEquals(2026)
41+
function rt:dateTime-record-year() {
42+
fn:dateTime-record(2026, 4, 27)?year
43+
};
44+
45+
declare
46+
%test:assertEquals(4)
47+
function rt:dateTime-record-month() {
48+
fn:dateTime-record(2026, 4, 27)?month
49+
};
50+
51+
declare
52+
%test:assertEquals(27)
53+
function rt:dateTime-record-day() {
54+
fn:dateTime-record(2026, 4, 27)?day
55+
};
56+
57+
declare
58+
%test:assertEquals(2026, 4, 27)
59+
function rt:dateTime-record-multiple-fields() {
60+
let $dt := fn:dateTime-record(2026, 4, 27)
61+
return ($dt?year, $dt?month, $dt?day)
62+
};
63+
64+
declare
65+
%test:assertTrue
66+
function rt:dateTime-record-fields-are-integers() {
67+
let $dt := fn:dateTime-record(2026, 4, 27)
68+
return $dt?year instance of xs:integer
69+
and $dt?month instance of xs:integer
70+
and $dt?day instance of xs:integer
71+
};
72+
73+
declare
74+
%test:assertTrue
75+
function rt:dateTime-record-is-map() {
76+
fn:dateTime-record(2026, 4, 27) instance of map(*)
77+
};
78+
79+
declare
80+
%test:assertEquals(12)
81+
function rt:dateTime-record-with-time() {
82+
fn:dateTime-record(2026, 4, 27, 12, 30, 0)?hours
83+
};
84+
85+
declare
86+
%test:assertEquals(30)
87+
function rt:dateTime-record-with-time-minutes() {
88+
fn:dateTime-record(2026, 4, 27, 12, 30, 0)?minutes
89+
};

0 commit comments

Comments
 (0)