Exemplo n.º 1
0
        // text, i.e. a string with the contents 'text'
        assert($top['children'][0]['token_name'] === 'child');
        assert(count($top['children'][0]['children']) === 1);
        assert($top['children'][0]['children'][0] === 'text');
        // now let's pop, and we should be back to the initial state
        $this->popState();
        $top = $this->getTopToken();
        assert($top['token_name'] === 'initial');
        // now let's test that we can't pop the initial state
        $exception = false;
        try {
            $this->popState();
        } catch (Exception $e) {
            $exception = true;
        }
        assert($exception);
        $top = $this->getTopToken();
        // now record some text into the initial state's child array
        $c = count($top['children']);
        $this->record('some text');
        $top = $this->getTopToken();
        $c1 = count($top['children']);
        assert($c + 1 === $c1);
        assert($top['children'][$c1 - 1] === 'some text');
    }
}
$t = new LanguageTest();
$t->test();
$t = new ApiTest();
$t->test();