new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
+ new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
+ new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
new Twig_SimpleTest('empty', 'twig_test_empty'),
new Twig_SimpleTest('iterable', 'twig_test_iterable'),
{
$stream = $parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+ $class = $this->getTestNodeClass($parser, $name, $node->getLine());
$arguments = null;
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$arguments = $parser->getExpressionParser()->parseArguments(true);
}
- $class = $this->getTestNodeClass($parser, $name, $node->getLine());
-
return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
}
{
$env = $parser->getEnvironment();
$testMap = $env->getTests();
- if (!isset($testMap[$name])) {
+ $testName = null;
+ if (isset($testMap[$name])) {
+ $testName = $name;
+ } elseif ($parser->getStream()->test(Twig_Token::NAME_TYPE)) {
+ // try 2-words tests
+ $name = $name.' '.$parser->getCurrentToken()->getValue();
+
+ if (isset($testMap[$name])) {
+ $parser->getStream()->next();
+
+ $testName = $name;
+ }
+ }
+
+ if (null === $testName) {
$message = sprintf('The test "%s" does not exist', $name);
if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
$message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));