Permalink
Browse files

changed Node instances line numbers from 0 to 1 in unit tests to bett…

…er reflect what really happens when using Twig
  • Loading branch information...
1 parent bc64a7f commit 3031fe6b95f7a1791ab89beb4fe8c8e469582b78 @fabpot committed Oct 19, 2012
Showing with 357 additions and 310 deletions.
  1. +5 −5 test/Twig/Tests/Node/AutoEscapeTest.php
  2. +6 −2 test/Twig/Tests/Node/BlockReferenceTest.php
  3. +5 −4 test/Twig/Tests/Node/BlockTest.php
  4. +5 −5 test/Twig/Tests/Node/DoTest.php
  5. +7 −7 test/Twig/Tests/Node/Expression/ArrayTest.php
  6. +2 −2 test/Twig/Tests/Node/Expression/AssignNameTest.php
  7. +6 −6 test/Twig/Tests/Node/Expression/Binary/AddTest.php
  8. +6 −6 test/Twig/Tests/Node/Expression/Binary/AndTest.php
  9. +6 −6 test/Twig/Tests/Node/Expression/Binary/ConcatTest.php
  10. +6 −6 test/Twig/Tests/Node/Expression/Binary/DivTest.php
  11. +6 −6 test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php
  12. +6 −6 test/Twig/Tests/Node/Expression/Binary/ModTest.php
  13. +6 −6 test/Twig/Tests/Node/Expression/Binary/MulTest.php
  14. +6 −6 test/Twig/Tests/Node/Expression/Binary/OrTest.php
  15. +6 −6 test/Twig/Tests/Node/Expression/Binary/SubTest.php
  16. +8 −8 test/Twig/Tests/Node/Expression/ConditionalTest.php
  17. +2 −2 test/Twig/Tests/Node/Expression/ConstantTest.php
  18. +12 −12 test/Twig/Tests/Node/Expression/FilterTest.php
  19. +7 −7 test/Twig/Tests/Node/Expression/FunctionTest.php
  20. +15 −15 test/Twig/Tests/Node/Expression/GetAttrTest.php
  21. +4 −4 test/Twig/Tests/Node/Expression/NameTest.php
  22. +2 −2 test/Twig/Tests/Node/Expression/ParentTest.php
  23. +8 −8 test/Twig/Tests/Node/Expression/TestTest.php
  24. +4 −4 test/Twig/Tests/Node/Expression/Unary/NegTest.php
  25. +4 −4 test/Twig/Tests/Node/Expression/Unary/NotTest.php
  26. +4 −4 test/Twig/Tests/Node/Expression/Unary/PosTest.php
  27. +34 −30 test/Twig/Tests/Node/ForTest.php
  28. +24 −21 test/Twig/Tests/Node/IfTest.php
  29. +11 −7 test/Twig/Tests/Node/ImportTest.php
  30. +32 −18 test/Twig/Tests/Node/IncludeTest.php
  31. +7 −6 test/Twig/Tests/Node/MacroTest.php
  32. +12 −10 test/Twig/Tests/Node/ModuleTest.php
  33. +3 −3 test/Twig/Tests/Node/PrintTest.php
  34. +5 −4 test/Twig/Tests/Node/SandboxTest.php
  35. +6 −5 test/Twig/Tests/Node/SandboxedModuleTest.php
  36. +3 −2 test/Twig/Tests/Node/SandboxedPrintTest.php
  37. +27 −17 test/Twig/Tests/Node/SetTest.php
  38. +5 −4 test/Twig/Tests/Node/SpacelessTest.php
  39. +2 −2 test/Twig/Tests/Node/TextTest.php
  40. +24 −24 test/Twig/Tests/ParserTest.php
  41. +8 −8 test/Twig/Tests/TokenStreamTest.php
