@@ -10,283 +10,6 @@ use Util;
10
10
11
11
prep_environment();
12
12
13
- DOLLAR_1: {
14
- my @files = qw( t/text/ ) ;
15
- my @args = qw/ --output=x$1x free(\\S+) --sort-files / ;
16
-
17
- my @target_file = map { reslash($_ ) } qw(
18
- t/text/bill-of-rights.txt
19
- t/text/gettysburg.txt
20
- ) ;
21
- my @expected = (
22
- " $target_file [0]:4:xdomx" ,
23
- " $target_file [1]:23:xdomx" ,
24
- );
25
-
26
- ack_sets_match( [ @args , @files ], \@expected , ' Find all the things with --output function' );
27
- }
28
-
29
-
30
- DOLLAR_UNDERSCORE: {
31
- my @expected = line_split( <<'HERE' );
32
- shall have a new birth of freedom -- and that government of the people,xshall have a new birth of freedom -- and that government of the people,
33
- HERE
34
-
35
- my @files = qw( t/text/gettysburg.txt ) ;
36
- my @args = qw( free --output=$_x$_ ) ;
37
- my @results = run_ack( @args , @files );
38
-
39
- lists_match( \@results , \@expected , ' Matching line' );
40
- }
41
-
42
-
43
- ARG_MULTIPLE_FILES: {
44
- # Note the first line is there twice because it matches twice.
45
- my @expected = line_split( <<'HERE' );
46
- or prohibiting the free exercise thereof; or abridging the freedom of
47
- or prohibiting the free exercise thereof; or abridging the freedom of
48
- A well regulated Militia, being necessary to the security of a free State,
49
- Number of free Persons, including those bound to Service for a Term
50
- shall have a new birth of freedom -- and that government of the people,
51
- HERE
52
-
53
- my @files = qw( t/text ) ;
54
- my @args = qw( free --sort-files -h --output=$_ ) ;
55
- my @results = run_ack( @args , @files );
56
-
57
- lists_match( \@results , \@expected , ' Matching line' );
58
- }
59
-
60
-
61
- # Find a match in multiple files, and output it in double quotes.
62
- DOUBLE_QUOTES: {
63
- my @files = qw( t/text/ ) ;
64
- my @args = ( ' --output="$1"' , ' (free\\ w*)' , ' --sort-files' );
65
-
66
- my @target_file = map { reslash($_ ) } qw(
67
- t/text/bill-of-rights.txt
68
- t/text/constitution.txt
69
- t/text/gettysburg.txt
70
- ) ;
71
- my @expected = (
72
- qq{ $target_file [0]:4:"free"} ,
73
- qq{ $target_file [0]:4:"freedom"} ,
74
- qq{ $target_file [0]:10:"free"} ,
75
- qq{ $target_file [1]:32:"free"} ,
76
- qq{ $target_file [2]:23:"freedom"} ,
77
- );
78
-
79
- ack_sets_match( [ @args , @files ], \@expected , ' Find all the things with --output function' );
80
- }
81
-
82
-
83
- MATCH: {
84
- my @expected = (
85
- ' free'
86
- );
87
-
88
- my @files = qw( t/text/gettysburg.txt ) ;
89
- my @args = qw( free --output=$& ) ;
90
- my @results = run_ack( @args , @files );
91
-
92
- lists_match( \@results , \@expected , ' Part of a line matching pattern' );
93
- }
94
-
95
- MATCH_MULTIPLE_FILES: {
96
- my @expected = line_split( <<'HERE' );
97
- t/text/bill-of-rights.txt:4:free
98
- t/text/bill-of-rights.txt:4:free
99
- t/text/bill-of-rights.txt:10:free
100
- t/text/constitution.txt:32:free
101
- t/text/gettysburg.txt:23:free
102
- HERE
103
-
104
- my @files = qw ( t/text ) ;
105
- my @args = qw( free --sort-files --output=$& ) ;
106
- my @results = run_ack( @args , @files );
107
-
108
- lists_match( \@results , \@expected , ' Part of a line matching pattern' );
109
- }
110
-
111
- PREMATCH: {
112
- # No HEREDOC here since we do not want our editor/IDE messing with trailing whitespace.
113
- my @expected = (
114
- ' shall have a new birth of '
115
- );
116
-
117
- my @files = qw( t/text/gettysburg.txt ) ;
118
- my @args = qw( freedom --output=$` ) ;
119
- my @results = run_ack( @args , @files );
120
-
121
- lists_match( \@results , \@expected , ' Part of a line preceding match' );
122
- }
123
-
124
- PREMATCH_MULTIPLE_FILES: {
125
- # No HEREDOC here since we do not want our editor/IDE messing with trailing whitespace.
126
- my @expected = (
127
- ' or prohibiting the free exercise thereof; or abridging the ' ,
128
- ' shall have a new birth of '
129
- );
130
-
131
- my @files = qw( t/text/) ;
132
- my @args = qw( freedom -h --sort-files --output=$` ) ;
133
- my @results = run_ack( @args , @files );
134
-
135
- lists_match( \@results , \@expected , ' Part of a line preceding match' );
136
- }
137
-
138
- POSTMATCH: {
139
- my @expected = split ( / \n / , <<'HERE' );
140
- -- and that government of the people,
141
- HERE
142
-
143
- my @files = qw( t/text/gettysburg.txt ) ;
144
- my @args = qw( freedom --output=$' ) ;
145
- my @results = run_ack( @args , @files );
146
-
147
- lists_match( \@results , \@expected , ' Part of a line that follows match' );
148
- }
149
-
150
- POSTMATCH_MULTIPLE_FILES: {
151
- my @expected = line_split( <<'HERE' );
152
- of
153
- -- and that government of the people,
154
- HERE
155
-
156
- my @files = qw( t/text/ ) ;
157
- my @args = qw( freedom -h --sort-files --output=$' ) ;
158
- my @results = run_ack( @args , @files );
159
-
160
- lists_match( \@results , \@expected , ' Part of a line that follows match' );
161
- }
162
-
163
- SUBPATTERN_MATCH: {
164
- my @expected = (
165
- ' love-God-Montresor'
166
- );
167
-
168
- my @files = qw( t/text/amontillado.txt ) ;
169
- my @args = qw( (love).+(God).+(Montresor) --output=$1-$2-$3 ) ;
170
- my @results = run_ack( @args , @files );
171
-
172
- lists_match( \@results , \@expected , ' Capturing parentheses match' );
173
- }
174
-
175
- SUBPATTERN_MATCH_MULTIPLE_FILES: {
176
- my @expected = line_split( <<'HERE' );
177
- the-free-exercise
178
- a-free-State
179
- of-free-Persons
180
- HERE
181
-
182
- my @files = qw( t/text/ ) ;
183
- my @args = qw( (\w +)\s(free)\s(\w +) -h --sort-files --output=$1-$2-$3 ) ;
184
- my @results = run_ack( @args , @files );
185
-
186
- lists_match( \@results , \@expected , ' Capturing parentheses match' );
187
- }
188
-
189
- INPUT_LINE_NUMBER: {
190
- my @expected = (
191
- ' line:15'
192
- );
193
-
194
- my @files = qw( t/text/bill-of-rights.txt ) ;
195
- my @args = qw( quartered --output=line:$. ) ;
196
- my @results = run_ack( @args , @files );
197
-
198
- lists_match( \@results , \@expected , ' Line number' );
199
- }
200
-
201
- INPUT_LINE_NUMBER_MULTIPLE_FILES: {
202
- my @expected = line_split( <<'HERE' );
203
- t/text/bill-of-rights.txt:4:line:4
204
- t/text/bill-of-rights.txt:4:line:4
205
- t/text/bill-of-rights.txt:10:line:10
206
- t/text/constitution.txt:32:line:32
207
- t/text/gettysburg.txt:23:line:23
208
- HERE
209
-
210
- my @files = qw( t/text/ ) ;
211
- my @args = qw( free --sort-files --output=line:$. ) ;
212
- my @results = run_ack( @args , @files );
213
-
214
- lists_match( \@results , \@expected , ' Line number' );
215
- }
216
-
217
- LAST_PAREN_MATCH: {
218
- my @expected = line_split( <<'HERE' );
219
- t/text/amontillado.txt:124:love
220
- t/text/amontillado.txt:309:love
221
- t/text/amontillado.txt:311:love
222
- t/text/constitution.txt:267:hate
223
- HERE
224
-
225
- my @files = qw( t/text/ ) ;
226
- my @args = qw( (love)|(hate) --sort-files --output=$+ ) ;
227
- my @results = run_ack( @args , @files );
228
-
229
- lists_match( \@results , \@expected , ' Last paren match' );
230
- }
231
-
232
-
233
- COMBOS_1: {
234
- my @expected = line_split( <<'HERE' );
235
- t/text/amontillado.txt:124:love-124-d; you are happy,
236
- t/text/amontillado.txt:309:love-309- of God, Montresor!"
237
- t/text/amontillado.txt:311:love-311- of God!"
238
- t/text/constitution.txt:267:hate-267-ver, from any King, Prince, or foreign State.
239
- HERE
240
-
241
- my @files = qw( t/text/ ) ;
242
- my @args = qw( (love)|(hate) --sort-files --output=$+-$.-$' ) ;
243
- my @results = run_ack( @args , @files );
244
-
245
- lists_match( \@results , \@expected , ' Combos 1' );
246
- }
247
-
248
-
249
- COMBOS_2: {
250
- my @expected = line_split( <<'HERE' );
251
- t/text/amontillado.txt:124:happy-happy-happy
252
- t/text/raven.txt:73:happy-happy-happy
253
- HERE
254
-
255
- my @files = qw( t/text/ ) ;
256
- my @args = qw( (happy) --sort-files -i --output=$1-$&-$1 ) ;
257
- my @results = run_ack( @args , @files );
258
-
259
- lists_match( \@results , \@expected , ' Combos 2' );
260
- }
261
-
262
-
263
- COMBOS_3: {
264
- my @expected = line_split( <<'HERE' );
265
- t/text/amontillado.txt:124:precious. You are rich, respected, admired, beloved; you are ---,--happy
266
- t/text/raven.txt:73:Caught from some un--- master whom unmerciful Disaster--happy
267
- HERE
268
-
269
- my @files = qw( t/text/ ) ;
270
- my @args = qw( (happy) --sort-files -i --output=$`---$'--$+ ) ;
271
- my @results = run_ack( @args , @files );
272
-
273
- lists_match( \@results , \@expected , ' Combos 2' );
274
- }
275
-
276
-
277
- NUMERIC_SUBSTITUTIONS: {
278
- # Make sure that substitutions don't affect future substitutions.
279
- my @expected = line_split( <<'HERE' );
280
- t/text/constitution.txt:269:Section 10 on line 269
281
- HERE
282
-
283
- my @files = qw( t/text/bill-of-rights.txt t/text/constitution.txt ) ;
284
- my @args = ( ' (\d\d)' , ' --output=Section $1 on line $.' );
285
- my @results = run_ack( @args , @files );
286
-
287
- lists_match( \@results , \@expected , ' Numeric substitutions' );
288
- }
289
-
290
13
291
14
CHARACTER_SUBSTITUTIONS: {
292
15
# Make sure that substitutions don't affect future substitutions.
0 commit comments