|
35 | 35 | use PackageFactory\ComponentEngine\TypeSystem\Type\StringType\StringType; |
36 | 36 | use PHPUnit\Framework\TestCase; |
37 | 37 |
|
38 | | -final class IntegrationTest extends TestCase |
| 38 | +final class PhpTranspilerIntegrationTest extends TestCase |
39 | 39 | { |
40 | | - public function tokenizationExamples(): array |
41 | | - { |
42 | | - return [ |
43 | | - 'Comment' => ["Comment"], |
44 | | - 'Component' => ["Component"], |
45 | | - 'ComponentWithKeywords' => ["ComponentWithKeywords"], |
46 | | - 'ComponentWithNesting' => ["ComponentWithNesting"], |
47 | | - 'Enum' => ["Enum"], |
48 | | - 'Expression' => ["Expression"], |
49 | | - 'ImportExport' => ["ImportExport"], |
50 | | - 'Match' => ["Match"], |
51 | | - 'Numbers' => ["Numbers"], |
52 | | - 'Struct' => ["Struct"], |
53 | | - 'TemplateLiteral' => ["TemplateLiteral"], |
54 | | - ]; |
55 | | - } |
56 | | - |
57 | | - /** |
58 | | - * @dataProvider tokenizationExamples |
59 | | - * @test |
60 | | - * @small |
61 | | - * @param string $input |
62 | | - * @return void |
63 | | - */ |
64 | | - public function testTokenizer(string $example): void |
65 | | - { |
66 | | - $source = Source::fromFile(__DIR__ . '/Examples/' . $example . '/' . $example . '.afx'); |
67 | | - $tokenizer = Tokenizer::fromSource($source); |
68 | | - $expected = json_decode( |
69 | | - file_get_contents(__DIR__ . '/Examples/' . $example . '/' . $example . '.tokens.json') |
70 | | - ); |
71 | | - |
72 | | - $index = 0; |
73 | | - foreach ($tokenizer as $token) { |
74 | | - if (!isset($expected[$index])) { |
75 | | - $tokenType = $token->type; |
76 | | - $this->fail("Unfinished expectation at $index [$tokenType->name]($token->value)"); |
77 | | - } |
78 | | - $this->assertEquals($expected[$index]->type, $token->type->name, "Type mismatch at index $index ($token->value)"); |
79 | | - $this->assertEquals($expected[$index]->value, $token->value, "Value mismatch at index $index"); |
80 | | - $index++; |
81 | | - } |
82 | | - } |
83 | | - |
84 | | - public function astExamples(): array |
85 | | - { |
86 | | - return [ |
87 | | - 'Comment' => ["Comment"], |
88 | | - 'Component' => ["Component"], |
89 | | - 'ComponentWithKeywords' => ["ComponentWithKeywords"], |
90 | | - 'ComponentWithNesting' => ["ComponentWithNesting"], |
91 | | - 'Enum' => ["Enum"], |
92 | | - 'Expression' => ["Expression"], |
93 | | - 'ImportExport' => ["ImportExport"], |
94 | | - 'Match' => ["Match"], |
95 | | - 'Numbers' => ["Numbers"], |
96 | | - 'Struct' => ["Struct"], |
97 | | - 'TemplateLiteral' => ["TemplateLiteral"], |
98 | | - ]; |
99 | | - } |
100 | | - |
101 | | - /** |
102 | | - * @dataProvider astExamples |
103 | | - * @test |
104 | | - * @small |
105 | | - * @param string $input |
106 | | - * @return void |
107 | | - */ |
108 | | - public function testParser(string $example): void |
109 | | - { |
110 | | - $source = Source::fromFile(__DIR__ . '/Examples/' . $example . '/' . $example . '.afx'); |
111 | | - $tokenizer = Tokenizer::fromSource($source); |
112 | | - $expected = json_decode( |
113 | | - file_get_contents(__DIR__ . '/Examples/' . $example . '/' . $example . '.ast.json'), |
114 | | - true |
115 | | - ); |
116 | | - |
117 | | - $module = ModuleNode::fromTokens($tokenizer->getIterator()); |
118 | | - |
119 | | - $this->assertEquals($expected, json_decode(json_encode($module), true)); |
120 | | - } |
121 | | - |
122 | 40 | public function transpilerExamples(): array |
123 | 41 | { |
124 | 42 | return [ |
|
0 commit comments