Fix odd not working for negative numbers

This commit is contained in:
Harry Bournis
2020-11-03 19:21:08 +02:00
committed by Fabien Potencier
parent cb4cd888ca
commit 53a3ccd2d2
3 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -359,7 +359,7 @@ This is used by many of the tests built into Twig::
$compiler
->raw('(')
->subcompile($this->getNode('node'))
->raw(' % 2 == 1')
->raw(' % 2 != 0')
->raw(')')
;
}
+1 -1
View File
@@ -28,7 +28,7 @@ class OddTest extends TestExpression
$compiler
->raw('(')
->subcompile($this->getNode('node'))
->raw(' % 2 == 1')
->raw(' % 2 != 0')
->raw(')')
;
}
+2
View File
@@ -3,8 +3,10 @@
--TEMPLATE--
{{ 1 is odd ? 'ok' : 'ko' }}
{{ 2 is odd ? 'ko' : 'ok' }}
{{ -1 is odd ? 'ok' : 'ko' }}
--DATA--
return []
--EXPECT--
ok
ok
ok