diff options
author | Urban Müller | 2024-05-02 19:03:47 +0200 |
---|---|---|
committer | Urban Müller | 2024-05-02 19:05:32 +0200 |
commit | d219344eedc4e62e2407013bd3bb347139c44e76 (patch) | |
tree | e8d2bb28ec121b0dec17489326699956ac61264c | |
parent | a257a34448c1553d61c3ca74859a91eebe2aeb7f (diff) | |
download | itools-d219344eedc4e62e2407013bd3bb347139c44e76.tar.gz itools-d219344eedc4e62e2407013bd3bb347139c44e76.tar.bz2 itools-d219344eedc4e62e2407013bd3bb347139c44e76.zip |
test it::filter and it::grep
-rwxr-xr-x | test/it_pipe.t | 8 |
1 files changed, 8 insertions, 0 deletions
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"}]'); |