mirror of https://github.com/tc39/test262.git
Temporal: Tests for week-numbering algorithm
This commit is contained in:
parent
c0e8eef81b
commit
ae8fe25b5a
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[null, TypeError],
|
||||
[false, TypeError],
|
||||
[Infinity, RangeError],
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[Infinity, RangeError],
|
||||
[-Infinity, RangeError],
|
||||
[Symbol("foo"), TypeError],
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[null, TypeError],
|
||||
[false, TypeError],
|
||||
[Infinity, RangeError],
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[Infinity, RangeError],
|
||||
[-Infinity, RangeError],
|
||||
[Symbol("foo"), TypeError],
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[null, TypeError],
|
||||
[false, TypeError],
|
||||
[Infinity, RangeError],
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const badResults = [
|
||||
[undefined, TypeError],
|
||||
[Infinity, RangeError],
|
||||
[-Infinity, RangeError],
|
||||
[Symbol("foo"), TypeError],
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.Calendar.prototype.weekOfYear returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = { month: 1, day: 1, year: 2024, calendar};
|
||||
|
||||
assert.sameValue(calendar.weekOfYear({...date}), 1);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = { month: 1, day: 1, year: 2024, calendar};
|
||||
|
||||
assert.sameValue(calendar.weekOfYear({...nonisodate}), undefined);
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.Calendar.prototype.yearOfWeek returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = { month: 1, day: 1, year: 2024, calendar};
|
||||
|
||||
assert.sameValue(calendar.yearOfWeek({...date}), 2024);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = { month: 1, day: 1, year: 2024, calendar};
|
||||
|
||||
assert.sameValue(calendar.yearOfWeek({...nonisodate}), undefined);
|
22
test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
22
test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.PlainDate.prototype.weekOfYear returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
22
test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
22
test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.PlainDate.prototype.yearOfWeek returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
22
test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
22
test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
22
test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
22
test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
24
test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
24
test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
|
||||
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
24
test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
24
test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all
|
||||
non-ISO calendars without a well-defined week numbering system.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// Gregorian calendar has a well defined week-numbering system.
|
||||
|
||||
let calendar = new Temporal.Calendar("gregory");
|
||||
|
||||
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = new Temporal.Calendar("hebrew");
|
||||
const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
Loading…
Reference in New Issue