mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Temporal: Move ZonedDateTime order-of-operations tests out of staging
This commit is contained in:
parent
bf46ed66b6
commit
0f6b269400
31
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-constrain.js
vendored
Normal file
31
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-constrain.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / constrain.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const breakoutUnits = (op, zdt, d, options) => zdt[op]({ years: d.years }, options)[op]({ months: d.months }, options)[op]({ weeks: d.weeks }, options)[op]({ days: d.days }, options)[op]({
|
||||||
|
hours: d.hours,
|
||||||
|
minutes: d.minutes,
|
||||||
|
seconds: d.seconds,
|
||||||
|
milliseconds: d.milliseconds,
|
||||||
|
microseconds: d.microseconds,
|
||||||
|
nanoseconds: d.nanoseconds
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1580457600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
// "2020-03-01T00:00:00-08:00[-08:00]"
|
||||||
|
const expected = new Temporal.ZonedDateTime(1583049600000000000n, "-08:00");
|
||||||
|
|
||||||
|
const options = { overflow: "constrain" };
|
||||||
|
const result = zdt.add(d, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(result, expected);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(breakoutUnits("add", zdt, d, options), result);
|
||||||
|
|
32
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-none.js
vendored
Normal file
32
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-none.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / none.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const breakoutUnits = (op, zdt, d, options) => zdt[op]({ years: d.years }, options)[op]({ months: d.months }, options)[op]({ weeks: d.weeks }, options)[op]({ days: d.days }, options)[op]({
|
||||||
|
hours: d.hours,
|
||||||
|
minutes: d.minutes,
|
||||||
|
seconds: d.seconds,
|
||||||
|
milliseconds: d.milliseconds,
|
||||||
|
microseconds: d.microseconds,
|
||||||
|
nanoseconds: d.nanoseconds
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1580457600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
// "2020-03-01T00:00:00-08:00[-08:00]"
|
||||||
|
const expected = new Temporal.ZonedDateTime(1583049600000000000n, "-08:00");
|
||||||
|
|
||||||
|
const options = undefined;
|
||||||
|
const result = zdt.add(d, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(result, expected);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(breakoutUnits("add", zdt, d, options),
|
||||||
|
result);
|
||||||
|
|
16
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-reject.js
vendored
Normal file
16
test/built-ins/Temporal/ZonedDateTime/prototype/add/math-order-of-operations-add-reject.js
vendored
Normal file
@ -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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / reject.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1580457600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
assert.throws(RangeError, () => zdt.add(d, options));
|
@ -0,0 +1,31 @@
|
|||||||
|
// 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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / reject.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const breakoutUnits = (op, zdt, d, options) => zdt[op]({ years: d.years }, options)[op]({ months: d.months }, options)[op]({ weeks: d.weeks }, options)[op]({ days: d.days }, options)[op]({
|
||||||
|
hours: d.hours,
|
||||||
|
minutes: d.minutes,
|
||||||
|
seconds: d.seconds,
|
||||||
|
milliseconds: d.milliseconds,
|
||||||
|
microseconds: d.microseconds,
|
||||||
|
nanoseconds: d.nanoseconds
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1585641600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
const options = { overflow: "constrain" };
|
||||||
|
// "2020-02-28T00:00:00-08:00[-08:00]"
|
||||||
|
const expected = new Temporal.ZonedDateTime(1582876800000000000n, "-08:00");
|
||||||
|
|
||||||
|
const result = zdt.subtract(d, options);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(result, expected);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(breakoutUnits("subtract", zdt, d, options),
|
||||||
|
result);
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
// 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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / reject.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const breakoutUnits = (op, zdt, d, options) => zdt[op]({ years: d.years }, options)[op]({ months: d.months }, options)[op]({ weeks: d.weeks }, options)[op]({ days: d.days }, options)[op]({
|
||||||
|
hours: d.hours,
|
||||||
|
minutes: d.minutes,
|
||||||
|
seconds: d.seconds,
|
||||||
|
milliseconds: d.milliseconds,
|
||||||
|
microseconds: d.microseconds,
|
||||||
|
nanoseconds: d.nanoseconds
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1585641600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
const options = undefined;
|
||||||
|
// "2020-02-28T00:00:00-08:00[-08:00]"
|
||||||
|
const expected = new Temporal.ZonedDateTime(1582876800000000000n, "-08:00");
|
||||||
|
|
||||||
|
const result = zdt.subtract(d, options);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(result, expected);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(breakoutUnits("subtract", zdt, d, options),
|
||||||
|
result);
|
||||||
|
|
@ -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.zoneddatetime.prototype.add
|
||||||
|
description: Math order of operations - add / reject.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// const zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
||||||
|
const zdt = new Temporal.ZonedDateTime(1585641600000000000n, "-08:00");
|
||||||
|
const d = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
assert.throws(RangeError, () => zdt.subtract(d, options));
|
@ -1,79 +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-zoneddatetime-objects
|
|
||||||
description: math order of operations and options
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var breakoutUnits = (op, zdt, d, options) => zdt[op]({ years: d.years }, options)[op]({ months: d.months }, options)[op]({ weeks: d.weeks }, options)[op]({ days: d.days }, options)[op]({
|
|
||||||
hours: d.hours,
|
|
||||||
minutes: d.minutes,
|
|
||||||
seconds: d.seconds,
|
|
||||||
milliseconds: d.milliseconds,
|
|
||||||
microseconds: d.microseconds,
|
|
||||||
nanoseconds: d.nanoseconds
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
// order of operations: add / none
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = undefined;
|
|
||||||
var result = zdt.add(d, options);
|
|
||||||
assert.sameValue(result.toString(), "2020-03-01T00:00:00-08:00[-08:00]");
|
|
||||||
assert.sameValue(breakoutUnits("add", zdt, d, options).toString(), result.toString());
|
|
||||||
|
|
||||||
// order of operations: add / constrain
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = { overflow: "constrain" };
|
|
||||||
var result = zdt.add(d, options);
|
|
||||||
assert.sameValue(result.toString(), "2020-03-01T00:00:00-08:00[-08:00]");
|
|
||||||
assert.sameValue(breakoutUnits("add", zdt, d, options).toString(), result.toString());
|
|
||||||
|
|
||||||
// order of operations: add / reject
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-01-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = { overflow: "reject" };
|
|
||||||
assert.throws(RangeError, () => zdt.add(d, options));
|
|
||||||
|
|
||||||
// order of operations: subtract / none
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = undefined;
|
|
||||||
var result = zdt.subtract(d, options);
|
|
||||||
assert.sameValue(result.toString(), "2020-02-28T00:00:00-08:00[-08:00]");
|
|
||||||
assert.sameValue(breakoutUnits("subtract", zdt, d, options).toString(), result.toString());
|
|
||||||
|
|
||||||
// order of operations: subtract / constrain
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = { overflow: "constrain" };
|
|
||||||
var result = zdt.subtract(d, options);
|
|
||||||
assert.sameValue(result.toString(), "2020-02-28T00:00:00-08:00[-08:00]");
|
|
||||||
assert.sameValue(breakoutUnits("subtract", zdt, d, options).toString(), result.toString());
|
|
||||||
|
|
||||||
// order of operations: subtract / reject
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2020-03-31T00:00-08:00[-08:00]");
|
|
||||||
var d = Temporal.Duration.from({
|
|
||||||
months: 1,
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
var options = { overflow: "reject" };
|
|
||||||
assert.throws(RangeError, () => zdt.subtract(d, options));
|
|
Loading…
x
Reference in New Issue
Block a user