Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ExpressionLanguage\Compiler;
abstract class AbstractNodeTest extends TestCase
{
/**
* @dataProvider getEvaluateData
*/
public function testEvaluate($expected, $node, $variables = [], $functions = [])
{
$this->assertSame($expected, $node->evaluate($functions, $variables));
}
abstract public function getEvaluateData();
/**
* @dataProvider getCompileData
*/
public function testCompile($expected, $node, $functions = [])
{
$compiler = new Compiler($functions);
$node->compile($compiler);
$this->assertSame($expected, $compiler->getSource());
}
abstract public function getCompileData();
/**
* @dataProvider getDumpData
*/
public function testDump($expected, $node)
{
$this->assertSame($expected, $node->dump());
}
abstract public function getDumpData();
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArgumentsNode;
class ArgumentsNodeTest extends ArrayNodeTest
{
public function getCompileData()
{
return [
['"a", "b"', $this->getArrayNode()],
];
}
public function getDumpData()
{
return [
['"a", "b"', $this->getArrayNode()],
];
}
protected function createArrayNode()
{
return new ArgumentsNode();
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
class ArrayNodeTest extends AbstractNodeTest
{
public function testSerialization()
{
$node = $this->createArrayNode();
$node->addElement(new ConstantNode('foo'));
$serializedNode = serialize($node);
$unserializedNode = unserialize($serializedNode);
$this->assertEquals($node, $unserializedNode);
$this->assertNotEquals($this->createArrayNode(), $unserializedNode);
}
public function getEvaluateData()
{
return [
[['b' => 'a', 'b'], $this->getArrayNode()],
];
}
public function getCompileData()
{
return [
['["b" => "a", 0 => "b"]', $this->getArrayNode()],
];
}
public function getDumpData()
{
yield ['{"b": "a", 0: "b"}', $this->getArrayNode()];
$array = $this->createArrayNode();
$array->addElement(new ConstantNode('c'), new ConstantNode('a"b'));
$array->addElement(new ConstantNode('d'), new ConstantNode('a\b'));
yield ['{"a\\"b": "c", "a\\\\b": "d"}', $array];
$array = $this->createArrayNode();
$array->addElement(new ConstantNode('c'));
$array->addElement(new ConstantNode('d'));
yield ['["c", "d"]', $array];
}
protected function getArrayNode()
{
$array = $this->createArrayNode();
$array->addElement(new ConstantNode('a'), new ConstantNode('b'));
$array->addElement(new ConstantNode('b'));
return $array;
}
protected function createArrayNode()
{
return new ArrayNode();
}
}

View File

@@ -0,0 +1,166 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
use Symfony\Component\ExpressionLanguage\Node\BinaryNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
class BinaryNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
$array = new ArrayNode();
$array->addElement(new ConstantNode('a'));
$array->addElement(new ConstantNode('b'));
return [
[true, new BinaryNode('or', new ConstantNode(true), new ConstantNode(false))],
[true, new BinaryNode('||', new ConstantNode(true), new ConstantNode(false))],
[false, new BinaryNode('and', new ConstantNode(true), new ConstantNode(false))],
[false, new BinaryNode('&&', new ConstantNode(true), new ConstantNode(false))],
[0, new BinaryNode('&', new ConstantNode(2), new ConstantNode(4))],
[6, new BinaryNode('|', new ConstantNode(2), new ConstantNode(4))],
[6, new BinaryNode('^', new ConstantNode(2), new ConstantNode(4))],
[true, new BinaryNode('<', new ConstantNode(1), new ConstantNode(2))],
[true, new BinaryNode('<=', new ConstantNode(1), new ConstantNode(2))],
[true, new BinaryNode('<=', new ConstantNode(1), new ConstantNode(1))],
[false, new BinaryNode('>', new ConstantNode(1), new ConstantNode(2))],
[false, new BinaryNode('>=', new ConstantNode(1), new ConstantNode(2))],
[true, new BinaryNode('>=', new ConstantNode(1), new ConstantNode(1))],
[true, new BinaryNode('===', new ConstantNode(true), new ConstantNode(true))],
[false, new BinaryNode('!==', new ConstantNode(true), new ConstantNode(true))],
[false, new BinaryNode('==', new ConstantNode(2), new ConstantNode(1))],
[true, new BinaryNode('!=', new ConstantNode(2), new ConstantNode(1))],
[-1, new BinaryNode('-', new ConstantNode(1), new ConstantNode(2))],
[3, new BinaryNode('+', new ConstantNode(1), new ConstantNode(2))],
[4, new BinaryNode('*', new ConstantNode(2), new ConstantNode(2))],
[1, new BinaryNode('/', new ConstantNode(2), new ConstantNode(2))],
[1, new BinaryNode('%', new ConstantNode(5), new ConstantNode(2))],
[25, new BinaryNode('**', new ConstantNode(5), new ConstantNode(2))],
['ab', new BinaryNode('~', new ConstantNode('a'), new ConstantNode('b'))],
[true, new BinaryNode('in', new ConstantNode('a'), $array)],
[false, new BinaryNode('in', new ConstantNode('c'), $array)],
[true, new BinaryNode('not in', new ConstantNode('c'), $array)],
[false, new BinaryNode('not in', new ConstantNode('a'), $array)],
[[1, 2, 3], new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
[1, new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+$/'))],
];
}
public function getCompileData()
{
$array = new ArrayNode();
$array->addElement(new ConstantNode('a'));
$array->addElement(new ConstantNode('b'));
return [
['(true || false)', new BinaryNode('or', new ConstantNode(true), new ConstantNode(false))],
['(true || false)', new BinaryNode('||', new ConstantNode(true), new ConstantNode(false))],
['(true && false)', new BinaryNode('and', new ConstantNode(true), new ConstantNode(false))],
['(true && false)', new BinaryNode('&&', new ConstantNode(true), new ConstantNode(false))],
['(2 & 4)', new BinaryNode('&', new ConstantNode(2), new ConstantNode(4))],
['(2 | 4)', new BinaryNode('|', new ConstantNode(2), new ConstantNode(4))],
['(2 ^ 4)', new BinaryNode('^', new ConstantNode(2), new ConstantNode(4))],
['(1 < 2)', new BinaryNode('<', new ConstantNode(1), new ConstantNode(2))],
['(1 <= 2)', new BinaryNode('<=', new ConstantNode(1), new ConstantNode(2))],
['(1 <= 1)', new BinaryNode('<=', new ConstantNode(1), new ConstantNode(1))],
['(1 > 2)', new BinaryNode('>', new ConstantNode(1), new ConstantNode(2))],
['(1 >= 2)', new BinaryNode('>=', new ConstantNode(1), new ConstantNode(2))],
['(1 >= 1)', new BinaryNode('>=', new ConstantNode(1), new ConstantNode(1))],
['(true === true)', new BinaryNode('===', new ConstantNode(true), new ConstantNode(true))],
['(true !== true)', new BinaryNode('!==', new ConstantNode(true), new ConstantNode(true))],
['(2 == 1)', new BinaryNode('==', new ConstantNode(2), new ConstantNode(1))],
['(2 != 1)', new BinaryNode('!=', new ConstantNode(2), new ConstantNode(1))],
['(1 - 2)', new BinaryNode('-', new ConstantNode(1), new ConstantNode(2))],
['(1 + 2)', new BinaryNode('+', new ConstantNode(1), new ConstantNode(2))],
['(2 * 2)', new BinaryNode('*', new ConstantNode(2), new ConstantNode(2))],
['(2 / 2)', new BinaryNode('/', new ConstantNode(2), new ConstantNode(2))],
['(5 % 2)', new BinaryNode('%', new ConstantNode(5), new ConstantNode(2))],
['pow(5, 2)', new BinaryNode('**', new ConstantNode(5), new ConstantNode(2))],
['("a" . "b")', new BinaryNode('~', new ConstantNode('a'), new ConstantNode('b'))],
['in_array("a", [0 => "a", 1 => "b"])', new BinaryNode('in', new ConstantNode('a'), $array)],
['in_array("c", [0 => "a", 1 => "b"])', new BinaryNode('in', new ConstantNode('c'), $array)],
['!in_array("c", [0 => "a", 1 => "b"])', new BinaryNode('not in', new ConstantNode('c'), $array)],
['!in_array("a", [0 => "a", 1 => "b"])', new BinaryNode('not in', new ConstantNode('a'), $array)],
['range(1, 3)', new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
['preg_match("/^[a-z]+/i\$/", "abc")', new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+/i$/'))],
];
}
public function getDumpData()
{
$array = new ArrayNode();
$array->addElement(new ConstantNode('a'));
$array->addElement(new ConstantNode('b'));
return [
['(true or false)', new BinaryNode('or', new ConstantNode(true), new ConstantNode(false))],
['(true || false)', new BinaryNode('||', new ConstantNode(true), new ConstantNode(false))],
['(true and false)', new BinaryNode('and', new ConstantNode(true), new ConstantNode(false))],
['(true && false)', new BinaryNode('&&', new ConstantNode(true), new ConstantNode(false))],
['(2 & 4)', new BinaryNode('&', new ConstantNode(2), new ConstantNode(4))],
['(2 | 4)', new BinaryNode('|', new ConstantNode(2), new ConstantNode(4))],
['(2 ^ 4)', new BinaryNode('^', new ConstantNode(2), new ConstantNode(4))],
['(1 < 2)', new BinaryNode('<', new ConstantNode(1), new ConstantNode(2))],
['(1 <= 2)', new BinaryNode('<=', new ConstantNode(1), new ConstantNode(2))],
['(1 <= 1)', new BinaryNode('<=', new ConstantNode(1), new ConstantNode(1))],
['(1 > 2)', new BinaryNode('>', new ConstantNode(1), new ConstantNode(2))],
['(1 >= 2)', new BinaryNode('>=', new ConstantNode(1), new ConstantNode(2))],
['(1 >= 1)', new BinaryNode('>=', new ConstantNode(1), new ConstantNode(1))],
['(true === true)', new BinaryNode('===', new ConstantNode(true), new ConstantNode(true))],
['(true !== true)', new BinaryNode('!==', new ConstantNode(true), new ConstantNode(true))],
['(2 == 1)', new BinaryNode('==', new ConstantNode(2), new ConstantNode(1))],
['(2 != 1)', new BinaryNode('!=', new ConstantNode(2), new ConstantNode(1))],
['(1 - 2)', new BinaryNode('-', new ConstantNode(1), new ConstantNode(2))],
['(1 + 2)', new BinaryNode('+', new ConstantNode(1), new ConstantNode(2))],
['(2 * 2)', new BinaryNode('*', new ConstantNode(2), new ConstantNode(2))],
['(2 / 2)', new BinaryNode('/', new ConstantNode(2), new ConstantNode(2))],
['(5 % 2)', new BinaryNode('%', new ConstantNode(5), new ConstantNode(2))],
['(5 ** 2)', new BinaryNode('**', new ConstantNode(5), new ConstantNode(2))],
['("a" ~ "b")', new BinaryNode('~', new ConstantNode('a'), new ConstantNode('b'))],
['("a" in ["a", "b"])', new BinaryNode('in', new ConstantNode('a'), $array)],
['("c" in ["a", "b"])', new BinaryNode('in', new ConstantNode('c'), $array)],
['("c" not in ["a", "b"])', new BinaryNode('not in', new ConstantNode('c'), $array)],
['("a" not in ["a", "b"])', new BinaryNode('not in', new ConstantNode('a'), $array)],
['(1 .. 3)', new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
['("abc" matches "/^[a-z]+/i$/")', new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+/i$/'))],
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ConditionalNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
class ConditionalNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
[1, new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
[2, new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
];
}
public function getCompileData()
{
return [
['((true) ? (1) : (2))', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
['((false) ? (1) : (2))', new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
];
}
public function getDumpData()
{
return [
['(true ? 1 : 2)', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
['(false ? 1 : 2)', new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
];
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
class ConstantNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
[false, new ConstantNode(false)],
[true, new ConstantNode(true)],
[null, new ConstantNode(null)],
[3, new ConstantNode(3)],
[3.3, new ConstantNode(3.3)],
['foo', new ConstantNode('foo')],
[[1, 'b' => 'a'], new ConstantNode([1, 'b' => 'a'])],
];
}
public function getCompileData()
{
return [
['false', new ConstantNode(false)],
['true', new ConstantNode(true)],
['null', new ConstantNode(null)],
['3', new ConstantNode(3)],
['3.3', new ConstantNode(3.3)],
['"foo"', new ConstantNode('foo')],
['[0 => 1, "b" => "a"]', new ConstantNode([1, 'b' => 'a'])],
];
}
public function getDumpData()
{
return [
['false', new ConstantNode(false)],
['true', new ConstantNode(true)],
['null', new ConstantNode(null)],
['3', new ConstantNode(3)],
['3.3', new ConstantNode(3.3)],
['"foo"', new ConstantNode('foo')],
['foo', new ConstantNode('foo', true)],
['{0: 1, "b": "a", 1: true}', new ConstantNode([1, 'b' => 'a', true])],
['{"a\\"b": "c", "a\\\\b": "d"}', new ConstantNode(['a"b' => 'c', 'a\\b' => 'd'])],
['["c", "d"]', new ConstantNode(['c', 'd'])],
['{"a": ["b"]}', new ConstantNode(['a' => ['b']])],
];
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\FunctionNode;
use Symfony\Component\ExpressionLanguage\Node\Node;
class FunctionNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => $this->getCallables()]],
];
}
public function getCompileData()
{
return [
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
];
}
public function getDumpData()
{
return [
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
];
}
protected function getCallables()
{
return [
'compiler' => function ($arg) {
return sprintf('foo(%s)', $arg);
},
'evaluator' => function ($variables, $arg) {
return $arg;
},
];
}
}

View File

@@ -0,0 +1,78 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\GetAttrNode;
use Symfony\Component\ExpressionLanguage\Node\NameNode;
class GetAttrNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
['a', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
['baz', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
['a', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b'], 'index' => 'b']],
];
}
public function getCompileData()
{
return [
['$foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
['$foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
['$foo->foo', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
['$foo->foo(["b" => "a", 0 => "b"])', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
['$foo[$index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
];
}
public function getDumpData()
{
return [
['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
];
}
protected function getArrayNode()
{
$array = new ArrayNode();
$array->addElement(new ConstantNode('a'), new ConstantNode('b'));
$array->addElement(new ConstantNode('b'));
return $array;
}
}
class Obj
{
public $foo = 'bar';
public function foo()
{
return 'baz';
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\NameNode;
class NameNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
['bar', new NameNode('foo'), ['foo' => 'bar']],
];
}
public function getCompileData()
{
return [
['$foo', new NameNode('foo')],
];
}
public function getDumpData()
{
return [
['foo', new NameNode('foo')],
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\Node;
class NodeTest extends TestCase
{
public function testToString()
{
$node = new Node([new ConstantNode('foo')]);
$this->assertEquals(<<<'EOF'
Node(
ConstantNode(value: 'foo')
)
EOF
, (string) $node);
}
public function testSerialization()
{
$node = new Node(['foo' => 'bar'], ['bar' => 'foo']);
$serializedNode = serialize($node);
$unserializedNode = unserialize($serializedNode);
$this->assertEquals($node, $unserializedNode);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\UnaryNode;
class UnaryNodeTest extends AbstractNodeTest
{
public function getEvaluateData()
{
return [
[-1, new UnaryNode('-', new ConstantNode(1))],
[3, new UnaryNode('+', new ConstantNode(3))],
[false, new UnaryNode('!', new ConstantNode(true))],
[false, new UnaryNode('not', new ConstantNode(true))],
];
}
public function getCompileData()
{
return [
['(-1)', new UnaryNode('-', new ConstantNode(1))],
['(+3)', new UnaryNode('+', new ConstantNode(3))],
['(!true)', new UnaryNode('!', new ConstantNode(true))],
['(!true)', new UnaryNode('not', new ConstantNode(true))],
];
}
public function getDumpData()
{
return [
['(- 1)', new UnaryNode('-', new ConstantNode(1))],
['(+ 3)', new UnaryNode('+', new ConstantNode(3))],
['(! true)', new UnaryNode('!', new ConstantNode(true))],
['(not true)', new UnaryNode('not', new ConstantNode(true))],
];
}
}