Permalink
Browse files

Implemented InstanceOfType support.

  • Loading branch information...
1 parent afd2223 commit c1d6493b778ee6626c626665a02951c781aeef47 @jmalloc jmalloc committed Aug 7, 2012
Showing with 18 additions and 3 deletions.
  1. +2 −2 composer.lock
  2. +6 −0 lib/Icecave/Rasta/Generator.php
  3. +10 −1 test/suite/Icecave/Rasta/GeneratorTest.php
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -18,6 +18,7 @@
use Icecave\Pasta\AST\Node;
use Icecave\Pasta\AST\Operator\BinaryOperator;
use Icecave\Pasta\AST\Operator\Equals;
+use Icecave\Pasta\AST\Operator\InstanceOfType;
use Icecave\Pasta\AST\Operator\LogicalAnd;
use Icecave\Pasta\AST\Operator\LogicalNot;
use Icecave\Pasta\AST\Operator\LogicalOr;
@@ -277,6 +278,11 @@ public function visitLogicalNot(LogicalNot $node)
return $this->generateUnaryOperatorCode('!', $node);
}
+ public function visitInstanceOfType(InstanceOfType $node)
+ {
+ return $this->generateBinaryOperatorCode('instanceof', $node);
+ }
+
// Support ...
protected function indent($code, $level = null)
@@ -14,6 +14,7 @@
use Icecave\Pasta\AST\InterfaceDefinition;
use Icecave\Pasta\AST\Literal;
use Icecave\Pasta\AST\Operator\Equals;
+use Icecave\Pasta\AST\Operator\InstanceOfType;
use Icecave\Pasta\AST\Operator\LogicalAnd;
use Icecave\Pasta\AST\Operator\LogicalNot;
use Icecave\Pasta\AST\Operator\LogicalOr;
@@ -26,7 +27,6 @@
use Icecave\Pasta\AST\Root;
use Icecave\Pasta\AST\StatementBlock;
use Icecave\Pasta\AST\Variable;
-
use PHPUnit_Framework_TestCase;
class GeneratorTest extends PHPUnit_Framework_TestCase
@@ -555,4 +555,13 @@ public function testVisitLogicalNot()
$expected = "(!123)";
$this->assertSame($expected, $code);
}
+
+ public function testVisitInstanceOfType()
+ {
+ $node = new InstanceOfType(new Variable('foo'), QualifiedName::fromString('Bar'));
+ $code = $this->_generator->visitInstanceOfType($node);
+
+ $expected = '($foo instanceof Bar)';
+ $this->assertSame($expected, $code);
+ }
}

0 comments on commit c1d6493

Please sign in to comment.