Skip to content

Commit 242577d

Browse files
committed
Add a test of error tolerant conversion
1 parent 725a1ea commit 242577d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/ASTConverter/ErrorTolerantConversionTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,51 @@ function foo() {
176176
$this->_testFallbackFromParser($incompleteContents, $validContents);
177177
}
178178

179+
public function testMissingSemicolon() {
180+
ASTConverter::set_should_add_placeholders(false);
181+
$incompleteContents = <<<'EOT'
182+
<?php
183+
function foo() {
184+
$y = 3
185+
$x = intdiv(3, 2);
186+
}
187+
EOT;
188+
$validContents = <<<'EOT'
189+
<?php
190+
function foo() {
191+
$y = 3;
192+
$x = intdiv(3, 2);
193+
}
194+
EOT;
195+
$this->_testFallbackFromParser($incompleteContents, $validContents);
196+
}
197+
198+
// Another test (Won't work with php-parser, might work with tolerant-php-parser
199+
/**
200+
$incompleteContents = <<<'EOT'
201+
<?php
202+
class C{
203+
public function foo() {
204+
$x = 3;
205+
206+
207+
public function bar() {
208+
}
209+
}
210+
EOT;
211+
$validContents = <<<'EOT'
212+
<?php
213+
class C{
214+
public function foo() {
215+
$x = 3;
216+
}
217+
218+
public function bar() {
219+
}
220+
}
221+
EOT;
222+
*/
223+
179224
private function _testFallbackFromParser(string $incompleteContents, string $validContents) {
180225
$supports40 = ConversionTest::hasNativeASTSupport(40);
181226
$supports50 = ConversionTest::hasNativeASTSupport(50);

0 commit comments

Comments
 (0)