@@ -17,8 +17,8 @@ class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $body = new Twig_Node(array(new Twig_Node_Text('foo', 0)));
- $node = new Twig_Node_AutoEscape(true, $body, 0);
+ $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
+ $node = new Twig_Node_AutoEscape(true, $body, 1);
$this->assertEquals($body, $node->getNode('body'));
$this->assertEquals(true, $node->getAttribute('value'));
@@ -35,11 +35,11 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $body = new Twig_Node(array(new Twig_Node_Text('foo', 0)));
- $node = new Twig_Node_AutoEscape(true, $body, 0);
+ $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
+ $node = new Twig_Node_AutoEscape(true, $body, 1);
return array(
- array($node, 'echo "foo";'),
+ array($node, "// line 1\necho \"foo\";"),
);
}
}
@@ -17,7 +17,7 @@ class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $node = new Twig_Node_BlockReference('foo', 0);
+ $node = new Twig_Node_BlockReference('foo', 1);
$this->assertEquals('foo', $node->getAttribute('name'));
}
@@ -34,7 +34,11 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
return array(
- array(new Twig_Node_BlockReference('foo', 0), '$this->displayBlock(\'foo\', $context, $blocks);'),
+ array(new Twig_Node_BlockReference('foo', 1), <<<EOF
+// line 1
+\$this->displayBlock('foo', \$context, \$blocks);
+EOF
+ ),
);
}
}
@@ -17,8 +17,8 @@ class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $body = new Twig_Node_Text('foo', 0);
- $node = new Twig_Node_Block('foo', $body, 0);
+ $body = new Twig_Node_Text('foo', 1);
+ $node = new Twig_Node_Block('foo', $body, 1);
$this->assertEquals($body, $node->getNode('body'));
$this->assertEquals('foo', $node->getAttribute('name'));
@@ -35,11 +35,12 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $body = new Twig_Node_Text('foo', 0);
- $node = new Twig_Node_Block('foo', $body, 0);
+ $body = new Twig_Node_Text('foo', 1);
+ $node = new Twig_Node_Block('foo', $body, 1);
return array(
array($node, <<<EOF
+// line 1
public function block_foo(\$context, array \$blocks = array())
{
echo "foo";
@@ -17,8 +17,8 @@ class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $expr = new Twig_Node_Expression_Constant('foo', 0);
- $node = new Twig_Node_Do($expr, 0);
+ $expr = new Twig_Node_Expression_Constant('foo', 1);
+ $node = new Twig_Node_Do($expr, 1);
$this->assertEquals($expr, $node->getNode('expr'));
}
@@ -36,9 +36,9 @@ public function getTests()
{
$tests = array();
- $expr = new Twig_Node_Expression_Constant('foo', 0);
- $node = new Twig_Node_Do($expr, 0);
- $tests[] = array($node, '"foo";');
+ $expr = new Twig_Node_Expression_Constant('foo', 1);
+ $node = new Twig_Node_Do($expr, 1);
+ $tests[] = array($node, "// line 1\n\"foo\";");
return $tests;
}
@@ -16,8 +16,8 @@ class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $elements = array(new Twig_Node_Expression_Constant('foo', 0), $foo = new Twig_Node_Expression_Constant('bar', 0));
- $node = new Twig_Node_Expression_Array($elements, 0);
+ $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1));
+ $node = new Twig_Node_Expression_Array($elements, 1);
$this->assertEquals($foo, $node->getNode(1));
}
@@ -34,13 +34,13 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
$elements = array(
- new Twig_Node_Expression_Constant('foo', 0),
- new Twig_Node_Expression_Constant('bar', 0),
+ new Twig_Node_Expression_Constant('foo', 1),
+ new Twig_Node_Expression_Constant('bar', 1),
- new Twig_Node_Expression_Constant('bar', 0),
- new Twig_Node_Expression_Constant('foo', 0),
+ new Twig_Node_Expression_Constant('bar', 1),
+ new Twig_Node_Expression_Constant('foo', 1),
);
- $node = new Twig_Node_Expression_Array($elements, 0);
+ $node = new Twig_Node_Expression_Array($elements, 1);
return array(
array($node, 'array("foo" => "bar", "bar" => "foo")'),
@@ -16,7 +16,7 @@ class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $node = new Twig_Node_Expression_AssignName('foo', 0);
+ $node = new Twig_Node_Expression_AssignName('foo', 1);
$this->assertEquals('foo', $node->getAttribute('name'));
}
@@ -32,7 +32,7 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $node = new Twig_Node_Expression_AssignName('foo', 0);
+ $node = new Twig_Node_Expression_AssignName('foo', 1);
return array(
array($node, '$context["foo"]'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Add($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Add($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Add($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Add($left, $right, 1);
return array(
array($node, '(1 + 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_And($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_And($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_And($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_And($left, $right, 1);
return array(
array($node, '(1 && 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCas
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1);
return array(
array($node, '(1 . 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Div($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Div($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Div($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Div($left, $right, 1);
return array(
array($node, '(1 / 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestC
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);
return array(
array($node, 'intval(floor((1 / 2)))'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1);
return array(
array($node, '(1 % 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1);
return array(
array($node, '(1 * 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Or($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Or($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Or($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Or($left, $right, 1);
return array(
array($node, '(1 || 2)'),
@@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase
*/
public function testConstructor()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1);
$this->assertEquals($left, $node->getNode('left'));
$this->assertEquals($right, $node->getNode('right'));
@@ -36,9 +36,9 @@ public function testCompile($node, $source, $environment = null)
public function getTests()
{
- $left = new Twig_Node_Expression_Constant(1, 0);
- $right = new Twig_Node_Expression_Constant(2, 0);
- $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0);
+ $left = new Twig_Node_Expression_Constant(1, 1);
+ $right = new Twig_Node_Expression_Constant(2, 1);
+ $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1);
return array(
array($node, '(1 - 2)'),
Oops, something went wrong.

0 comments on commit 3031fe6

Please sign in to comment.