mirror of https://github.com/tc39/test262.git
Intl.DateTimeFormat.{formatRange,formatRangeToParts} should throw TypeError instead of RangeError if either of parameter is undefined (#2685)
http://tc39.es/proposal-intl-DateTimeFormat-formatRange/ The spec draft throws TypeError instead of RangeError. 1.4.5 Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate ) ... 4. If startDate is undefined or endDate is undefined, throw a TypeError exception. 1.4.6 Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate ) ... 4. If startDate is undefined or endDate is undefined, throw a TypeError exception.
This commit is contained in:
parent
fe3ad55d80
commit
281eb10b28
|
@ -3,14 +3,14 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Throws a RangeError if startDate or endDate is undefined.
|
||||
Throws a TypeError 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.
|
||||
4. If startDate is undefined or endDate is undefined, throw a TypeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
|
||||
|
@ -19,24 +19,24 @@ features: [Intl.DateTimeFormat-formatRange]
|
|||
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRange(); // Not possible to poison this one
|
||||
}, "no args");
|
||||
|
||||
var poison = { valueOf() { throw new Test262Error(); } };
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRange(undefined, poison);
|
||||
}, "date/undefined");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRange(poison, undefined);
|
||||
}, "undefined/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRange(poison);
|
||||
}, "only one arg");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRange(undefined, undefined);
|
||||
}, "undefined/undefined");
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Throws a RangeError if startDate or endDate are undefined.
|
||||
Throws a TypeError 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.
|
||||
4. If startDate is undefined or endDate is undefined, throw a TypeError exception.
|
||||
5. Let x be ? ToNumber(startDate).
|
||||
6. Let y be ? ToNumber(endDate).
|
||||
|
||||
|
@ -18,24 +18,24 @@ features: [Intl.DateTimeFormat-formatRange]
|
|||
---*/
|
||||
var dtf = new Intl.DateTimeFormat();
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRangeToParts(); // Not possible to poison this one
|
||||
}, "no args");
|
||||
|
||||
var poison = { valueOf() { throw new Test262Error(); } };
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRangeToParts(undefined, poison);
|
||||
}, "date/undefined");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRangeToParts(poison, undefined);
|
||||
}, "undefined/date");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRangeToParts(poison);
|
||||
}, "only one arg");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
assert.throws(TypeError, function() {
|
||||
dtf.formatRangeToParts(undefined, undefined);
|
||||
}, "undefined/undefined");
|
||||
|
|
Loading…
Reference in New Issue