You are here

public function Twig_Tests_ExpressionParserTest::getTestsForArray in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php \Twig_Tests_ExpressionParserTest::getTestsForArray()

File

vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php, line 71

Class

Twig_Tests_ExpressionParserTest

Code

public function getTestsForArray() {
  return array(
    // simple array
    array(
      '{{ [1, 2] }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant(0, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Constant(2, 1),
      ), 1),
    ),
    // array with trailing ,
    array(
      '{{ [1, 2, ] }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant(0, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Constant(2, 1),
      ), 1),
    ),
    // simple hash
    array(
      '{{ {"a": "b", "b": "c"} }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant('a', 1),
        new Twig_Node_Expression_Constant('b', 1),
        new Twig_Node_Expression_Constant('b', 1),
        new Twig_Node_Expression_Constant('c', 1),
      ), 1),
    ),
    // hash with trailing ,
    array(
      '{{ {"a": "b", "b": "c", } }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant('a', 1),
        new Twig_Node_Expression_Constant('b', 1),
        new Twig_Node_Expression_Constant('b', 1),
        new Twig_Node_Expression_Constant('c', 1),
      ), 1),
    ),
    // hash in an array
    array(
      '{{ [1, {"a": "b", "b": "c"}] }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant(0, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Constant(1, 1),
        new Twig_Node_Expression_Array(array(
          new Twig_Node_Expression_Constant('a', 1),
          new Twig_Node_Expression_Constant('b', 1),
          new Twig_Node_Expression_Constant('b', 1),
          new Twig_Node_Expression_Constant('c', 1),
        ), 1),
      ), 1),
    ),
    // array in a hash
    array(
      '{{ {"a": [1, 2], "b": "c"} }}',
      new Twig_Node_Expression_Array(array(
        new Twig_Node_Expression_Constant('a', 1),
        new Twig_Node_Expression_Array(array(
          new Twig_Node_Expression_Constant(0, 1),
          new Twig_Node_Expression_Constant(1, 1),
          new Twig_Node_Expression_Constant(1, 1),
          new Twig_Node_Expression_Constant(2, 1),
        ), 1),
        new Twig_Node_Expression_Constant('b', 1),
        new Twig_Node_Expression_Constant('c', 1),
      ), 1),
    ),
  );
}