mirror of https://github.com/tc39/test262.git
Temporal: Move tests out of staging/Temporal/Duration/old and into test/built-ins
This commit is contained in:
parent
3f0a24f4f6
commit
b8c29a05b5
|
@ -0,0 +1,13 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.duration.compare
|
||||
description: Temporal.Duration.compare() does not lose precision when totaling everything down to nanoseconds.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const days200 = new Temporal.Duration(0, 0, 0, 200);
|
||||
const days200oneNanosecond = new Temporal.Duration(0, 0, 0, 200, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
assert.notSameValue(Temporal.Duration.compare(days200, days200oneNanosecond), 0);
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.duration.from
|
||||
description: Minimum value is zero.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const units = [
|
||||
"years",
|
||||
"months",
|
||||
"weeks",
|
||||
"days",
|
||||
"hours",
|
||||
"minutes",
|
||||
"seconds",
|
||||
"milliseconds",
|
||||
"microseconds",
|
||||
"nanoseconds"
|
||||
];
|
||||
|
||||
units.forEach(unit => TemporalHelpers.assertDuration(Temporal.Duration.from({ [unit]: 0 }),
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||
|
||||
[
|
||||
"P0Y",
|
||||
"P0M",
|
||||
"P0W",
|
||||
"P0D",
|
||||
"PT0H",
|
||||
"PT0M",
|
||||
"PT0S"
|
||||
].forEach(str => TemporalHelpers.assertDuration(Temporal.Duration.from(str),
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [temporalHelpers.js]
|
||||
esid: sec-temporal.duration
|
||||
description: Minimum value is zero.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.assertDuration(new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.duration.prototype.tostring
|
||||
description: Serializing balance doesn't lose precision when values are precise.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0,
|
||||
Number.MAX_SAFE_INTEGER,
|
||||
Number.MAX_SAFE_INTEGER, 0);
|
||||
|
||||
assert.sameValue(d.toString(), "PT9016206453995.731991S");
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal-duration-objects
|
||||
description: Temporal.Duration.compare() does not lose precision when totaling everything down to nanoseconds
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.notSameValue(Temporal.Duration.compare({ days: 200 }, {
|
||||
days: 200,
|
||||
nanoseconds: 1
|
||||
}), 0);
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal-duration-objects
|
||||
description: min/max values
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var units = [
|
||||
"years",
|
||||
"months",
|
||||
"weeks",
|
||||
"days",
|
||||
"hours",
|
||||
"minutes",
|
||||
"seconds",
|
||||
"milliseconds",
|
||||
"microseconds",
|
||||
"nanoseconds"
|
||||
];
|
||||
|
||||
// minimum is zero
|
||||
assert.sameValue(`${ new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0) }`, "PT0S");
|
||||
units.forEach(unit => assert.sameValue(`${ Temporal.Duration.from({ [unit]: 0 }) }`, "PT0S"));
|
||||
[
|
||||
"P0Y",
|
||||
"P0M",
|
||||
"P0W",
|
||||
"P0D",
|
||||
"PT0H",
|
||||
"PT0M",
|
||||
"PT0S"
|
||||
].forEach(str => assert.sameValue(`${ Temporal.Duration.from(str) }`, "PT0S"));
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal-duration-objects
|
||||
description: toString() works as expected
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// serializing balance doesn't lose precision when values are precise
|
||||
var d = Temporal.Duration.from({
|
||||
milliseconds: Number.MAX_SAFE_INTEGER,
|
||||
microseconds: Number.MAX_SAFE_INTEGER
|
||||
});
|
||||
assert.sameValue(`${ d }`, "PT9016206453995.731991S");
|
Loading…
Reference in New Issue