From 269d0ecc6419c6576ca795430eeac157c4155a18 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 17 Sep 2020 09:10:32 -0400 Subject: [PATCH] Patch tests based on input not unstable identifier --- tests/cases/TestTokenizer.php | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/tests/cases/TestTokenizer.php b/tests/cases/TestTokenizer.php index 9e8cfff..946e068 100644 --- a/tests/cases/TestTokenizer.php +++ b/tests/cases/TestTokenizer.php @@ -136,7 +136,7 @@ class TestTokenizer extends \PHPUnit\Framework\TestCase { } $test['initialStates'] = $test['initialStates'] ?? ["Data state"]; // check if a test needs a patch due to trivial differences in implementation - $this->patchTest($testId, $test); + $this->patchTest($test); for ($a = 0; $a < sizeof($test['initialStates']); $a++) { $tokens = []; foreach ($test['output'] as $token) { @@ -179,23 +179,39 @@ class TestTokenizer extends \PHPUnit\Framework\TestCase { } } - protected function patchTest(string $id, &$test): void { + protected function patchTest(&$test): void { + $id = [$test['input'], $test['initialStates']]; switch ($id) { // test emits input stream error first despite peeking - case "test3.test #30": + case [" positions in some tests don't make sense // https://github.com/html5lib/html5lib-tests/issues/125 - case "test3.test #143": - $test['errors'][0]['col'] = 10; + case ["", ["CDATA section state"]]: + // there is no position 2 + $test['errors'][0]['col']--; break; - case "test3.test #144": - case "test3.test #145": - case "test3.test #146": - $test['errors'][0]['line'] = 2; + case ["\u{A}", ["CDATA section state"]]: + // the line break is, for some reason, not counted in the test + $test['errors'][0]['line']++; + $test['errors'][0]['col'] = 1; + break; + case ["