mirror of https://github.com/tc39/test262.git
Add abstract operation test for dateFromFields
This commit is contained in:
parent
c0b3a5f074
commit
bf1b3f585f
|
@ -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.calendar.prototype.datefromfields
|
||||
description: Temporal.Calendar.prototype.dateFromFields should throw Error from ISODateFromFields.
|
||||
info: |
|
||||
6. Let result be ? ISODateFromFields(fields, options).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601")
|
||||
|
||||
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: 20},
|
||||
{overflow: "invalid garbage"}),
|
||||
"RangeError should be throw from ISODateFromFields");
|
|
@ -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.calendar.prototype.datefromfields
|
||||
description: Temporal.Calendar.prototype.dateFromFields should throw TypeError while fields is not object.
|
||||
info: |
|
||||
4. If Type(fields) is not Object, throw a TypeError exception.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601")
|
||||
|
||||
let notObjectList = [
|
||||
null, undefined, "string", Symbol('efg'), true, false, Infinity, NaN, 123, 456n];
|
||||
notObjectList.forEach(function(fields) {
|
||||
assert.throws(TypeError, () => cal.dateFromFields(fields),
|
||||
"fields is not object");
|
||||
})
|
|
@ -0,0 +1,18 @@
|
|||
// 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.calendar.prototype.datefromfields
|
||||
description: Temporal.Calendar.prototype.dateFromFields should throw TypeError from GetOptionsObject.
|
||||
info: |
|
||||
4. If Type(fields) is not Object, throw a TypeError exception.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601")
|
||||
|
||||
let fields = {year: 2021, month: 7, day: 20};
|
||||
let notObjectList = [
|
||||
null, "string", Symbol('efg'), true, false, Infinity, NaN, 123, 456n];
|
||||
notObjectList.forEach(function(options) {
|
||||
assert.throws(TypeError, () => cal.dateFromFields(fields, options),
|
||||
"options is not object");
|
||||
})
|
|
@ -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.calendar.prototype.datefromfields
|
||||
description: Temporal.Calendar.prototype.dateFromFields should throw TypeError while calendar has no [[InitializedTemporalCalendar]]
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601")
|
||||
let badCal = {dateFromFields: cal.dateFromFields};
|
||||
|
||||
assert.throws(TypeError, () => badCal.dateFromFields({year: 2021, month: 3, day: 17}),
|
||||
"calendar has no [[InitializedTemporalCalendar]]");
|
Loading…
Reference in New Issue