mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 05:55:36 +02:00
Merge pull request #86 from smikes/pr/83
browser runner: check negative regex
This commit is contained in:
commit
0149045593
@ -6,9 +6,20 @@
|
|||||||
|
|
||||||
//Error Detector
|
//Error Detector
|
||||||
if (this.window!==undefined) { //for console support
|
if (this.window!==undefined) { //for console support
|
||||||
this.window.onerror = function(errorMsg, url, lineNumber) {
|
this.window.onerror = function(errorMsg, url, lineNumber, colNumber, error) {
|
||||||
this.window.iframeError = errorMsg;
|
var cookedError;
|
||||||
if(typeof $DONE === 'function') $DONE();
|
|
||||||
|
if (error) {
|
||||||
|
cookedError = error.toString();
|
||||||
|
} else {
|
||||||
|
if (/Error:/.test(errorMsg)) {
|
||||||
|
cookedError = errorMsg;
|
||||||
|
} else {
|
||||||
|
cookedError = "UnknownError: " + errorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE(cookedError);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,67 +5,65 @@
|
|||||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||||
|
|
||||||
//Global Scope Test Case Validator
|
//Global Scope Test Case Validator
|
||||||
function $DONE() {
|
var doneCalled;
|
||||||
|
function $DONE(argError) {
|
||||||
|
|
||||||
|
var testError;
|
||||||
|
var result, resultError;
|
||||||
|
|
||||||
|
if (argError) {
|
||||||
|
testError = argError.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doneCalled) {
|
||||||
|
// ? log called twice
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
doneCalled = true;
|
||||||
|
|
||||||
//An exception is expected
|
//An exception is expected
|
||||||
if (testDescrip.negative !== undefined) {
|
if (testDescrip.negative !== undefined) {
|
||||||
//TODO - come up with a generic way of catching the error type
|
//TODO - come up with a generic way of catching the error type
|
||||||
//from this.onerror
|
//from this.onerror
|
||||||
testDescrip.negative = testDescrip.negative === "NotEarlyError" ?
|
|
||||||
testDescrip.negative :
|
var negRegexp = new RegExp(testDescrip.negative, "i"),
|
||||||
(testDescrip.negative === "^((?!NotEarlyError).)*$" ?
|
unkRegexp = /^UnknownError:/;
|
||||||
testDescrip.negative : ".");
|
|
||||||
if (this.iframeError === undefined) { //no exception was thrown
|
|
||||||
testRun(testDescrip.id,
|
if (!testError) { //no exception was thrown
|
||||||
testDescrip.path,
|
result = 'fail';
|
||||||
testDescrip.description,
|
resultError = Error('No exception was thrown; expected an error "message"' +
|
||||||
testDescrip.code,
|
|
||||||
'fail',
|
|
||||||
Error('No exception was thrown; expected an error "message"' +
|
|
||||||
' property matching the regular expression "' +
|
' property matching the regular expression "' +
|
||||||
testDescrip.negative + '".'));
|
testDescrip.negative + '".');
|
||||||
} else if (!(new RegExp(testDescrip.negative,
|
} else if (!negRegexp.test(testError) &&
|
||||||
"i").test(this.iframeError))) {
|
!unkRegexp.test(testError)) {
|
||||||
//wrong type of exception thrown
|
//wrong type of exception thrown
|
||||||
testRun(testDescrip.id,
|
result = 'fail';
|
||||||
testDescrip.path,
|
resultError = Error('Expected an exception with a "message"' +
|
||||||
testDescrip.description,
|
|
||||||
testDescrip.code,
|
|
||||||
'fail',
|
|
||||||
Error('Expected an exception with a "message"' +
|
|
||||||
' property matching the regular expression "' +
|
' property matching the regular expression "' +
|
||||||
testDescrip.negative +
|
testDescrip.negative +
|
||||||
'" to be thrown; actual was "' +
|
'" to be thrown; actual was "' +
|
||||||
this.iframeError + '".'));
|
testError + '".');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
testRun(testDescrip.id,
|
result = 'pass';
|
||||||
testDescrip.path,
|
resultError = 'undefined';
|
||||||
testDescrip.description,
|
|
||||||
testDescrip.code,
|
|
||||||
'pass',
|
|
||||||
undefined);
|
|
||||||
}
|
}
|
||||||
}
|
} else if (testError) {
|
||||||
|
|
||||||
//Exception was not expected to be thrown
|
//Exception was not expected to be thrown
|
||||||
else if (this.iframeError !== undefined) {
|
result = 'fail';
|
||||||
testRun(testDescrip.id,
|
resultError = Error('Unexpected exception, "' + testError + '" was thrown.');
|
||||||
testDescrip.path,
|
} else {
|
||||||
testDescrip.description,
|
result = 'pass';
|
||||||
testDescrip.code,
|
resultError = undefined;
|
||||||
'fail',
|
|
||||||
Error('Unexpected exception, "' +
|
|
||||||
this.iframeError + '" was thrown.'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
|
||||||
testRun(testDescrip.id,
|
testRun(testDescrip.id,
|
||||||
testDescrip.path,
|
testDescrip.path,
|
||||||
testDescrip.description,
|
testDescrip.description,
|
||||||
testDescrip.code,
|
testDescrip.code,
|
||||||
'pass',
|
result,
|
||||||
undefined);
|
resultError);
|
||||||
}
|
|
||||||
|
|
||||||
//teardown
|
//teardown
|
||||||
testFinished();
|
testFinished();
|
||||||
|
@ -129,7 +129,7 @@ function BrowserRunner() {
|
|||||||
|
|
||||||
//TODO - 500ms *should* be a sufficient delay
|
//TODO - 500ms *should* be a sufficient delay
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
instance.supportsWindowOnerror = iwinPrereqs.failCount === 2;
|
instance.supportsWindowOnerror = (iwinPrereqs.failCount === 2);
|
||||||
//alert(iwinPrereqs.failCount);
|
//alert(iwinPrereqs.failCount);
|
||||||
document.body.removeChild(iframePrereqs);
|
document.body.removeChild(iframePrereqs);
|
||||||
instance.run(test, code);
|
instance.run(test, code);
|
||||||
|
@ -14,8 +14,9 @@ var y = 1;
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//CHECK#1
|
//CHECK#1
|
||||||
if(delete y){
|
var result = delete y;
|
||||||
$ERROR('#1: y = 1; (delete y) === false. Actual: ' + ((delete y)));
|
if(result){
|
||||||
|
$ERROR('#1: y = 1; (delete y) === false. Actual: ' + result);
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user