-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some basic functionality tests for Instant
- Loading branch information
Showing
14 changed files
with
198 additions
and
128 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
polyfill/test/Instant/constructor/fromEpochMicroseconds/basic.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,14 @@ | ||
// 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.instant.fromepochmicroseconds | ||
description: Basic tests for Instant.fromEpochMicroseconds(). | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = Temporal.Instant.fromEpochMicroseconds(217175010_123_456n); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_000n, "fromEpochMicroseconds post epoch"); | ||
|
||
const beforeEpoch = Temporal.Instant.fromEpochMicroseconds(-217175010_876_543n); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_000n, "fromEpochMicroseconds pre epoch"); |
14 changes: 14 additions & 0 deletions
14
polyfill/test/Instant/constructor/fromEpochMilliseconds/basic.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,14 @@ | ||
// 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.instant.fromepochmilliseconds | ||
description: Basic tests for Instant.fromEpochMilliseconds(). | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = Temporal.Instant.fromEpochMilliseconds(217175010_123); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_000_000n, "fromEpochMilliseconds post epoch"); | ||
|
||
const beforeEpoch = Temporal.Instant.fromEpochMilliseconds(-217175010_876); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_000_000n, "fromEpochMilliseconds pre epoch"); |
14 changes: 14 additions & 0 deletions
14
polyfill/test/Instant/constructor/fromEpochNanoseconds/basic.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,14 @@ | ||
// 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.instant.fromepochnanoseconds | ||
description: Basic tests for Instant.fromEpochNanoseconds(). | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = Temporal.Instant.fromEpochNanoseconds(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_789n, "fromEpochNanoseconds post epoch"); | ||
|
||
const beforeEpoch = Temporal.Instant.fromEpochNanoseconds(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_211n, "fromEpochNanoseconds pre epoch"); |
14 changes: 14 additions & 0 deletions
14
polyfill/test/Instant/constructor/fromEpochSeconds/basic.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,14 @@ | ||
// 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.instant.fromepochseconds | ||
description: Basic tests for Instant.fromEpochSeconds(). | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = Temporal.Instant.fromEpochSeconds(217175010); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_000_000_000n, "fromEpochSeconds post epoch"); | ||
|
||
const beforeEpoch = Temporal.Instant.fromEpochSeconds(-217175010); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_000_000_000n, "fromEpochSeconds pre epoch"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/Instant/prototype/epochMicroseconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.instant.prototype.epochmicroseconds | ||
description: Basic tests for epochMicroseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); | ||
|
||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_543n, "epochMicroseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/Instant/prototype/epochMilliseconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.instant.prototype.epochmilliseconds | ||
description: Basic tests for epochMilliseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.epochMilliseconds, 217175010_123, "epochMilliseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochMilliseconds, "number", "epochMilliseconds value is a number"); | ||
|
||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.epochMilliseconds, -217175010_876, "epochMilliseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochMilliseconds, "number", "epochMilliseconds value is a number"); |
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 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.instant.prototype.epochnanoseconds | ||
description: Basic tests for epochNanoseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_789n, "epochNanoseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochNanoseconds, "bigint", "epochNanoseconds value is a bigint"); | ||
|
||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_211n, "epochNanoseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochNanoseconds, "bigint", "epochNanoseconds value is a bigint"); |
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 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.instant.prototype.epochseconds | ||
description: Basic tests for epochSeconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number"); | ||
|
||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.epochSeconds, -217175010, "epochSeconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number"); |
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 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.instant.prototype.tostring | ||
description: Basic tests for toString(). | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n); | ||
assert.sameValue(afterEpoch.toString(), "1976-11-18T14:23:30.123456789Z", "basic toString() after epoch"); | ||
|
||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); | ||
assert.sameValue(beforeEpoch.toString(), "1963-02-13T09:36:29.123456789Z", "basic toString() before epoch"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/ZonedDateTime/prototype/epochMicroseconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.zoneddatetime.prototype.epochmicroseconds | ||
description: Basic tests for epochMicroseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); | ||
assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); | ||
|
||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); | ||
assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_543n, "epochMicroseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/ZonedDateTime/prototype/epochMilliseconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.zoneddatetime.prototype.epochmilliseconds | ||
description: Basic tests for epochMilliseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); | ||
assert.sameValue(afterEpoch.epochMilliseconds, 217175010_123, "epochMilliseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochMilliseconds, "number", "epochMilliseconds value is a number"); | ||
|
||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); | ||
assert.sameValue(beforeEpoch.epochMilliseconds, -217175010_876, "epochMilliseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochMilliseconds, "number", "epochMilliseconds value is a number"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/ZonedDateTime/prototype/epochNanoseconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.zoneddatetime.prototype.epochnanoseconds | ||
description: Basic tests for epochNanoseconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); | ||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_789n, "epochNanoseconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochNanoseconds, "bigint", "epochNanoseconds value is a bigint"); | ||
|
||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); | ||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_211n, "epochNanoseconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochNanoseconds, "bigint", "epochNanoseconds value is a bigint"); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/ZonedDateTime/prototype/epochSeconds/basic.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,16 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-get-temporal.zoneddatetime.prototype.epochseconds | ||
description: Basic tests for epochSeconds. | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); | ||
assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch"); | ||
assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number"); | ||
|
||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); | ||
assert.sameValue(beforeEpoch.epochSeconds, -217175010, "epochSeconds pre epoch"); | ||
assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number"); |
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