for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tests\PHPSA\Compiler\Expression\Casts;
use PhpParser\Node;
use PHPSA\CompiledExpression;
use PHPSA\Compiler\Expression;
class DoubleCastTest extends \Tests\PHPSA\TestCase
{
/**
* @return array
*/
public function getDataProvider()
return array(
array(true, 1.0),
array(0, 0.0),
array(-1, -1.0),
array(1.4, 1.4),
array("a", 0.0),
array(array(), 0.0),
);
}
* Tests (double) {expr} = {expr}
*
* @dataProvider getDataProvider
public function testSimpleSuccessCompile($a, $b)
$baseExpression = new Node\Expr\Cast\Double(
$this->newScalarExpr($a)
$compiledExpression = $this->compileExpression($baseExpression);
$this->assertInstanceOfCompiledExpression($compiledExpression);
$this->assertSame(CompiledExpression::DOUBLE, $compiledExpression->getType());
$this->assertSame($b, $compiledExpression->getValue());
public function testUnexpectedType()
$this->newFakeScalarExpr()
$this->assertSame(CompiledExpression::UNKNOWN, $compiledExpression->getType());
$this->assertSame(null, $compiledExpression->getValue());