mirror of https://github.com/tc39/test262.git
Replace incorrect use of $DONOTEVALUATE
This commit is contained in:
parent
4f126a8ce9
commit
93ff9b7262
|
@ -24,6 +24,5 @@ $ERROR = function $ERROR(message) {
|
|||
};
|
||||
|
||||
function $DONOTEVALUATE() {
|
||||
// This function MUST NOT throw a Test262Error.
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
}
|
||||
|
|
|
@ -9,14 +9,22 @@ info: |
|
|||
1. If _lim_ = 0, return _A_.
|
||||
---*/
|
||||
|
||||
function ExpectedError(message) {
|
||||
this.message = message || "";
|
||||
}
|
||||
ExpectedError.prototype.toString = function () {
|
||||
return "ExpectedError: " + this.message;
|
||||
};
|
||||
|
||||
var nonStringableSeparator = {};
|
||||
nonStringableSeparator[Symbol.toPrimitive] = $DONOTEVALUATE;
|
||||
nonStringableSeparator.toString = $DONOTEVALUATE;
|
||||
nonStringableSeparator.valueOf = $DONOTEVALUATE;
|
||||
nonStringableSeparator[Symbol.toPrimitive] =
|
||||
function() { throw new Test262Error("separator[Symbol.toPrimitive]"); };
|
||||
nonStringableSeparator.toString = function() { throw new Test262Error("separator.toString"); };
|
||||
nonStringableSeparator.valueOf = function() { throw new Test262Error("separator.valueOf"); };
|
||||
|
||||
var nonNumberableLimit = {};
|
||||
nonStringableSeparator[Symbol.toPrimitive] = function() { throw new Test262Error(); };
|
||||
nonNumberableLimit[Symbol.toPrimitive] = function() { throw new ExpectedError(); };
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
assert.throws(ExpectedError, function() {
|
||||
"foo".split(nonStringableSeparator, nonNumberableLimit);
|
||||
}, 'ToUint32 should be called on the limit before ToString on the separator.');
|
||||
|
|
|
@ -8,9 +8,16 @@ info: |
|
|||
1. If _lim_ = 0, return _A_.
|
||||
---*/
|
||||
|
||||
var nonStringableSeparator = {};
|
||||
nonStringableSeparator.toString = function() { throw new Test262Error(); };
|
||||
function ExpectedError(message) {
|
||||
this.message = message || "";
|
||||
}
|
||||
ExpectedError.prototype.toString = function () {
|
||||
return "ExpectedError: " + this.message;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
var nonStringableSeparator = {};
|
||||
nonStringableSeparator.toString = function() { throw new ExpectedError(); };
|
||||
|
||||
assert.throws(ExpectedError, function() {
|
||||
"foo".split(nonStringableSeparator, 0);
|
||||
}, 'ToString should be called on the separator before checking if the limit is zero.');
|
||||
|
|
|
@ -12,10 +12,17 @@ info: |
|
|||
1. Let _S_ be ? ToString(_O_).
|
||||
---*/
|
||||
|
||||
function ExpectedError(message) {
|
||||
this.message = message || "";
|
||||
}
|
||||
ExpectedError.prototype.toString = function () {
|
||||
return "ExpectedError: " + this.message;
|
||||
};
|
||||
|
||||
var split = String.prototype.split;
|
||||
|
||||
var nonStringableReceiver = {};
|
||||
nonStringableReceiver.toString = function() { throw new Test262Error(); };
|
||||
nonStringableReceiver.toString = function() { throw new ExpectedError("receiver.toString"); };
|
||||
|
||||
var splitter = {};
|
||||
splitter[Symbol.split] = function() {};
|
||||
|
@ -28,10 +35,11 @@ try {
|
|||
}
|
||||
|
||||
var nonStringableSeparator = {};
|
||||
nonStringableSeparator[Symbol.toPrimitive] = $DONOTEVALUATE;
|
||||
nonStringableSeparator.toString = $DONOTEVALUATE;
|
||||
nonStringableSeparator.valueOf = $DONOTEVALUATE;
|
||||
nonStringableSeparator[Symbol.toPrimitive] =
|
||||
function() { throw new Test262Error("separator[Symbol.toPrimitive]"); };
|
||||
nonStringableSeparator.toString = function() { throw new Test262Error("separator.toString"); };
|
||||
nonStringableSeparator.valueOf = function() { throw new Test262Error("separator.valueOf"); };
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
assert.throws(ExpectedError, function() {
|
||||
split.call(nonStringableReceiver, nonStringableSeparator, Symbol());
|
||||
}, 'ToString should be called on the receiver before processing the separator or limit.');
|
||||
|
|
Loading…
Reference in New Issue