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 //An exception is expected
if (testDescrip.negative !== undefined) { if (testDescrip.negative !== undefined) {
if (window.iframeError === undefined) { //no exception was thrown 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', 'fail',
Error('No exception was thrown; expected an error "message" property matching the regular expression "' + testDescrip.negative + '".')); 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 } 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', 'fail',
Error('Expected an exception with a "message" property matching the regular expression "' + testDescrip.negative +'" to be thrown; actual was "' + window.iframeError + '".')); Error('Expected an exception with a "message" property matching the regular expression "' + testDescrip.negative +'" to be thrown; actual was "' + window.iframeError + '".'));
} else { } 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); 'pass', undefined);
} }
} }
//Exception was not expected to be thrown //Exception was not expected to be thrown
else if (window.iframeError !== undefined) { 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', 'fail',
Error('Unexpected exception, "' + window.iframeError + '" was thrown.')); Error('Unexpected exception, "' + window.iframeError + '" was thrown.'));
} }
else { 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); 'pass', undefined);
} }

View File

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

View File

@ -288,38 +288,28 @@ var NotEarlyError = new Error(NotEarlyErrorString);
var ES5Harness = {}; var ES5Harness = {};
ES5Harness.registerTest = function (test) { ES5Harness.registerTest = function (test) {
var error; var error;
//Has a test precondition set, but the precondition fails try {
if (test.precondition && !test.precondition()) { if (test.strict!==undefined) {
testRun(test.id, test.path, test.description, test.test.toString(), var res = test.test();
typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', } else {
'fail', Error('Precondition Failed')); var res = test.test.call(window);
} }
//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);
}
} catch (e) { } catch (e) {
res = 'fail'; res = 'fail';
error = e; error = e;
if (!(e instanceof Error)) { if (!(e instanceof Error)) {
try { try {
error = Error(e.toString()); error = Error(e.toString());
} catch (e2) { } catch (e2) {
error = Error("test262: unknown error in test case or ECMAScript implementation"); 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. */ /* 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.id = id;
currentTest.path = path; currentTest.path = path;
currentTest.description = description; currentTest.description = description;
currentTest.result = result; currentTest.result = result;
currentTest.error = error; currentTest.error = error;
currentTest.code = codeString; 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 */ /* Move on to the next test */
this.getNextTest = function() { this.getNextTest = function() {
if(testGroups.length == 0) { if(testGroups.length == 0) {
@ -287,7 +301,8 @@ function TestLoader() {
} else if(currentTestIndex < testGroups[testGroupIndex].tests.length) { } else if(currentTestIndex < testGroups[testGroupIndex].tests.length) {
// We have tests left in this test group. // We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++]; 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) ? //var scriptCode = (test.firstChild.text != undefined) ?
// test.firstChild.text : test.firstChild.textContent; // test.firstChild.text : test.firstChild.textContent;