<commit_before>use v6;
use Test;

use Text::CSV;

my $input = q[[[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>] ],
          '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>] ],
          '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>] ],
          'with :skip-header, the first line is left out';

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> } ],
          'with :output<hashes>, an AoH is returned, header as hash keys';

done_testing;

# vim:ft=perl6<commit_msg>simplified 04-output.t and added 2 tests<commit_after>use v6;
use Test;

use Text::CSV;

my $input = q[[[subject,predicate,object
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),
          @AoA,
          'with no :output parameter, an AoA is returned, header included';

is_deeply Text::CSV.read($input, :output<arrays>),
          @AoA,
          'with :output<arrays>, an AoA is returned, header included';

is_deeply Text::CSV.read($input, :skip-header),
          @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>),
          @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
{'fraction_non_alphanumeric': 0.15801024140453548, 'fraction_numerical': 0.002926115581565472, 'mean_word_length': 2.8684582743988685, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6133143', 'n_tokens_mistral': 964, 'n_tokens_neox': 931, 'n_words': 223}