545f51f81fefea98647f55ac7a856eb7f7648eeb
[yaffs-website] / vendor / twig / twig / test / Twig / Tests / Fixtures / tests / in.test
1 --TEST--
2 Twig supports the in operator
3 --TEMPLATE--
4 {% if bar in foo %}
5 TRUE
6 {% endif %}
7 {% if not (bar in foo) %}
8 {% else %}
9 TRUE
10 {% endif %}
11 {% if bar not in foo %}
12 {% else %}
13 TRUE
14 {% endif %}
15 {% if 'a' in bar %}
16 TRUE
17 {% endif %}
18 {% if 'c' not in bar %}
19 TRUE
20 {% endif %}
21 {% if '' in bar %}
22 TRUE
23 {% endif %}
24 {% if '' in '' %}
25 TRUE
26 {% endif %}
27 {% if '0' not in '' %}
28 TRUE
29 {% endif %}
30 {% if 'a' not in '0' %}
31 TRUE
32 {% endif %}
33 {% if '0' in '0' %}
34 TRUE
35 {% endif %}
36
37 {{ false in [0, 1] ? 'TRUE' : 'FALSE' }}
38 {{ true in [0, 1] ? 'TRUE' : 'FALSE' }}
39 {{ '0' in [0, 1] ? 'TRUE' : 'FALSE' }}
40 {{ '' in [0, 1] ? 'TRUE' : 'FALSE' }}
41 {{ 0 in ['', 1] ? 'TRUE' : 'FALSE' }}
42
43 {{ '' in 'foo' ? 'TRUE' : 'FALSE' }}
44 {{ 0 in 'foo' ? 'TRUE' : 'FALSE' }}
45 {{ false in 'foo' ? 'TRUE' : 'FALSE' }}
46 {{ false in '100' ? 'TRUE' : 'FALSE' }}
47 {{ true in '100' ? 'TRUE' : 'FALSE' }}
48
49 {{ [] in [true, false] ? 'TRUE' : 'FALSE' }}
50 {{ [] in [true, ''] ? 'TRUE' : 'FALSE' }}
51 {{ [] in [true, []] ? 'TRUE' : 'FALSE' }}
52
53 {{ resource ? 'TRUE' : 'FALSE' }}
54 {{ resource in 'foo'~resource ? 'TRUE' : 'FALSE' }}
55 {{ object in 'stdClass' ? 'TRUE' : 'FALSE' }}
56 {{ [] in 'Array' ? 'TRUE' : 'FALSE' }}
57 {{ dir_object in 'foo'~dir_object ? 'TRUE' : 'FALSE' }}
58
59 {{ ''~resource in resource ? 'TRUE' : 'FALSE' }}
60 {{ 'stdClass' in object ? 'TRUE' : 'FALSE' }}
61 {{ 'Array' in [] ? 'TRUE' : 'FALSE' }}
62 {{ ''~dir_object in dir_object ? 'TRUE' : 'FALSE' }}
63
64 {{ resource in [''~resource] ? 'TRUE' : 'FALSE' }}
65 {{ resource in [resource + 1 - 1] ? 'TRUE' : 'FALSE' }}
66 {{ dir_object in [''~dir_object] ? 'TRUE' : 'FALSE' }}
67
68 {{ 5 in 125 ? 'TRUE' : 'FALSE' }}
69 {{ 5 in '125' ? 'TRUE' : 'FALSE' }}
70 {{ '5' in 125 ? 'TRUE' : 'FALSE' }}
71 {{ '5' in '125' ? 'TRUE' : 'FALSE' }}
72
73 {{ 5.5 in 125.5 ? 'TRUE' : 'FALSE' }}
74 {{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }}
75 {{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }}
76 --DATA--
77 return array('bar' => 'bar', 'foo' => array('bar' => 'bar'), 'dir_object' => new SplFileInfo(dirname(__FILE__)), 'object' => new stdClass(), 'resource' => opendir(dirname(__FILE__)))
78 --EXPECT--
79 TRUE
80 TRUE
81 TRUE
82 TRUE
83 TRUE
84 TRUE
85 TRUE
86 TRUE
87 TRUE
88 TRUE
89
90 TRUE
91 TRUE
92 TRUE
93 TRUE
94 TRUE
95
96 TRUE
97 FALSE
98 FALSE
99 FALSE
100 FALSE
101
102 TRUE
103 FALSE
104 TRUE
105
106 TRUE
107 FALSE
108 FALSE
109 FALSE
110 FALSE
111
112 FALSE
113 FALSE
114 FALSE
115 FALSE
116
117 FALSE
118 FALSE
119 FALSE
120
121 FALSE
122 TRUE
123 FALSE
124 TRUE
125
126 FALSE
127 TRUE
128 FALSE