mirror of https://github.com/tc39/test262.git
Add initial tests for Intl.DateTimeFormat formatRange and formatRangeToParts (#2134)
This commit is contained in:
parent
94c498a792
commit
4b25f6fae8
|
@ -96,6 +96,10 @@ Intl.NumberFormat-unified
|
|||
# https://github.com/tc39/proposal-intl-datetime-style
|
||||
Intl.DateTimeFormat-datetimestyle
|
||||
|
||||
# Intl.DateTimeFormat: formatRange and formatRangeToParts functions
|
||||
# https://github.com/tc39/proposal-intl-DateTimeFormat-formatRange
|
||||
Intl.DateTimeFormat-formatRange
|
||||
|
||||
# Global
|
||||
# https://github.com/tc39/proposal-global
|
||||
globalThis
|
||||
|
|
70
test/intl402/DateTimeFormat/prototype/formatRange/date-is-infinity-throws.js
vendored
Normal file
70
test/intl402/DateTimeFormat/prototype/formatRange/date-is-infinity-throws.js
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date arg is cast to an Infinity value
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
8. Return ? FormatDateTimeRange(dtf, x, y).
|
||||
|
||||
FormatDateTimeRange ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
|
||||
|
||||
PartitionDateTimeRangePattern ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let x be TimeClip(x).
|
||||
2. If x is NaN, throw a RangeError exception.
|
||||
3. Let y be TimeClip(y).
|
||||
4. If y is NaN, throw a RangeError exception.
|
||||
|
||||
TimeClip ( time )
|
||||
1. If time is not finite, return NaN.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var date = new Date();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(Infinity, date);
|
||||
}, "+Infinity/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(-Infinity, date);
|
||||
}, "-Infinity/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(date, Infinity);
|
||||
}, "date/+Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(date, -Infinity);
|
||||
}, "date/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(Infinity, Infinity);
|
||||
}, "+Infinity/+Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(-Infinity, -Infinity);
|
||||
}, "-Infinity/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(Infinity, -Infinity);
|
||||
}, "+Infinity/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(-Infinity, Infinity);
|
||||
}, "-Infinity/+Infinity");
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date arg is cast to NaN
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
8. Return ? FormatDateTimeRange(dtf, x, y).
|
||||
|
||||
FormatDateTimeRange ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
|
||||
|
||||
PartitionDateTimeRangePattern ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let x be TimeClip(x).
|
||||
2. If x is NaN, throw a RangeError exception.
|
||||
3. Let y be TimeClip(y).
|
||||
4. If y is NaN, throw a RangeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var date = new Date();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(NaN, date);
|
||||
}, "NaN/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(date, NaN);
|
||||
}, "date/NaN");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(NaN, NaN);
|
||||
}, "NaN/NaN");
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if startDate or endDate is undefined.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(); // Not possible to poison this one
|
||||
}, "no args");
|
||||
|
||||
var poison = { valueOf() { throw new Test262Error(); } };
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(undefined, poison);
|
||||
}, "date/undefined");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(poison, undefined);
|
||||
}, "undefined/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(poison);
|
||||
}, "only one arg");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(undefined, undefined);
|
||||
}, "undefined/undefined");
|
32
test/intl402/DateTimeFormat/prototype/formatRange/date-x-greater-than-y-throws.js
vendored
Normal file
32
test/intl402/DateTimeFormat/prototype/formatRange/date-x-greater-than-y-throws.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date x is greater than y.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var x = new Date();
|
||||
var y = new Date();
|
||||
x.setDate(y.getDate() + 1);
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRange(x, y);
|
||||
}, "x > y");
|
||||
|
||||
assert.sameValue("string", typeof dtf.formatRange(x, x));
|
||||
assert.sameValue("string", typeof dtf.formatRange(y, y));
|
||||
assert.sameValue("string", typeof dtf.formatRange(y, x));
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Intl.DateTimeFormat.prototype.formatRange.length.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Intl.DateTimeFormat.prototype.formatRange.length, 2);
|
||||
|
||||
verifyProperty(Intl.DateTimeFormat.prototype.formatRange, 'length', {
|
||||
value: 2,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Intl.DateTimeFormat.prototype.formatRange.name value and descriptor.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
assert.sameValue(Intl.DateTimeFormat.prototype.formatRange.name, 'formatRange',
|
||||
'The value of `Intl.DateTimeFormat.prototype.formatRange.name` is `"formatRange"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Intl.DateTimeFormat.prototype.formatRange, 'name');
|
||||
verifyNotWritable(Intl.DateTimeFormat.prototype.formatRange, 'name');
|
||||
verifyConfigurable(Intl.DateTimeFormat.prototype.formatRange, 'name');
|
47
test/intl402/DateTimeFormat/prototype/formatRange/this-is-not-object-throws.js
vendored
Normal file
47
test/intl402/DateTimeFormat/prototype/formatRange/this-is-not-object-throws.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a TypeError if this is not Object.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange, Symbol]
|
||||
---*/
|
||||
|
||||
let formatRange = Intl.DateTimeFormat.prototype.formatRange;
|
||||
let d1 = new Date("1997-08-22T00:00");
|
||||
let d2 = new Date("1999-06-26T00:00");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(undefined, d1, d2);
|
||||
}, "undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(null, d1, d2);
|
||||
}, "null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(42, d1, d2);
|
||||
}, "number");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call("foo", d1, d2);
|
||||
}, "string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(false, d1, d2);
|
||||
}, "false");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(true, d1, d2);
|
||||
}, "true");
|
||||
|
||||
var s = Symbol('3');
|
||||
assert.throws(TypeError, function() {
|
||||
formatRange.call(s, d1, d2);
|
||||
}, "symbol");
|
69
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-is-infinity-throws.js
vendored
Normal file
69
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-is-infinity-throws.js
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date arg is cast to an Infinity value
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
8. Return ? FormatDateTimeRangeToParts(dtf, x, y).
|
||||
|
||||
FormatDateTimeRangeToParts ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
|
||||
|
||||
PartitionDateTimeRangePattern ( dateTimeFormat, x, y )
|
||||
1. Let x be TimeClip(x).
|
||||
2. If x is NaN, throw a RangeError exception.
|
||||
3. Let y be TimeClip(y).
|
||||
4. If y is NaN, throw a RangeError exception.
|
||||
|
||||
TimeClip ( time )
|
||||
1. If time is not finite, return NaN.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var date = new Date();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(Infinity, date);
|
||||
}, "+Infinity/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(-Infinity, date);
|
||||
}, "-Infinity/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(date, Infinity);
|
||||
}, "date/+Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(date, -Infinity);
|
||||
}, "date/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(Infinity, Infinity);
|
||||
}, "+Infinity/+Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(-Infinity, -Infinity);
|
||||
}, "-Infinity/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(Infinity, -Infinity);
|
||||
}, "+Infinity/-Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(-Infinity, Infinity);
|
||||
}, "-Infinity/+Infinity");
|
47
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-is-nan-throws.js
vendored
Normal file
47
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-is-nan-throws.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date arg is cast to Nan
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
8. Return ? FormatDateTimeRangeToParts(dtf, x, y).
|
||||
|
||||
FormatDateTimeRangeToParts ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
|
||||
|
||||
PartitionDateTimeRangePattern ( dateTimeFormat, x, y )
|
||||
|
||||
1. Let x be TimeClip(x).
|
||||
2. If x is NaN, throw a RangeError exception.
|
||||
3. Let y be TimeClip(y).
|
||||
4. If y is NaN, throw a RangeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var date = new Date();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(NaN, date);
|
||||
}, "NaN/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(date, NaN);
|
||||
}, "date/NaN");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(NaN, NaN);
|
||||
}, "NaN/NaN");
|
41
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-undefined-throws.js
vendored
Normal file
41
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-undefined-throws.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if startDate or endDate are undefined.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(); // Not possible to poison this one
|
||||
}, "no args");
|
||||
|
||||
var poison = { valueOf() { throw new Test262Error(); } };
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(undefined, poison);
|
||||
}, "date/undefined");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(poison, undefined);
|
||||
}, "undefined/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(poison);
|
||||
}, "only one arg");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(undefined, undefined);
|
||||
}, "undefined/undefined");
|
31
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-x-greater-than-y-throws.js
vendored
Normal file
31
test/intl402/DateTimeFormat/prototype/formatRangeToParts/date-x-greater-than-y-throws.js
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a RangeError if date x is greater than y.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
7. If x is greater than y, throw a RangeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
var x = new Date();
|
||||
var y = new Date();
|
||||
x.setDate(y.getDate() + 1);
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
dtf.formatRangeToParts(x, y);
|
||||
}, "x > y");
|
||||
assert.sameValue("object", typeof dtf.formatRangeToParts(x, x));
|
||||
assert.sameValue("object", typeof dtf.formatRangeToParts(y, y));
|
||||
assert.sameValue("object", typeof dtf.formatRangeToParts(y, x));
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Intl.DateTimeFormat.prototype.formatRangeToParts.length.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Intl.DateTimeFormat.prototype.formatRangeToParts.length, 2);
|
||||
|
||||
verifyProperty(Intl.DateTimeFormat.prototype.formatRangeToParts, 'length', {
|
||||
value: 2,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Intl.DateTimeFormat.prototype.formatRangeToParts.name value and descriptor.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.DateTimeFormat-formatRange]
|
||||
---*/
|
||||
assert.sameValue(Intl.DateTimeFormat.prototype.formatRangeToParts.name, 'formatRangeToParts',
|
||||
'The value of `Intl.DateTimeFormat.prototype.formatRangeToParts.name` is `"formatRangeToParts"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Intl.DateTimeFormat.prototype.formatRangeToParts, 'name');
|
||||
verifyNotWritable(Intl.DateTimeFormat.prototype.formatRangeToParts, 'name');
|
||||
verifyConfigurable(Intl.DateTimeFormat.prototype.formatRangeToParts, 'name');
|
47
test/intl402/DateTimeFormat/prototype/formatRangeToParts/this-is-not-object-throws.js
vendored
Normal file
47
test/intl402/DateTimeFormat/prototype/formatRangeToParts/this-is-not-object-throws.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2019 Google, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description:
|
||||
Throws a TypeError if this is not Object.
|
||||
info:
|
||||
Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
|
||||
|
||||
1. Let dtf be this value.
|
||||
2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
|
||||
features: [Intl.DateTimeFormat-formatRange, Symbol]
|
||||
---*/
|
||||
|
||||
let formatRangeToParts = Intl.DateTimeFormat.prototype.formatRangeToParts;
|
||||
let d1 = new Date("1997-08-22T00:00");
|
||||
let d2 = new Date("1999-06-26T00:00");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(undefined, d1, d2);
|
||||
}, "undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(null, d1, d2);
|
||||
}, "null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(42, d1, d2);
|
||||
}, "number");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call("foo", d1, d2);
|
||||
}, "string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(false, d1, d2);
|
||||
}, "false");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(true, d1, d2);
|
||||
}, "true");
|
||||
|
||||
var s = Symbol('3');
|
||||
assert.throws(TypeError, function() {
|
||||
formatRangeToParts.call(s, d1, d2);
|
||||
}, "symbol");
|
Loading…
Reference in New Issue