Location: PHPKode > scripts > Lisphp > lunant-lisphp-adfa7bf/Lisphp/Test/LiteralTest.php
<?php
require_once 'PHPUnit/Framework.php';
require_once 'Lisphp/Literal.php';
require_once 'Lisphp/Scope.php';

class Lisphp_Test_LiteralTest extends PHPUnit_Framework_TestCase {
    static $values = array('integer' => 123, 'real' => 3.14, 'string' => 'abc');

    function testUnexpectedValue() {
        $this->setExpectedException('UnexpectedValueException');
        new Lisphp_Literal(new stdClass);
    }

    function testValue() {
        foreach (self::$values as $_ => $value) {
            $literal = new Lisphp_Literal($value);
            $this->assertEquals($value, $literal->value);
        }
    }

    function testEvaluate() {
        foreach (self::$values as $_ => $value) {
            $literal = new Lisphp_Literal($value);
            $this->assertEquals($value, $literal->evaluate(new Lisphp_Scope));
        }
    }

    function testPredicate() {
        foreach (self::$values as $type => $value) {
            $literal = new Lisphp_Literal($value);
            $this->assertTrue($literal->{"is$type"}());
        }
    }
}

Return current item: Lisphp