packages/deriver/tests/Unit/Deriver/Evaluator/Call/Plan/ActionKindTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Deriver\Evaluator\Call\Plan;
6
7use Deriver\Deriver\Evaluator\Call\Plan\ActionKind as Subject;
8use PHPUnit\Framework\Attributes\CoversNothing;
9use PHPUnit\Framework\TestCase;
10
11#[CoversNothing]
12final class ActionKindTest extends TestCase
13{
14 public function testThrowActionsLowerToExceptionalControlFlow(): void
15 {
16 $compiler = new \Deriver\Deriver\Evaluator\Call\Plan\PlanCompiler(new \Deriver\Deriver\Sources\SourceRef('s', 'evaluator:custom', 0, 1));
17 $action = new \Deriver\Deriver\Evaluator\Call\Plan\Action(Subject::Throw, [\Deriver\Deriver\Evaluator\Call\Plan\Expression::literal(\Deriver\Deriver\Evaluator\Term::opaque('vendor.failure', 'Throwable'))]);
18 self::assertTrue((new \Deriver\Deriver\Evaluator\Call\Plan\PlanActions($compiler))->apply($action));
19 self::assertSame(\Deriver\Deriver\Lowerer\Graph\TerminatorKind::Throw, $compiler->terminators[0]->kind);
20 self::assertSame('vendor.failure', (new \Deriver\Deriver\Evaluator\Expression\LiteralEvaluator())->instruction($compiler->instructions[0][0])->literal);
21 }
22}
23