Skip to content
Browse files

simplified 04-output.t and added 2 tests

  • Loading branch information...
1 parent 1e15984 commit 3577f655ac87b573ed8967ad7a3723ba40984cad @masak committed
Showing with 21 additions and 14 deletions.
  1. +21 −14 t/04-output.t
View
35 t/04-output.t
@@ -8,32 +8,39 @@ dog,bites,man
child,gets,cake
arthur,extracts,excalibur]]];
+my @AoA = [<subject predicate object>],
+ [<dog bites man>],
+ [<child gets cake>],
+ [<arthur extracts excalibur>];
+
is_deeply Text::CSV.read($input),
- [ [<subject predicate object>],
- [<dog bites man>],
- [<child gets cake>],
- [<arthur extracts excalibur>] ],
+ @AoA,
'with no :output parameter, an AoA is returned, header included';
is_deeply Text::CSV.read($input, :output<arrays>),
- [ [<subject predicate object>],
- [<dog bites man>],
- [<child gets cake>],
- [<arthur extracts excalibur>] ],
+ @AoA,
'with :output<arrays>, an AoA is returned, header included';
is_deeply Text::CSV.read($input, :skip-header),
- [ [<dog bites man>],
- [<child gets cake>],
- [<arthur extracts excalibur>] ],
+ @AoA[1..^*],
'with :skip-header, the first line is left out';
+my @AoH = { :subject<dog>, :predicate<bites>, :object<man> },
+ { :subject<child>, :predicate<gets>, :object<cake> },
+ { :subject<arthur>, :predicate<extracts>, :object<excalibur> };
+
is_deeply Text::CSV.read($input, :output<hashes>),
- [ { :subject<dog>, :predicate<bites>, :object<man> },
- { :subject<child>, :predicate<gets>, :object<cake> },
- { :subject<arthur>, :predicate<extracts>, :object<excalibur> } ],
+ @AoH,
'with :output<hashes>, an AoH is returned, header as hash keys';
+is_deeply Text::CSV.read($input, :output<hashes>, :!skip-header),
+ @AoH,
+ 'with :output<hashes>, turning :skip-header off is a no-op';
+
+is_deeply Text::CSV.read($input, :output<hashes>, :skip-header),
+ @AoH,
+ 'with :output<hashes>, turning :skip-header on is a no-op';
+
done_testing;
# vim:ft=perl6

0 comments on commit 3577f65

Please sign in to comment.
Something went wrong with that request. Please try again.