tokenize(); $this->assertCount(2, $tokens); $this->assertEquals(TokenType::TEXT, $tokens[0]->type); $this->assertEquals('Hello World', $tokens[0]->value); $this->assertEquals(TokenType::EOF, $tokens[1]->type); } public function testTokenizeOutput(): void { $lexer = new Lexer('<< name >>'); $tokens = $lexer->tokenize(); $this->assertCount(4, $tokens); $this->assertEquals(TokenType::OUTPUT_START, $tokens[0]->type); $this->assertEquals(TokenType::IDENTIFIER, $tokens[1]->type); $this->assertEquals('name', $tokens[1]->value); $this->assertEquals(TokenType::OUTPUT_END, $tokens[2]->type); $this->assertEquals(TokenType::EOF, $tokens[3]->type); } public function testTokenizeControl(): void { $lexer = new Lexer('<( if true )>'); $tokens = $lexer->tokenize(); $this->assertCount(5, $tokens); $this->assertEquals(TokenType::CONTROL_START, $tokens[0]->type); $this->assertEquals(TokenType::IDENTIFIER, $tokens[1]->type); $this->assertEquals('if', $tokens[1]->value); $this->assertEquals(TokenType::IDENTIFIER, $tokens[2]->type); $this->assertEquals('true', $tokens[2]->value); $this->assertEquals(TokenType::CONTROL_END, $tokens[3]->type); } public function testTokenizeMixed(): void { $lexer = new Lexer('Hello << name >>!'); $tokens = $lexer->tokenize(); $this->assertCount(6, $tokens); $this->assertEquals(TokenType::TEXT, $tokens[0]->type); $this->assertEquals('Hello ', $tokens[0]->value); $this->assertEquals(TokenType::OUTPUT_START, $tokens[1]->type); $this->assertEquals(TokenType::IDENTIFIER, $tokens[2]->type); $this->assertEquals(TokenType::OUTPUT_END, $tokens[3]->type); $this->assertEquals(TokenType::TEXT, $tokens[4]->type); $this->assertEquals('!', $tokens[4]->value); } }