This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added support for literal null.

  • Loading branch information...
jmalloc committed Aug 15, 2012
1 parent 9ad5a92 commit 5df7056500b39f9597126dd657ad6d337f4df7a1
Showing with 38 additions and 3 deletions.
  1. +2 −2 composer.lock
  2. +3 −0 lib/Icecave/Rasta/Renderer.php
  3. +33 −1 test/suite/Icecave/Rasta/RendererTest.php
View

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

Oops, something went wrong.
@@ -354,6 +354,9 @@ public function visitCall(Call $node)
public function visitLiteral(Literal $node)
{
+ if (null === $node->value()) {
+ return 'null';
+ }
return var_export($node->value(), true);
}
@@ -499,13 +499,45 @@ public function testVisitFunctionCallNestedCall()
$this->assertSame($expected, $code);
}
- public function testVisitLiteral()
+ public function testVisitLiteralString()
{
$node = new Literal('<literal>');
$code = $node->accept($this->_renderer);
$this->assertSame("'<literal>'", $code);
}
+ public function testVisitLiteralNull()
+ {
+ $node = new Literal(null);
+ $code = $node->accept($this->_renderer);
+ $this->assertSame('null', $code);
+ }
+
+ public function testVisitLiteralBoolean()
+ {
+ $node = new Literal(true);
+ $code = $node->accept($this->_renderer);
+ $this->assertSame('true', $code);
+
+ $node = new Literal(false);
+ $code = $node->accept($this->_renderer);
+ $this->assertSame('false', $code);
+ }
+
+ public function testVisitLiteralInteger()
+ {
+ $node = new Literal(123);
+ $code = $node->accept($this->_renderer);
+ $this->assertSame('123', $code);
+ }
+
+ public function testVisitLiteralFloat()
+ {
+ $node = new Literal(1.5);
+ $code = $node->accept($this->_renderer);
+ $this->assertSame('1.5', $code);
+ }
+
public function testVisitVariable()
{
$node = new Variable(new Identifier('thing'));

0 comments on commit 5df7056

Please sign in to comment.