<commit_before><?php

namespace Phug\Test\Parser\TokenHandler;

use Phug\Lexer;
use Phug\Lexer\Token\TagToken;
use Phug\Parser\Node\CodeNode;
use Phug\Parser\State;
use Phug\Parser\TokenHandler\CodeTokenHandler;
use Phug\Test\AbstractParserTest;

/**
 * @coversDefaultClass Phug\Parser\TokenHandler\CodeTokenHandler
 */
class CodeTokenHandlerTest extends AbstractParserTest
{
    /**
     * @covers ::<public>
     */
    public function testHandleSingleLine()
    {
        $this->assertNodes('- do_something();', [
            '[DocumentNode]',
            '  [CodeNode]',
            '    [TextNode]',
        ]);
        $this->assertNodes("code- do_something()\n  | foo\n| bar", [
            '[DocumentNode]',
            '  [ElementNode]',
            '    [CodeNode]',
            '    [TextNode]',
            '  [TextNode]',
        ]);
        $documentNodes = $this->parser->parse("code- do_something()\n  | foo\n| bar")->getChildren();
        self::assertSame('code', $documentNodes[0]->getName());
        self::assertSame('bar', $documentNodes[1]->getValue());
        $elementNodes = $documentNodes[0]->getChildren();
        self::assertSame('do_something()', $elementNodes[0]->getValue());
        self::assertSame('foo', $elementNodes[1]->getValue());
    }

    /**
     * @group i
     * @covers ::<public>
     */
    public function testHandleBlock()
    {
        $this->assertNodes("-\n  foo();\n  bar();", [
            '[DocumentNode]',
            '  [CodeNode]',
            '    [TextNode]',
        ]);
        $documentNodes = $this->parser->parse("-\n  foo();\n  bar();")->getChildren();<commit_msg>Cleanup annotations<commit_after><?php

namespace Phug\Test\Parser\TokenHandler;

use Phug\Lexer;
use Phug\Lexer\Token\TagToken;
use Phug\Parser\Node\CodeNode;
use Phug\Parser\State;
use Phug\Parser\TokenHandler\CodeTokenHandler;
use Phug\Test\AbstractParserTest;

/**
 * @coversDefaultClass Phug\Parser\TokenHandler\CodeTokenHandler
 */
class CodeTokenHandlerTest extends AbstractParserTest
{
    /**
     * @covers ::<public>
     */
    public function testHandleSingleLine()
    {
        $this->assertNodes('- do_something();', [
            '[DocumentNode]',
            '  [CodeNode]',
            '    [TextNode]',
        ]);
        $this->assertNodes("code- do_something()\n  | foo\n| bar", [
            '[DocumentNode]',
            '  [ElementNode]',
            '    [CodeNode]',
            '    [TextNode]',
            '  [TextNode]',
        ]);
        $documentNodes = $this->parser->parse("code- do_something()\n  | foo\n| bar")->getChildren();
        self::assertSame('code', $documentNodes[0]->getName());
        self::assertSame('bar', $documentNodes[1]->getValue());
        $elementNodes = $documentNodes[0]->getChildren();
        self::assertSame('do_something()', $elementNodes[0]->getValue());
        self::assertSame('foo', $elementNodes[1]->getValue());
    }

    /**
     * @covers ::<public>
     */
    public function testHandleBlock()
    {
        $this->assertNodes("-\n  foo();\n  bar();", [
            '[DocumentNode]',
            '  [CodeNode]',
            '    [TextNode]',
        ]);
        $documentNodes = $this->parser->parse("-\n  foo();\n  bar();")->getChildren();
{'fraction_non_alphanumeric': 0.18304668304668303, 'fraction_numerical': 0.003071253071253071, 'mean_word_length': 2.4575371549893843, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6033594', 'n_tokens_mistral': 1000, 'n_tokens_neox': 1000, 'n_words': 142}