comparison vendor/nikic/php-parser/test/PhpParser/ConstExprEvaluatorTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
2 2
3 namespace PhpParser; 3 namespace PhpParser;
4 4
5 use PhpParser\Node\Expr; 5 use PhpParser\Node\Expr;
6 use PhpParser\Node\Scalar; 6 use PhpParser\Node\Scalar;
7 use PHPUnit\Framework\TestCase;
8 7
9 class ConstExprEvaluatorTest extends TestCase 8 class ConstExprEvaluatorTest extends \PHPUnit\Framework\TestCase
10 { 9 {
11 /** @dataProvider provideTestEvaluate */ 10 /** @dataProvider provideTestEvaluate */
12 public function testEvaluate($exprString, $expected) { 11 public function testEvaluate($exprString, $expected) {
13 $parser = new Parser\Php7(new Lexer()); 12 $parser = new Parser\Php7(new Lexer());
14 $expr = $parser->parse('<?php ' . $exprString . ';')[0]->expr; 13 $expr = $parser->parse('<?php ' . $exprString . ';')[0]->expr;
71 ['true or (1/0)', true], 70 ['true or (1/0)', true],
72 ['true xor false', true], 71 ['true xor false', true],
73 ]; 72 ];
74 } 73 }
75 74
76 /**
77 * @expectedException \PhpParser\ConstExprEvaluationException
78 * @expectedExceptionMessage Expression of type Expr_Variable cannot be evaluated
79 */
80 public function testEvaluateFails() { 75 public function testEvaluateFails() {
76 $this->expectException(ConstExprEvaluationException::class);
77 $this->expectExceptionMessage('Expression of type Expr_Variable cannot be evaluated');
81 $evaluator = new ConstExprEvaluator(); 78 $evaluator = new ConstExprEvaluator();
82 $evaluator->evaluateDirectly(new Expr\Variable('a')); 79 $evaluator->evaluateDirectly(new Expr\Variable('a'));
83 } 80 }
84 81
85 public function testEvaluateFallback() { 82 public function testEvaluateFallback() {