From 3b0441037f6ee680a0099b91e87f4fd1544e59e8 Mon Sep 17 00:00:00 2001 From: Technosophos Date: Thu, 18 Apr 2013 20:48:04 -0500 Subject: Tokenizer now handles sophisticated tags. --- test/HTML5/Parser/TokenizerTest.php | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'test/HTML5/Parser') diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index d525e56..eb94035 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -322,6 +322,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase { * @depends testCharacterReference */ public function testTagAttributes() { + // Opening tags. $good = array( '' => array('foo', array('bar' => 'baz'), FALSE), '' => array('foo', array('bar' => ' baz '), FALSE), @@ -330,31 +331,36 @@ class TokenizerTest extends \HTML5\Tests\TestCase { "" => array('foo', array('a' => '1', 'b' => '2'), FALSE), "" => array('foo', array('ns:bar' => 'baz'), FALSE), "" => array('foo', array('a' => 'blue&red'), FALSE), + "" => array('foo', array('a' => 'blue&&red'), FALSE), "" => array('foo', array('bar' => 'baz'), FALSE), '' => array('doe', array('a' => NULL, 'deer' => NULL), FALSE), + '' => array('foo', array('bar' => 'baz'), FALSE), + + // The spec allows an unquoted value '/'. This will not be a closing + // tag. + '' => array('foo', array('bar' => '/'), FALSE), + '' => array('foo', array('bar' => 'baz/'), FALSE), ); $this->isAllGood('startTag', 2, $good); + // Self-closing tags. $withEnd = array( '' => array('foo', array('bar' => 'baz'), TRUE), '' => array('foo', array('bar' => 'baz'), TRUE), '' => array('foo', array('bar' => 'BAZ'), TRUE), + "" => array('foo', array('a' => '1', 'b' => '2', 'c' => '3', 'd' => NULL), TRUE), ); $this->isAllGood('startTag', 3, $withEnd); - /* + // Cause a parse error. $bad = array( // This will emit an entity lookup failure for &red. "" => array('foo', array('a' => 'blue&red'), FALSE), + "" => array('foo', array('a' => 'blue&&&red'), FALSE), '' => array('foo', array('b"' => 'baz'), FALSE), - '' => array('foo', array('="bar"' => NULL), FALSE), - '' => array('foo', array('bar' => NULL), TRUE), - '' => array('foo', array(), TRUE), '' => array('foo', array('bar' => NULL), FALSE), '' => array('foo', array('bar' => NULL, '=' => NULL, '"baz"' => NULL), FALSE), + '' => array('foo', array('bar' => 'oh"'), FALSE), ); foreach ($bad as $test => $expects) { @@ -363,7 +369,20 @@ class TokenizerTest extends \HTML5\Tests\TestCase { $this->assertEventError($events->get(0)); $this->assertEventEquals('startTag', $expects, $events->get(1)); } - */ + + // Cause multiple parse errors. + $reallyBad = array( + '' => array('foo', array('=' => NULL, '"bar"' => NULL), FALSE), + '' => array('foo', array(), TRUE), + '' => array('foo', array('bar' => NULL, '=' => NULL, '"baz"' => NULL), FALSE), + ); + foreach ($reallyBad as $test => $expects) { + $events = $this->parse($test); + //fprintf(STDOUT, $test . print_r($events, TRUE)); + $this->assertEventError($events->get(0)); + $this->assertEventError($events->get(1)); + //$this->assertEventEquals('startTag', $expects, $events->get(1)); + } } public function testText() { -- cgit v1.2.3