From d219344eedc4e62e2407013bd3bb347139c44e76 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 2 May 2024 19:03:47 +0200 Subject: test it::filter and it::grep --- test/it_pipe.t | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/it_pipe.t b/test/it_pipe.t index 734b7fa..72847d1 100755 --- a/test/it_pipe.t +++ b/test/it_pipe.t @@ -9,6 +9,14 @@ is(it::pipe('echo {0}{1}', "f", "oo")->lines(), ["foo"]); is(it::pipe('echo {f}', ['f' => 1, 'f' => 2])->lines(), [2]); is(it::pipe(['foo'])->lines(), ["foo"]); +foreach(it::pipe(['a','b','a']) as $i) $x1 .= $i; +is($x1, "aba"); +foreach(it::pipe(['a','b','a'])->filter(fn($x) => $x == 'a') as $i) $x2 .= $i; +is($x2, "aa"); +foreach(it::pipe(['a','b','a'])->grep('a') as $i) $x3 .= $i; +is($x3, "aa"); + + # csv() is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv()), '[{"a":"1","b":"2"}]'); is(json_encode((new it_pipe(['data' => ["a;b", "1;2"]]))->csv()), '[{"a":"1","b":"2"}]'); -- cgit v1.2.3