-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Temporal.now.instant (#3031)
- Loading branch information
1 parent
ebb6c34
commit aaf4402
Showing
8 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/built-ins/Temporal/now/instant/return-value-distinct.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
12 changes: 12 additions & 0 deletions
12
test/built-ins/Temporal/now/instant/return-value-prototype.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |