mirror of https://github.com/tc39/test262.git
Test Temporal.Now.
This commit is contained in:
parent
4eb14032ae
commit
d86b913c11
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now
|
||||
description: Tests that Temporal.Now meets the requirements for built-in objects
|
||||
info: |
|
||||
Unless specified otherwise, a built-in object that is callable as a function is a built-in
|
||||
function object with the characteristics described in 10.3. Unless specified otherwise, the
|
||||
[[Extensible]] internal slot of a built-in object initially has the value true.
|
||||
|
||||
Unless otherwise specified every built-in function and every built-in constructor has the
|
||||
Function prototype object [...] as the value of its [[Prototype]] internal slot.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Temporal.Now),
|
||||
true, "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Temporal.Now),
|
||||
"[object Temporal.Now]", "Object.prototype.toString");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Temporal.Now),
|
||||
Object.prototype, "prototype");
|
||||
|
||||
assert.sameValue(Temporal.Now.prototype,
|
||||
undefined, "prototype property");
|
|
@ -7,6 +7,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.instant, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'instant', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.instant
|
||||
description: Temporal.Now.instant returns an Instant
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instant = Temporal.Now.instant();
|
||||
assert(instant instanceof Temporal.Instant);
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindate
|
||||
description: Throws when the calendar argument is undefined
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate(), "implicit");
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate(undefined), "implicit");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindate
|
||||
description: The "plainDate" property of Temporal.Now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.plainDate, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, "plainDate", {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindateiso
|
||||
description: The "plainDateISO" property of Temporal.Now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.plainDateISO, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, "plainDateISO", {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindateiso
|
||||
description: Functions when time zone argument is omitted
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const d = Temporal.Now.plainDateISO();
|
||||
assert(d instanceof Temporal.PlainDate);
|
||||
assert.sameValue(d.calendar.id, "iso8601");
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindatetime
|
||||
description: Throws when the calendar argument is undefined
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime(), "implicit");
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime(undefined), "implicit");
|
|
@ -7,6 +7,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.plainDateTime, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'plainDateTime', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -7,6 +7,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.plainDateTimeISO, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'plainDateTimeISO', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindatetimeiso
|
||||
description: Temporal.Now.plainDateTimeISO is extensible.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const result = Temporal.Now.plainDateTimeISO();
|
||||
assert(result.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(result.calendar.id, "iso8601");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaintimeiso
|
||||
description: The "plainTimeISO" property of Temporal.Now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.plainTimeISO, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, "plainTimeISO", {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaintimeiso
|
||||
description: Functions when time zone argument is omitted
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const t = Temporal.Now.plainTimeISO();
|
||||
assert(t instanceof Temporal.PlainTime);
|
||||
assert.sameValue(t.calendar.id, "iso8601");
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now
|
||||
description: The "Now" property of Temporal
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Temporal.Now,
|
||||
"object",
|
||||
"`typeof Now` is `object`"
|
||||
);
|
||||
|
||||
verifyProperty(Temporal, "Now", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -12,6 +12,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.timeZone, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'timeZone', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Throws when the calendar argument is undefined
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime(), "implicit");
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime(undefined), "implicit");
|
|
@ -7,6 +7,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.zonedDateTime, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'zonedDateTime', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -7,6 +7,8 @@ includes: [propertyHelper.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Temporal.Now.zonedDateTimeISO, "function", "typeof is function");
|
||||
|
||||
verifyProperty(Temporal.Now, 'zonedDateTimeISO', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Functions when time zone argument is omitted
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.Now.zonedDateTimeISO();
|
||||
const tz = Temporal.Now.timeZone();
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(zdt.calendar.id, "iso8601");
|
||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||
assert.sameValue(zdt.timeZone.id, tz.id);
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindate
|
||||
description: String calendar argument
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const date = Temporal.Now.plainDate("gregory");
|
||||
assert(date instanceof Temporal.PlainDate);
|
||||
assert.sameValue(date.calendar.id, "gregory");
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.plaindatetime
|
||||
description: String calendar argument
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const dt = Temporal.Now.plainDateTime("gregory");
|
||||
assert(dt instanceof Temporal.PlainDateTime);
|
||||
assert.sameValue(dt.calendar.id, "gregory");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: String calendar argument
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.Now.zonedDateTime("gregory");
|
||||
const tz = Temporal.Now.timeZone();
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(zdt.calendar.id, "gregory");
|
||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||
assert.sameValue(zdt.timeZone.id, tz.id);
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: String calendar and time zone arguments
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.Now.zonedDateTime("gregory", "America/Los_Angeles");
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(zdt.calendar.id, "gregory");
|
||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||
assert.sameValue(zdt.timeZone.id, "America/Los_Angeles");
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: String calendar argument
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.Now.zonedDateTimeISO("America/Los_Angeles");
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(zdt.calendar.id, "iso8601");
|
||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||
assert.sameValue(zdt.timeZone.id, "America/Los_Angeles");
|
Loading…
Reference in New Issue