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