You are here

public function ScannerTest::testUnconsume in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/test/HTML5/Parser/ScannerTest.php \Masterminds\HTML5\Tests\Parser\ScannerTest::testUnconsume()

File

vendor/masterminds/html5/test/HTML5/Parser/ScannerTest.php, line 68
Test the Scanner. This requires the InputStream tests are all good.

Class

ScannerTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testUnconsume() {
  $s = new Scanner(new StringInputStream("abcdefghijklmnopqrst"));

  // Get initial position.
  $s
    ->next();
  $start = $s
    ->position();

  // Move forward a bunch of positions.
  $amount = 7;
  for ($i = 0; $i < $amount; $i++) {
    $s
      ->next();
  }

  // Roll back the amount we moved forward.
  $s
    ->unconsume($amount);
  $this
    ->assertEquals($start, $s
    ->position());
}