Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
9 use PhpParser\Node\Scalar\EncapsedStringPart; | 9 use PhpParser\Node\Scalar\EncapsedStringPart; |
10 use PhpParser\Node\Scalar\LNumber; | 10 use PhpParser\Node\Scalar\LNumber; |
11 use PhpParser\Node\Scalar\String_; | 11 use PhpParser\Node\Scalar\String_; |
12 use PhpParser\Node\Stmt; | 12 use PhpParser\Node\Stmt; |
13 use PhpParser\PrettyPrinter\Standard; | 13 use PhpParser\PrettyPrinter\Standard; |
14 | |
15 require_once __DIR__ . '/CodeTestAbstract.php'; | |
16 | 14 |
17 class PrettyPrinterTest extends CodeTestAbstract | 15 class PrettyPrinterTest extends CodeTestAbstract |
18 { | 16 { |
19 protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $modeLine) { | 17 protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $modeLine) { |
20 $lexer = new Lexer\Emulative; | 18 $lexer = new Lexer\Emulative; |
182 [new DNumber(-\INF), '-\INF'], | 180 [new DNumber(-\INF), '-\INF'], |
183 [new DNumber(-\NAN), '\NAN'], | 181 [new DNumber(-\NAN), '\NAN'], |
184 ]; | 182 ]; |
185 } | 183 } |
186 | 184 |
187 /** | |
188 * @expectedException \LogicException | |
189 * @expectedExceptionMessage Cannot pretty-print AST with Error nodes | |
190 */ | |
191 public function testPrettyPrintWithError() { | 185 public function testPrettyPrintWithError() { |
186 $this->expectException(\LogicException::class); | |
187 $this->expectExceptionMessage('Cannot pretty-print AST with Error nodes'); | |
192 $stmts = [new Stmt\Expression( | 188 $stmts = [new Stmt\Expression( |
193 new Expr\PropertyFetch(new Expr\Variable('a'), new Expr\Error()) | 189 new Expr\PropertyFetch(new Expr\Variable('a'), new Expr\Error()) |
194 )]; | 190 )]; |
195 $prettyPrinter = new PrettyPrinter\Standard; | 191 $prettyPrinter = new PrettyPrinter\Standard; |
196 $prettyPrinter->prettyPrint($stmts); | 192 $prettyPrinter->prettyPrint($stmts); |
197 } | 193 } |
198 | 194 |
199 /** | |
200 * @expectedException \LogicException | |
201 * @expectedExceptionMessage Cannot pretty-print AST with Error nodes | |
202 */ | |
203 public function testPrettyPrintWithErrorInClassConstFetch() { | 195 public function testPrettyPrintWithErrorInClassConstFetch() { |
196 $this->expectException(\LogicException::class); | |
197 $this->expectExceptionMessage('Cannot pretty-print AST with Error nodes'); | |
204 $stmts = [new Stmt\Expression( | 198 $stmts = [new Stmt\Expression( |
205 new Expr\ClassConstFetch(new Name('Foo'), new Expr\Error()) | 199 new Expr\ClassConstFetch(new Name('Foo'), new Expr\Error()) |
206 )]; | 200 )]; |
207 $prettyPrinter = new PrettyPrinter\Standard; | 201 $prettyPrinter = new PrettyPrinter\Standard; |
208 $prettyPrinter->prettyPrint($stmts); | 202 $prettyPrinter->prettyPrint($stmts); |
209 } | 203 } |
210 | 204 |
211 /** | |
212 * @expectedException \LogicException | |
213 * @expectedExceptionMessage Cannot directly print EncapsedStringPart | |
214 */ | |
215 public function testPrettyPrintEncapsedStringPart() { | 205 public function testPrettyPrintEncapsedStringPart() { |
206 $this->expectException(\LogicException::class); | |
207 $this->expectExceptionMessage('Cannot directly print EncapsedStringPart'); | |
216 $expr = new Node\Scalar\EncapsedStringPart('foo'); | 208 $expr = new Node\Scalar\EncapsedStringPart('foo'); |
217 $prettyPrinter = new PrettyPrinter\Standard; | 209 $prettyPrinter = new PrettyPrinter\Standard; |
218 $prettyPrinter->prettyPrintExpr($expr); | 210 $prettyPrinter->prettyPrintExpr($expr); |
219 } | 211 } |
220 | 212 |