From f3a868f55f37bf3d1b8b2ebc93d8c87ad0b3e2ec Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Mon, 24 Aug 2009 01:22:22 +0200 Subject: [PATCH] Fix reorderToMatchExpected by maintaining the inAttrList state correctly. Extend the test file syntax with comment and todo features. b=462701 r=sayrer --- .../tests/mochitest/parser_datreader.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/parser/htmlparser/tests/mochitest/parser_datreader.js b/parser/htmlparser/tests/mochitest/parser_datreader.js index f863d155b36..4b2d18108fd 100644 --- a/parser/htmlparser/tests/mochitest/parser_datreader.js +++ b/parser/htmlparser/tests/mochitest/parser_datreader.js @@ -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)) {