Completed
Push — master ( 5f2691...53c2bd )
by Enrico
03:49
created

BitwiseNotTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 9 1
A testSimpleSuccessCompile() 0 11 1
A testUnexpectedTypes() 0 11 1
1
<?php
2
3
namespace Tests\PHPSA\Compiler\Expression\Operators\Bitwise;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
9
class BitwiseNotTest extends \Tests\PHPSA\TestCase
10
{
11
    /**
12
     * @return array
13
     */
14
    public function getDataProvider()
15
    {
16
        return array(
17
            array(1, -2),
18
            array(-1, 0),
19
            array(1.4,-2),
20
            array(-2.7, 1),
21
        );
22
    }
23
24
    /**
25
     * Tests ~{expr}
26
     *
27
     * @dataProvider getDataProvider
28
     */
29
    public function testSimpleSuccessCompile($a, $b)
30
    {
31
        $baseExpression = new Node\Expr\BitwiseNot(
32
            $this->newScalarExpr($a)
33
        );
34
        $compiledExpression = $this->compileExpression($baseExpression);
35
36
        $this->assertInstanceOfCompiledExpression($compiledExpression);
37
        $this->assertSame(CompiledExpression::INTEGER, $compiledExpression->getType());
38
        $this->assertSame($b, $compiledExpression->getValue());
39
    }
40
41
    public function testUnexpectedTypes()
42
    {
43
        $baseExpression = new Node\Expr\BitwiseNot(
44
            $this->newFakeScalarExpr()
45
        );
46
        $compiledExpression = $this->compileExpression($baseExpression);
47
48
        $this->assertInstanceOfCompiledExpression($compiledExpression);
49
        $this->assertSame(CompiledExpression::UNKNOWN, $compiledExpression->getType());
50
        $this->assertSame(null, $compiledExpression->getValue());
51
    }
52
}
53