-
Notifications
You must be signed in to change notification settings - Fork 137
/
ack-output.t
84 lines (62 loc) · 1.77 KB
/
ack-output.t
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!perl -T
use warnings;
use strict;
use Test::More tests => 12;
use lib 't';
use Util;
use File::Next;
prep_environment();
ARG: {
my @expected = (
'Sink, swim, go down with the ship'
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( swim --output=$_ );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Matching line' );
}
MATCH: {
my @expected = (
'swim'
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( swim --output=$& );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Part of a line matching pattern' );
}
PREMATCH: {
my @expected = (
'Sink, '
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( swim --output=$` );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Part of a line preceding match' );
}
POSTMATCH: {
my @expected = (
', go down with the ship'
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( swim --output=$' );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Part of a line that follows match' );
}
SUBPATTERN_MATCH: {
my @expected = (
'Sink-swim-ship'
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( ^(Sink).+(swim).+(ship)$ --output=$1-$2-$3 );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Capturing parentheses match' );
}
INPUT_LINE_NUMBER: {
my @expected = (
'line:3'
);
my @files = qw( t/text/freedom-of-choice.txt );
my @args = qw( swim --output=line:$. );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Line number' );
}