packages/bison-parser/tests/Unit/Ast/LineTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Ast;
6
7use BisonParser\Ast\Line;
8use BisonParser\Ast\Location;
9use PHPUnit\Framework\Attributes\CoversClass;
10use PHPUnit\Framework\Attributes\Small;
11use PHPUnit\Framework\Attributes\UsesClass;
12use PHPUnit\Framework\TestCase;
13
14#[CoversClass(Line::class)]
15#[UsesClass(Location::class)]
16#[Small]
17final class LineTest extends TestCase
18{
19    public function testLocation(): void
20    {
21        $line = new Line(10, 'other.y', new Location(3, 1));
22
23        self::assertSame(10, $line->line);
24        self::assertSame('other.y', $line->file);
25        self::assertSame('3:1', (string) $line->location());
26        self::assertNull((new Line(1, null, new Location(1, 1)))->file);
27    }
28}
29