File: illegal-regex.t

package info (click to toggle)
ack 2.24-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,704 kB
  • sloc: perl: 8,590; ansic: 21; fortran: 11; makefile: 5; sh: 5
file content (37 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!perl -T

use warnings;
use strict;

use Test::More;

use lib 't';
use Util;

prep_environment();

# test for behavior with illegal regexes
my @tests = (
    [ 'illegal pattern',  '?foo', 't/' ],
    [ 'illegal -g regex', '-g', '?foo', 't/' ],
);

plan tests => scalar @tests;

for ( @tests ) {
    test_ack_with( @{$_} );
}

sub test_ack_with {
    my $testcase = shift;
    my @args     = @_;

    return subtest "test_ack_with( $testcase: @args )" => sub {
        my ( $stdout, $stderr ) = run_ack_with_stderr( @args );

        is_empty_array( $stdout, "No STDOUT for $testcase" );
        is( scalar @{$stderr}, 2, "Two lines of STDERR for $testcase" );
        like( $stderr->[0], qr/Invalid regex/, "Correct ack error message for $testcase" );
        like( $stderr->[1], qr/^\s+Quantifier follows nothing/, "Correct type of error for $testcase" );
    };
}