1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-temporal.plaindate.prototype.weekofyear
description: Validate result returned from calendar weekOfYear() method
features: [Temporal]
---*/
const badResults = [
[null, TypeError],
[false, TypeError],
[Infinity, RangeError],
[-Infinity, RangeError],
[NaN, RangeError],
[-7, RangeError],
[-0.1, RangeError],
["string", TypeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[{}, TypeError],
[true, TypeError],
[7.1, RangeError],
["7", TypeError],
["7.5", TypeError],
[{valueOf() { return 7; }}, TypeError],
];
badResults.forEach(([result, error]) => {
const calendar = new class extends Temporal.Calendar {
weekOfYear() {
return result;
}
}("iso8601");
const instance = new Temporal.PlainDate(1981, 12, 15, calendar);
assert.throws(error, () => instance.weekOfYear, `${typeof result} ${String(result)} not converted to positive integer`);
});
reportCompare(0, 0);
|