-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathant.test.mk
executable file
·243 lines (192 loc) · 3.42 KB
/
ant.test.mk
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#
# Test Driver for Anthony's Grep
#
# Public Domain 1992, 1993 by Anthony Howe. No warranty.
#
SHELL=/bin/sh
PRG=./ag
all: ${PRG} char word anchor literal wild closure option branch sub class
#
# Built the entry
#
${PRG}: ag.c
${CC} ${CFLAGS} -o ${PRG} ag.c
clean:
rm ${PRG}
#
# Test simple text patterns without the use of meta characters.
#
empty:
$(PRG) '' ant.test.mk
char:
$(PRG) 'q' ant.test.mk
word:
$(PRG) 'simple' ant.test.mk
#
# Test meta characters.
#
anchor: anchor1 anchor2 anchor3 anchor4 anchor5
anchor1:
$(PRG) '^anchor1' ant.test.mk
anchor2:
$(PRG) 'Grep$$' ant.test.mk
#
# Find all empty lines.
#
anchor3:
$(PRG) '^$$' ant.test.mk
#
# This is valid but will never match.
#
anchor4:
-$(PRG) 'x^a' ant.test.mk
#
# This is valid but will never match.
#
anchor5:
-$(PRG) 'mk$$x' ant.test.mk
literal: literal1 literal2
#
# Every line with a dollar-sign.
#
literal1:
$(PRG) '\$$' ant.test.mk
#
# Every line with a backslash.
#
literal2:
$(PRG) '\\' ant.test.mk
#
# wild #1#
# wild #a#
# wild #%#
#
wild:
$(PRG) '#.#' ant.test.mk
#
# closure !!
# closure !x!
# closure !xxxxxx!
#
closure:
$(PRG) 'closure !x*!' ant.test.mk
#
# option ++
# option +a+
# option +b+
# option +c+
# option +abc+
#
option: option1 option2
option1:
$(PRG) '+b?+' ant.test.mk
option2:
$(PRG) '+.?+' ant.test.mk
branch: branch1 branch2 branch3 branch4 branch5 branch6
branch1:
$(PRG) 'q|simple' ant.test.mk
#
# This pattern should be the same as '(^all)|(Public)|(Grep$)'.
#
branch2:
$(PRG) '^all|Public|Grep$$' ant.test.mk
#
# This pattern should generate the same results as branch2.
#
branch3:
$(PRG) 'Grep$$|^all|Public' ant.test.mk
#
# Null expression between start of pattern and vertical-line.
#
branch4:
$(PRG) '|Grep' ant.test.mk
#
# Null expression between vertical-line and end of pattern.
#
branch5:
$(PRG) 'Grep|' ant.test.mk
#
# Null expression between vertical-line and vertical-line.
#
branch6:
$(PRG) 'all||Grep' ant.test.mk
#
# sub aabcbcbcxx
# sub aagxx
# sub aaggxx
# sub aadddxx
# sub aaxx
#
sub: sub0 sub1 sub2 sub3 sub4 sub5 lparen1 lparen2 rparen1 rparen2
#
# Null sub-expressions.
#
sub0:
$(PRG) 's()u()b()' ant.test.mk
sub1:
$(PRG) '#(1|%)#' ant.test.mk
sub2:
$(PRG) 'aa((bc)*|g)xx' ant.test.mk
#
# Null expression between the left-parenthesis and the vertical-line.
#
sub3:
$(PRG) '#(|1)#' ant.test.mk
#
# Null expression between the vertical-line and the right-parenthesis.
#
sub4:
$(PRG) '#(1|)#' ant.test.mk
#
# Null expression between the vertical-line and the right-parenthesis.
#
sub5:
$(PRG) '#(%||1)#' ant.test.mk
#
# Missing left-parenthesis generates an error.
#
lparen1:
-$(PRG) 'left ( only' ant.test.mk
lparen2:
$(PRG) 'left \( only' ant.test.mk
#
# Right-parenthesis without preceding left parenthesis should be a literal.
#
rparen1:
-$(PRG) 'right ) only' ant.test.mk
rparen2:
$(PRG) 'right \) only' ant.test.mk
#
# 12345678
# -----------------
# =0= 1 45
# =1= 2 45 78
# =2= 2 45
# =3= 2 45 78
# =4= 2 45
# =5= 2 45
# =6= 2 45
# =7= 2 45
# =8= 2 45
# =9= 1 45
# =]= 23 6
# =-= 2 4 678
# = = 2 4 6
#
class: class1 class2 class3 class4 class5 class6 class7 class8
class1:
$(PRG) '=[09]=' ant.test.mk
class2:
$(PRG) '=[^09]=' ant.test.mk
class3:
$(PRG) '=[]]=' ant.test.mk
class4:
$(PRG) '=[^]]=' ant.test.mk
class5:
$(PRG) '=[0-9]=' ant.test.mk
class6:
$(PRG) '=[^0-9]=' ant.test.mk
class7:
-$(PRG) '=[3-1]=' ant.test.mk
class8:
$(PRG) '=[-13]=' ant.test.mk