• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1echo T.int-expr: test interval expressions
2
3awk=${awk-../a.out}
4
5rm -f foo
6
7cat << \EOF > prog
8NF == 0		{ next }
9$1 == "pat"	{ pattern = $2; next }
10{
11	check = ($1 ~ pattern)
12	printf("%s ~ /%s/ -> should be %d, is %d\n", $1, pattern, $2, check)
13}
14EOF
15
16cat << \EOF > foo.in
17pat	ab{0}c
18ac	1
19abc	0
20
21pat	a(b{0})c
22ac	1
23abc	0
24
25pat	ab{0}*c
26ac	1
27abc	0
28
29pat	a(b{0})*c
30ac	1
31abc	0
32
33pat	ab{0,}c
34ac	1
35abc	1
36
37pat	a(b{0,})c
38ac	1
39abc	1
40
41pat	ab{0,}*c
42ac	1
43abc	1
44
45pat	a(b{0,})*c
46ac	1
47abc	1
48
49pat	ab{1}c
50ac	0
51abc	1
52abbc	0
53
54pat	ab{1,}c
55ac	0
56abc	1
57abbc	1
58abbbc	1
59abbbbc	1
60
61pat	ab{0,1}c
62ac	1
63abc	1
64abbc	0
65
66pat	ab{0,3}c
67ac	1
68abc	1
69abbc	1
70abbbc	1
71abbbbc	0
72
73pat	ab{1,3}c
74ac	0
75abc	1
76abbc	1
77abbbc	1
78abbbbc	0
79EOF
80
81cat << \EOF > foo1
82ac ~ /ab{0}c/ -> should be 1, is 1
83abc ~ /ab{0}c/ -> should be 0, is 0
84ac ~ /a(b{0})c/ -> should be 1, is 1
85abc ~ /a(b{0})c/ -> should be 0, is 0
86ac ~ /ab{0}*c/ -> should be 1, is 1
87abc ~ /ab{0}*c/ -> should be 0, is 0
88ac ~ /a(b{0})*c/ -> should be 1, is 1
89abc ~ /a(b{0})*c/ -> should be 0, is 0
90ac ~ /ab{0,}c/ -> should be 1, is 1
91abc ~ /ab{0,}c/ -> should be 1, is 1
92ac ~ /a(b{0,})c/ -> should be 1, is 1
93abc ~ /a(b{0,})c/ -> should be 1, is 1
94ac ~ /ab{0,}*c/ -> should be 1, is 1
95abc ~ /ab{0,}*c/ -> should be 1, is 1
96ac ~ /a(b{0,})*c/ -> should be 1, is 1
97abc ~ /a(b{0,})*c/ -> should be 1, is 1
98ac ~ /ab{1}c/ -> should be 0, is 0
99abc ~ /ab{1}c/ -> should be 1, is 1
100abbc ~ /ab{1}c/ -> should be 0, is 0
101ac ~ /ab{1,}c/ -> should be 0, is 0
102abc ~ /ab{1,}c/ -> should be 1, is 1
103abbc ~ /ab{1,}c/ -> should be 1, is 1
104abbbc ~ /ab{1,}c/ -> should be 1, is 1
105abbbbc ~ /ab{1,}c/ -> should be 1, is 1
106ac ~ /ab{0,1}c/ -> should be 1, is 1
107abc ~ /ab{0,1}c/ -> should be 1, is 1
108abbc ~ /ab{0,1}c/ -> should be 0, is 0
109ac ~ /ab{0,3}c/ -> should be 1, is 1
110abc ~ /ab{0,3}c/ -> should be 1, is 1
111abbc ~ /ab{0,3}c/ -> should be 1, is 1
112abbbc ~ /ab{0,3}c/ -> should be 1, is 1
113abbbbc ~ /ab{0,3}c/ -> should be 0, is 0
114ac ~ /ab{1,3}c/ -> should be 0, is 0
115abc ~ /ab{1,3}c/ -> should be 1, is 1
116abbc ~ /ab{1,3}c/ -> should be 1, is 1
117abbbc ~ /ab{1,3}c/ -> should be 1, is 1
118abbbbc ~ /ab{1,3}c/ -> should be 0, is 0
119EOF
120
121
122$awk -f prog foo.in > foo2
123diff foo1 foo2 || echo 'BAD: T.int-expr (1)'
124rm -f prog
125