<commit_before>#!perl

use strict;
use warnings;
use lib 't';

use Test::More;

use Carp qw(croak);
use File::Temp;

use File::Slurp qw( read_file );

use App::Ack::Filter::Default;

sub test_loader {
    my $name = pop if @_ % 2;
    my %opts = @_;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my ( $env, $argv, $expected_opts, $expected_targets ) =
        delete @opts{qw/env argv expected_opts expected_targets/};

    $env  = '' unless defined $env;
    $argv = [] unless defined $argv;

    my @files = map {
        $opts{$_}
    } sort {
        my ( $a_end ) = $a =~ /(\d+)/;
        my ( $b_end ) = $b =~ /(\d+)/;

        $a_end <=> $b_end;
    } grep { /^file\d+/ } keys %opts;
    foreach my $contents (@files) {
        my $file = File::Temp->new;
        print {$file} $contents;
        close $file;
    }

    my ( $got_opts, $got_targets );

    do {
        local $ENV{'ACK_OPTIONS'} = $env;
        local @ARGV;

        my @arg_sources = (
            ARGV => $argv,
            map { $_ => scalar read_file($_), } @files,
        );

        $got_opts    = App::Ack::ConfigLoader::process_args( @arg_sources );
        $got_targets = [ @ARGV ];
    };

    is_deeply( $got_opts, $expected_opts, 'Options match' )       or diag 'Options did not match';
    is_deeply( $got_targets, $expected_targets, 'Targets match' ) or diag 'Targets did not match';
}

my %defaults = (
    after_context     => undef,
    all               => undef,
    before_context    => undef,
    'break'           => undef,
    color             => undef,
    column            => undef,
    count             => undef,
    f                 => undef,
    filters           => [ App::Ack::Filter::Default->new ],
    flush             => undef,
    follow            => undef,
    G                 => undef,<commit_msg>fix critic dirtiness<commit_after>#!perl

use strict;
use warnings;
use lib 't';

use Test::More;

use Carp qw(croak);
use File::Temp;

use File::Slurp qw( read_file );

use App::Ack::Filter::Default;

sub test_loader {
    pop if @_ % 2;

    my %opts = @_;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my ( $env, $argv, $expected_opts, $expected_targets ) =
        delete @opts{qw/env argv expected_opts expected_targets/};

    $env  = '' unless defined $env;
    $argv = [] unless defined $argv;

    my @files = map {
        $opts{$_}
    } sort {
        my ( $a_end ) = $a =~ /(\d+)/;
        my ( $b_end ) = $b =~ /(\d+)/;

        $a_end <=> $b_end;
    } grep { /^file\d+/ } keys %opts;
    foreach my $contents (@files) {
        my $file = File::Temp->new;
        print {$file} $contents;
        close $file;
    }

    my ( $got_opts, $got_targets );

    do {
        local $ENV{'ACK_OPTIONS'} = $env;
        local @ARGV;

        my @arg_sources = (
            ARGV => $argv,
            map { $_ => scalar read_file($_), } @files,
        );

        $got_opts    = App::Ack::ConfigLoader::process_args( @arg_sources );
        $got_targets = [ @ARGV ];
    };

    is_deeply( $got_opts, $expected_opts, 'Options match' )       or diag 'Options did not match';
    is_deeply( $got_targets, $expected_targets, 'Targets match' ) or diag 'Targets did not match';

    return;
}

my %defaults = (
    after_context     => undef,
    all               => undef,
    before_context    => undef,
    'break'           => undef,
    color             => undef,
    column            => undef,
    count             => undef,
    f                 => undef,
    filters           => [ App::Ack::Filter::Default->new ],
    flush             => undef,
    follow            => undef,
    G                 => undef,
{'fraction_non_alphanumeric': 0.15482646420824295, 'fraction_numerical': 0.0010845986984815619, 'mean_word_length': 1.8530549110595513, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '576098', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1209, 'n_words': 306}