Removed all traces of test pre-req requirements.

Generate the 'id' property from the 'path' property.
This commit is contained in:
David Fugate 2011-09-24 11:46:26 -07:00
parent ff32b5c3fc
commit 5be3b44a3d
4 changed files with 43 additions and 43 deletions

View File

@ -23,28 +23,28 @@
//An exception is expected
if (testDescrip.negative !== undefined) {
if (window.iframeError === undefined) { //no exception was thrown
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'fail',
Error('No exception was thrown; expected an error "message" property matching the regular expression "' + testDescrip.negative + '".'));
} else if (!(new RegExp(testDescrip.negative, "i").test(window.iframeError))) { //wrong type of exception thrown
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'fail',
Error('Expected an exception with a "message" property matching the regular expression "' + testDescrip.negative +'" to be thrown; actual was "' + window.iframeError + '".'));
} else {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'pass', undefined);
}
}
//Exception was not expected to be thrown
else if (window.iframeError !== undefined) {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'fail',
Error('Unexpected exception, "' + window.iframeError + '" was thrown.'));
}
else {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'pass', undefined);
}

View File

@ -160,11 +160,6 @@ function Presenter() {
innerHTML += '<br /><br /><br /><b>Testcase</b>';
innerHTML += '<pre>' + test.code + '</pre>';
if (test.pre) {
innerHTML += '<b>Precondition</b>';
innerHTML += '<pre>' + test.pre + '</pre>';
}
innerHTML += '<b>Path</b>';
innerHTML += '<pre>' + test.path + ' </pre>&nbsp';

View File

@ -288,38 +288,28 @@ var NotEarlyError = new Error(NotEarlyErrorString);
var ES5Harness = {};
ES5Harness.registerTest = function (test) {
var error;
//Has a test precondition set, but the precondition fails
if (test.precondition && !test.precondition()) {
testRun(test.id, test.path, test.description, test.test.toString(),
typeof test.precondition !== 'undefined' ? test.precondition.toString() : '',
'fail', Error('Precondition Failed'));
}
//We're good to actually run the test case
else {
try {
if (test.strict!==undefined) {
var res = test.test();
} else {
var res = test.test.call(window);
}
try {
if (test.strict!==undefined) {
var res = test.test();
} else {
var res = test.test.call(window);
}
} catch (e) {
res = 'fail';
error = e;
if (!(e instanceof Error)) {
try {
error = Error(e.toString());
} catch (e2) {
error = Error("test262: unknown error in test case or ECMAScript implementation");
}
} catch (e) {
res = 'fail';
error = e;
if (!(e instanceof Error)) {
try {
error = Error(e.toString());
} catch (e2) {
error = Error("test262: unknown error in test case or ECMAScript implementation");
}
}
//Sputnik and IE Test Center tests are a bit different in terms of return values.
//That is, IE Test Center will always return 'true' IFF the test passed. Sputnik
//test cases will return either 'true' or 'undefined' if they pass.
var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail');
testRun(test.id, test.path, test.description, test.test.toString(),
typeof test.precondition !== 'undefined' ? test.precondition.toString() : '',
retVal, error);
}
//Sputnik and IE Test Center tests are a bit different in terms of return values.
//That is, IE Test Center will always return 'true' IFF the test passed. Sputnik
//test cases will return either 'true' or 'undefined' if they pass.
var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail');
testRun(test.id, test.path, test.description, test.test.toString(),
retVal, error);
}

View File

@ -87,14 +87,13 @@ function BrowserRunner() {
}
/* Called from the child window after the test has run. */
function testRun(id, path, description, codeString, preconditionString, result, error) {
function testRun(id, path, description, codeString, result, error) {
currentTest.id = id;
currentTest.path = path;
currentTest.description = description;
currentTest.result = result;
currentTest.error = error;
currentTest.code = codeString;
currentTest.pre = preconditionString;
}
@ -279,6 +278,21 @@ function TestLoader() {
}});
}
this.getIdFromPath = function(path) {
//path is of the form "a/b/c.js"
var id = path.split("/");
//id is now of the form ["a", "b", "c.js"];
id = id[id.length-1];
//id is now of the form "c.js"
id = id.replace(/\.js$/i, "");
//id is now of the form "c"
return id;
}
/* Move on to the next test */
this.getNextTest = function() {
if(testGroups.length == 0) {
@ -287,7 +301,8 @@ function TestLoader() {
} else if(currentTestIndex < testGroups[testGroupIndex].tests.length) {
// We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++];
var scriptCode = test.code;
var scriptCode = test.code;
scriptCode.id = getIdFromPath(test.path);
//var scriptCode = (test.firstChild.text != undefined) ?
// test.firstChild.text : test.firstChild.textContent;