packages/bison-parser/tests/Unit/Ast/Declaration/Symbols/PrecedenceDeclarationTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Ast\Declaration\Symbols;
6
7use BisonParser\Ast\Declaration\Symbols\Associativity;
8use BisonParser\Ast\Declaration\Symbols\PrecedenceDeclaration;
9use BisonParser\Ast\Declaration\Symbols\SymbolEntry;
10use BisonParser\Ast\Location;
11use BisonParser\Ast\Symbol;
12use BisonParser\Ast\SymbolKind;
13use PHPUnit\Framework\Attributes\CoversClass;
14use PHPUnit\Framework\Attributes\Small;
15use PHPUnit\Framework\Attributes\UsesClass;
16use PHPUnit\Framework\TestCase;
17
18#[CoversClass(PrecedenceDeclaration::class)]
19#[UsesClass(Location::class)]
20#[UsesClass(Associativity::class)]
21#[UsesClass(Symbol::class)]
22#[UsesClass(SymbolEntry::class)]
23#[UsesClass(SymbolKind::class)]
24#[Small]
25final class PrecedenceDeclarationTest extends TestCase
26{
27    public function testLocation(): void
28    {
29        $declaration = new PrecedenceDeclaration(Associativity::Left, [new SymbolEntry(new Symbol(SymbolKind::CharLiteral, '+', new Location(3, 7)), null, null, null)], new Location(3, 1));
30
31        self::assertSame('3:1', (string) $declaration->location());
32        self::assertSame(Associativity::Left, $declaration->associativity);
33        self::assertSame('+', $declaration->entries[0]->symbol->value);
34    }
35}
36