mirror of https://github.com/tc39/test262.git
Add tests for Temporal.Now.plainDateTimeISO
This commit is contained in:
parent
7c3d29686b
commit
0232d97415
|
@ -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.plaindatetimeiso
|
||||||
|
description: Temporal.Now.plainDateTimeISO is extensible.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert(
|
||||||
|
Object.isExtensible(Temporal.Now.plainDateTimeISO),
|
||||||
|
'Object.isExtensible(Temporal.Now.plainDateTimeISO) must return true'
|
||||||
|
);
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.now.plaindatetimeiso
|
||||||
|
description: The `length` property of Temporal.Now.plainDateTimeISO
|
||||||
|
info: |
|
||||||
|
Every built-in function object, including constructors, has a "length" property whose value is
|
||||||
|
an integer. Unless otherwise specified, this value is equal to the largest number of named
|
||||||
|
arguments shown in the subclause headings for the function description. Optional parameters
|
||||||
|
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
|
||||||
|
«...name») are not included in the default argument count.
|
||||||
|
|
||||||
|
Unless otherwise specified, the "length" property of a built-in function object has the
|
||||||
|
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyProperty(Temporal.Now.plainDateTimeISO, "length", {
|
||||||
|
value: 0,
|
||||||
|
writable: false,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
});
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 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.plainDateTimeISO
|
||||||
|
description: Temporal.Now.plainDateTimeISO.name is "plainDateTimeISO".
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Now.plainDateTimeISO.name,
|
||||||
|
'plainDateTimeISO',
|
||||||
|
'The value of Temporal.Now.plainDateTimeISO.name is expected to be "plainDateTimeISO"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyProperty(Temporal.Now.plainDateTimeISO, '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.plaindatetimeiso
|
||||||
|
description: Temporal.Now.plainDateTimeISO does not implement [[Construct]]
|
||||||
|
includes: [isConstructor.js]
|
||||||
|
features: [Reflect.construct, Temporal, arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(isConstructor(Temporal.Now.plainDateTimeISO), false, 'isConstructor(Temporal.Now.plainDateTimeISO) must return false');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
new Temporal.Now.plainDateTimeISO();
|
||||||
|
}, 'new Temporal.Now.plainDateTimeISO() throws a TypeError exception');
|
|
@ -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.plaindatetimeiso
|
||||||
|
description: The "plainDateTimeISO" property of Temporal.Now
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyProperty(Temporal.Now, 'plainDateTimeISO', {
|
||||||
|
enumerable: false,
|
||||||
|
writable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.now.plaindatetimeiso
|
||||||
|
description: Return value describes the start of a day
|
||||||
|
features: [BigInt, Temporal]
|
||||||
|
---*/
|
||||||
|
const timeZone = {
|
||||||
|
getOffsetNanosecondsFor(instant) {
|
||||||
|
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
|
||||||
|
for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) {
|
||||||
|
assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0');
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
// 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.now.plaindatetimeiso
|
||||||
|
description: Functions when time zone argument is omitted
|
||||||
|
includes: [compareArray.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
Object.defineProperty(Temporal.TimeZone, "from", {
|
||||||
|
get() {
|
||||||
|
actual.push("get Temporal.TimeZone.from");
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const resultExplicit = Temporal.Now.plainDateTimeISO(undefined);
|
||||||
|
assert(
|
||||||
|
resultExplicit instanceof Temporal.PlainDateTime,
|
||||||
|
'The result of evaluating (resultExplicit instanceof Temporal.PlainDateTime) is expected to be true'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
||||||
|
|
||||||
|
const resultImplicit = Temporal.Now.plainDateTimeISO();
|
||||||
|
assert(
|
||||||
|
resultImplicit instanceof Temporal.PlainDateTime,
|
||||||
|
'The result of evaluating (resultImplicit instanceof Temporal.PlainDateTime) is expected to be true'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
|
@ -0,0 +1,28 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Correctly invokes `getOffsetNanosecondsFor` method of TimeZone-like objects
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var calls = [];
|
||||||
|
var timeZone = {
|
||||||
|
getOffsetNanosecondsFor: function() {
|
||||||
|
calls.push({
|
||||||
|
args: arguments,
|
||||||
|
this: this
|
||||||
|
});
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
|
||||||
|
assert.sameValue(calls.length, 1, 'The value of calls.length is expected to be 1');
|
||||||
|
assert.sameValue(calls[0].args.length, 1, 'The value of calls[0].args.length is expected to be 1');
|
||||||
|
assert(
|
||||||
|
calls[0].args[0] instanceof Temporal.Instant,
|
||||||
|
'The result of evaluating (calls[0].args[0] instanceof Temporal.Instant) is expected to be true'
|
||||||
|
);
|
||||||
|
assert.sameValue(calls[0].this, timeZone, 'The value of calls[0].this is expected to equal the value of timeZone');
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 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.now.plaindatetimeiso
|
||||||
|
description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds
|
||||||
|
features: [Temporal, arrow-function]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
[3600000000000.5, NaN].forEach(wrongOffset => {
|
||||||
|
const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
RangeError,
|
||||||
|
() => Temporal.Now.plainDateTimeISO(timeZone),
|
||||||
|
'Temporal.Now.plainDateTimeISO(timeZone) throws a RangeError exception'
|
||||||
|
);
|
||||||
|
});
|
|
@ -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.plaindatetimeiso
|
||||||
|
description: Rejects when `getOffsetNanosecondsFor` property is not a method
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
getOffsetNanosecondsFor: 7
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception');
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.now.plaindatetimeiso
|
||||||
|
description: Rejects non-numeric nanosecond values reported by TimeZone-like object
|
||||||
|
features: [BigInt, Symbol, Temporal, arrow-function]
|
||||||
|
---*/
|
||||||
|
const invalidValues = [
|
||||||
|
undefined,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
'2020-01-01T12:45:36',
|
||||||
|
Symbol(),
|
||||||
|
2n,
|
||||||
|
{},
|
||||||
|
Temporal.PlainDateTime,
|
||||||
|
Temporal.PlainDateTime.prototype
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const dateTime of invalidValues) {
|
||||||
|
let callCount = 0;
|
||||||
|
|
||||||
|
const timeZone = {
|
||||||
|
getOffsetNanosecondsFor(instant, calendar) {
|
||||||
|
callCount += 1;
|
||||||
|
return dateTime;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
TypeError,
|
||||||
|
() => Temporal.Now.plainDateTimeISO(timeZone),
|
||||||
|
'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1');
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 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.now.plaindatetimeiso
|
||||||
|
description: RangeError thrown if time zone reports an offset that is out of range
|
||||||
|
features: [Temporal, arrow-function]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
[-86400000000001, 86400000000001, -Infinity, Infinity].forEach(wrongOffset => {
|
||||||
|
const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
RangeError,
|
||||||
|
() => Temporal.Now.plainDateTimeISO(timeZone),
|
||||||
|
'Temporal.Now.plainDateTimeISO(timeZone) throws a RangeError exception'
|
||||||
|
);
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error when accessing `getOffsetNanosecondsFor` property throws
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
get getOffsetNanosecondsFor() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error when `getOffsetNanosecondsFor` throws
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
getOffsetNanosecondsFor() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,21 @@
|
||||||
|
// 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.now.plaindatetimeiso
|
||||||
|
description: TypeError thrown if time zone reports an offset that is not a Number
|
||||||
|
features: [BigInt, Symbol, Temporal, arrow-function]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
[undefined, null, true, '+01:00', Symbol(), 3600000000000n, {}, {
|
||||||
|
valueOf() {
|
||||||
|
return 3600000000000;
|
||||||
|
}
|
||||||
|
}].forEach(wrongOffset => {
|
||||||
|
const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
TypeError,
|
||||||
|
() => Temporal.Now.plainDateTimeISO(timeZone),
|
||||||
|
'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception'
|
||||||
|
);
|
||||||
|
});
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error thrown by invoking "toString" property
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
timeZone: {
|
||||||
|
timeZone: true,
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error thrown by retrieving value of "timeZone" property
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
get timeZone() {
|
||||||
|
throw new Test262Error();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,21 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error thrown by checking presence of nested "timeZone" property
|
||||||
|
features: [Proxy, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = {
|
||||||
|
timeZone: new Proxy({}, {
|
||||||
|
has: function(target, property) {
|
||||||
|
if (property === 'timeZone') {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,19 @@
|
||||||
|
// 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.plaindatetimeiso
|
||||||
|
description: Forwards error thrown by checking presence of "timeZone" property
|
||||||
|
features: [Proxy, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var timeZone = new Proxy({}, {
|
||||||
|
has: function(target, property) {
|
||||||
|
if (property === 'timeZone') {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.now.plaindatetimeiso
|
||||||
|
description: Observable interactions with the provided timezone-like object
|
||||||
|
includes: [compareArray.js]
|
||||||
|
features: [BigInt, Proxy, Temporal]
|
||||||
|
---*/
|
||||||
|
const actual = [];
|
||||||
|
|
||||||
|
const expected = [
|
||||||
|
'has timeZone.timeZone',
|
||||||
|
'get timeZone.timeZone',
|
||||||
|
'has nestedTimeZone.timeZone',
|
||||||
|
'get nestedTimeZone.getOffsetNanosecondsFor',
|
||||||
|
'call nestedTimeZone.getOffsetNanosecondsFor'
|
||||||
|
];
|
||||||
|
|
||||||
|
const nestedTimeZone = new Proxy({
|
||||||
|
getOffsetNanosecondsFor(instant) {
|
||||||
|
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
instant instanceof Temporal.Instant,
|
||||||
|
true,
|
||||||
|
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||||
|
);
|
||||||
|
|
||||||
|
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
has(target, property) {
|
||||||
|
actual.push(`has nestedTimeZone.${String(property)}`);
|
||||||
|
return property in target;
|
||||||
|
},
|
||||||
|
|
||||||
|
get(target, property) {
|
||||||
|
actual.push(`get nestedTimeZone.${String(property)}`);
|
||||||
|
return target[property];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeZone = new Proxy({
|
||||||
|
timeZone: nestedTimeZone,
|
||||||
|
|
||||||
|
getOffsetNanosecondsFor(instant) {
|
||||||
|
actual.push('call timeZone.getOffsetNanosecondsFor');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
instant instanceof Temporal.Instant,
|
||||||
|
true,
|
||||||
|
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||||
|
);
|
||||||
|
|
||||||
|
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
has(target, property) {
|
||||||
|
actual.push(`has timeZone.${property}`);
|
||||||
|
return property in target;
|
||||||
|
},
|
||||||
|
|
||||||
|
get(target, property) {
|
||||||
|
actual.push(`get timeZone.${property}`);
|
||||||
|
return target[property];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(Temporal.TimeZone, 'from', {
|
||||||
|
get() {
|
||||||
|
actual.push('get Temporal.TimeZone.from');
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
|
@ -0,0 +1,24 @@
|
||||||
|
// 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.now.plaindatetimeiso
|
||||||
|
description: Conversion of ISO date-time strings to Temporal.TimeZone instances
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let timeZone = "2021-08-19T17:30";
|
||||||
|
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "bare date-time string is not a time zone");
|
||||||
|
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO({ timeZone }), "bare date-time string is not a time zone");
|
||||||
|
|
||||||
|
// The following are all valid strings so should not throw:
|
||||||
|
|
||||||
|
[
|
||||||
|
"2021-08-19T17:30Z",
|
||||||
|
"2021-08-19T17:30-07:00",
|
||||||
|
"2021-08-19T17:30[America/Vancouver]",
|
||||||
|
"2021-08-19T17:30Z[America/Vancouver]",
|
||||||
|
"2021-08-19T17:30-07:00[America/Vancouver]",
|
||||||
|
].forEach((timeZone) => {
|
||||||
|
Temporal.Now.plainDateTimeISO(timeZone);
|
||||||
|
Temporal.Now.plainDateTimeISO({ timeZone });
|
||||||
|
});
|
Loading…
Reference in New Issue