summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/it_pipe.t16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/it_pipe.t b/test/it_pipe.t
index 0a36d1c..106d372 100755
--- a/test/it_pipe.t
+++ b/test/it_pipe.t
@@ -31,6 +31,22 @@ is(iterator_to_array((new it_pipe(['data' => ["a b\tb", "1\t2"]]))->cols('c')),
# askey()
is(json_encode((new it_pipe(['data' => "a\nb\n"]))->askey()), '{"a":true,"b":true}');
+# keyval()
+is(json_encode((new it_pipe(['data' => "a\tA\nb\tB\n"]))->keyval()), '{"a":"A","b":"B"}');
+is(json_encode((new it_pipe(['data' => "a,A\nb,B\n"]))->keyval(",")), '{"a":"A","b":"B"}');
+
+# swap()
+is(json_encode((new it_pipe(['data' => "a\tA\nb\tB\n"]))->swap()->lines), '["A\ta","B\tb"]');
+is(json_encode((new it_pipe(['data' => "a,A\nb,B\n"]))->swap(',')->lines), '["A,a","B,b"]');
+
+# cut()
+is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('0,2')->lines), '["a\t1","b\t2"]');
+is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('2,0')->lines), '["1\ta","2\tb"]');
+is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('1')->lines), '["A","B"]');
+is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('0,2', ',')->lines), '["a,1","b,2"]');
+is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('2,0', ',')->lines), '["1,a","2,b"]');
+is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('1', ',')->lines), '["A","B"]');
+
# __call() generic funcs
is((new it_pipe(['data' => [" a a "]]))->trim()->lines[0], "a a");
is((new it_pipe(['data' => [" a a "]]))->it__match('\w', ['all' => true])->lines[0], ["a", "a"], "test argument in second pos");