зеркало из https://github.com/mozilla/pjs.git
Fix reorderToMatchExpected by maintaining the inAttrList state correctly. Extend the test file syntax with comment and todo features. b=462701 r=sayrer
This commit is contained in:
Родитель
4810d93bd2
Коммит
f3a868f55f
|
@ -67,18 +67,32 @@ function trimString(s) {
|
|||
*/
|
||||
function parseTestcase(testcase) {
|
||||
var lines = testcase.split("\n");
|
||||
if (lines[0] != "#data") {
|
||||
|
||||
/* check that the first non-empty, non-comment line is #data */
|
||||
for each (var line in lines) {
|
||||
if (!line || startsWith(line, "##")) {
|
||||
continue;
|
||||
}
|
||||
if (line == "#data")
|
||||
break;
|
||||
log(lines);
|
||||
throw "Unknown test format."
|
||||
}
|
||||
|
||||
var input = [];
|
||||
var output = [];
|
||||
var errors = [];
|
||||
var currentList = input;
|
||||
for each (var line in lines) {
|
||||
if (line && !(startsWith(line, "#error") ||
|
||||
startsWith(line, "#document") ||
|
||||
startsWith(line, "#data"))) {
|
||||
if (!line || startsWith(line, "##")) {
|
||||
if (startsWith(line, "##todo")) {
|
||||
todo(false, line.substring(6));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!(startsWith(line, "#error") ||
|
||||
startsWith(line, "#document") ||
|
||||
startsWith(line, "#data"))) {
|
||||
if (currentList == output && startsWith(line, "|")) {
|
||||
currentList.push(line.substring(2));
|
||||
} else {
|
||||
|
@ -126,10 +140,10 @@ function reorderToMatchExpected(output, expected) {
|
|||
return true;
|
||||
}
|
||||
|
||||
var inAttrList = false;
|
||||
for (var i=0; i < outputLines.length; i++) {
|
||||
var outputLine = outputLines[i];
|
||||
var expectedLine = expectedLines[i];
|
||||
var inAttrList = false;
|
||||
if (isAttributeLine(outputLine)) {
|
||||
// attribute mismatch, return original
|
||||
if (!isAttributeLine(expectedLine)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче