--TEST--
"filter" filter
--TEMPLATE--
{% set offset = 3 %}

{% for k, v in [1, 5, 3, 4, 5]|filter((v) => v > offset) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in {a: 1, b: 2, c: 5, d: 8}|filter(v => v > offset) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in {a: 1, b: 2, c: 5, d: 8}|filter((v, k) => (v > offset) and (k != "d")) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in [1, 5, 3, 4, 5]|filter(v => v > offset) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in it|filter((v) => v > offset) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in ita|filter(v => v > offset) -%}
    {{ k }} = {{ v }}
{% endfor %}

{% for k, v in xml|filter(x => true) %}
{{ k }}/{{ v }}
{% endfor %}

{# we can iterate more than once #}
{% for k, v in xml|filter(x => true) %}
{{ k }}/{{ v }}
{% endfor %}

{% set coll = ['a', 'b']|filter(v => v is same as('a')) %}
{% if coll|length > 0 %}
    {{- coll|join(', ') }}
{% endif %}
--DATA--
return [
    'it' => new \ArrayIterator(['a' => 1, 'b' => 2, 'c' => 5, 'd' => 8]),
    'ita' => new IteratorAggregateStub(['a' => 1, 'b' => 2, 'c' => 5, 'd' => 8]),
    'xml' => new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><doc><elem>foo</elem><elem>bar</elem><elem>baz</elem></doc>'),
]
--EXPECT--
1 = 5
3 = 4
4 = 5

c = 5
d = 8

c = 5

1 = 5
3 = 4
4 = 5

c = 5
d = 8

c = 5
d = 8

elem/foo
elem/bar
elem/baz

elem/foo
elem/bar
elem/baz

a
