Files
Fabien Potencier 03491db322 Merge branch '1.x' into 2.x
* 1.x:
  Remove tests that do not make sense
2020-08-23 14:46:45 +02:00

121 lines
2.1 KiB
Plaintext

--TEST--
Twig supports the in operator
--TEMPLATE--
{{ bar in foo ? 'OK' : 'KO' }}
{{ not (bar in foo) ? 'KO' : 'OK' }}
{{ bar not in foo ? 'KO' : 'OK' }}
{{ 'a' in bar ? 'OK' : 'KO' }}
{{ 'c' not in bar ? 'OK' : 'KO' }}
{{ '' in bar ? 'OK' : 'KO' }}
{{ '' in '' ? 'OK' : 'KO' }}
{{ '0' not in '' ? 'OK' : 'KO' }}
{{ 'a' not in '0' ? 'OK' : 'KO' }}
{{ '0' in '0' ? 'OK' : 'KO' }}
{{ false in [0, 1] ? 'OK' : 'KO' }}
{{ true in [0, 1] ? 'OK' : 'KO' }}
{{ '0' in [0, 1] ? 'OK' : 'KO' }}
{{ '0' in [1, 0] ? 'OK' : 'KO' }}
{{ '' in 'foo' ? 'OK' : 'KO' }}
{{ 0 in 'foo' ? 'KO' : 'OK' }}
{{ false in 'foo' ? 'KO' : 'OK' }}
{{ false in '100' ? 'KO' : 'OK' }}
{{ true in '100' ? 'KO' : 'OK' }}
{{ [] in [true, false] ? 'OK' : 'KO' }}
{{ [] in [true, ''] ? 'KO' : 'OK' }}
{{ [] in [true, []] ? 'OK' : 'KO' }}
{{ resource ? 'OK' : 'KO' }}
{{ resource in 'foo'~resource ? 'KO' : 'OK' }}
{{ object in 'stdClass' ? 'KO' : 'OK' }}
{{ [] in 'Array' ? 'KO' : 'OK' }}
{{ dir_object in 'foo'~dir_object ? 'KO' : 'OK' }}
{{ ''~resource in resource ? 'KO' : 'OK' }}
{{ 'stdClass' in object ? 'KO' : 'OK' }}
{{ 'Array' in [] ? 'KO' : 'OK' }}
{{ ''~dir_object in dir_object ? 'KO' : 'OK' }}
{{ resource in [''~resource] ? 'KO' : 'OK' }}
{{ dir_object in [''~dir_object] ? 'KO' : 'OK' }}
{{ 5 in 125 ? 'KO' : 'OK' }}
{{ 5 in '125' ? 'OK' : 'KO' }}
{{ '5' in 125 ? 'KO' : 'OK' }}
{{ '5' in '125' ? 'OK' : 'KO' }}
{{ 5.5 in 125.5 ? 'KO' : 'OK' }}
{{ 5.5 in '125.5' ? 'OK' : 'KO' }}
{{ '5.5' in 125.5 ? 'KO' : 'OK' }}
{{ safe in ['foo', 'bar'] ? 'OK' : 'KO' }}
{{ 'fo' in safe ? 'OK' : 'KO' }}
{{ foo.not in ['not'] ? 'OK' : 'KO' }}
{{ 'value'|not in ['not value'] ? 'OK' : 'KO' }}
{{ foo.not not in ['not'] ? 'KO' : 'OK' }}
{{ 'value'|not not in ['not value'] ? 'KO' : 'OK' }}
{{ 'value'not in['not value'] ? 'OK' : 'KO' }}
--DATA--
return ['bar' => 'bar', 'foo' => ['bar' => 'bar', 'not' => 'not'], 'dir_object' => new \SplFileInfo(__DIR__), 'object' => new \stdClass(), 'resource' => opendir(__DIR__), 'safe' => new \Twig\Markup('foo', 'UTF-8')]
--EXPECT--
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK