mirror of https://github.com/tc39/test262.git
Add tests for Temporal.now.instant (#3031)
This commit is contained in:
parent
ebb6c34fa5
commit
aaf4402b4c
|
@ -0,0 +1,9 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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 is extensible.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert(Object.isExtensible(Temporal.now.instant));
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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.length is 0
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.now.instant, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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.name is "instant".
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Temporal.now.instant.name, 'instant');
|
||||
|
||||
verifyProperty(Temporal.now.instant, 'name', {
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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 does not implement [[Construct]]
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.now.instant), false, 'isConstructor(Temporal.now.instant) must return false');
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.now.instant();
|
||||
}, '`new Temporal.now.instant()` throws TypeError');
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.instant
|
||||
description: The "instant" property of Temporal.now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.now, 'instant', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.instant
|
||||
description: Each invocation of the function produces a distinct object value
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var instant1 = Temporal.now.instant();
|
||||
var instant2 = Temporal.now.instant();
|
||||
|
||||
assert.notSameValue(instant1, instant2);
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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 instance of the Instant constructor
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Temporal.now.instant()),
|
||||
Temporal.Instant.prototype
|
||||
);
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2021 the V8 project authors. 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 describing the current moment in time
|
||||
(as corroborated by `Date.now`)
|
||||
features: [Temporal, BigInt]
|
||||
---*/
|
||||
|
||||
var nowBefore = Date.now();
|
||||
var seconds = Number(Temporal.now.instant().epochNanoseconds / 1000000n);
|
||||
var nowAfter = Date.now();
|
||||
|
||||
assert(seconds >= nowBefore, 'before');
|
||||
assert(seconds <= nowAfter, 'after');
|
Loading…
Reference in New Issue