Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation-invalid-key.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.instant.compare
7 description: Annotation keys are lowercase-only
8 features: [Temporal]
9 ---*/
10
11 const epoch = new Temporal.Instant(0n);
12
13 const invalidStrings = [
14 ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"],
15 ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"],
16 ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"],
17 ];
18
19 invalidStrings.forEach(([arg, descr]) => {
20 assert.throws(
21 RangeError,
22 () => Temporal.Instant.compare(arg, epoch),
23 `annotation keys must be lowercase: ${arg} - ${descr} (first argument)`
24 );
25 assert.throws(
26 RangeError,
27 () => Temporal.Instant.compare(epoch, arg),
28 `annotation keys must be lowercase: ${arg} - ${descr} (second argument)`
29 );
30 });
31
32 reportCompare(0, 0);