Skip to content

Commit 69523b2

Browse files
committed
Some tests for top-level Aho Corasick behaviour.
1 parent 2d03655 commit 69523b2

23 files changed

+478
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ SUBDIR += tests/minimise
6060
SUBDIR += tests/native
6161
SUBDIR += tests/pcre
6262
SUBDIR += tests/pcre-classes
63+
SUBDIR += tests/pcre-ac
6364
SUBDIR += tests/pcre-anchor
6465
SUBDIR += tests/pcre-repeat
6566
SUBDIR += tests/pred

tests/pcre-ac/Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.include "../../share/mk/top.mk"
2+
3+
TEST.tests/pcre-ac != ls -1 tests/pcre-ac/out*-*.fsm
4+
TEST_SRCDIR.tests/pcre-ac = tests/pcre-ac
5+
TEST_OUTDIR.tests/pcre-ac-anchored = ${BUILD}/tests/pcre-ac-anchored
6+
TEST_OUTDIR.tests/pcre-ac-unanchored = ${BUILD}/tests/pcre-ac-unanchored
7+
8+
DIR += ${TEST_OUTDIR.tests/pcre-ac-anchored}
9+
DIR += ${TEST_OUTDIR.tests/pcre-ac-unanchored}
10+
11+
RE=${BUILD}/bin/re
12+
13+
.for n in ${TEST.tests/pcre-ac:T:Mout*-anchored.fsm:R:C/^out//:C/-anchored$//}
14+
15+
${TEST_OUTDIR.tests/pcre-ac-anchored}/got${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
16+
${RE} -b -r pcre -py ${.ALLSRC:M*.re} \
17+
> $@
18+
19+
${TEST_OUTDIR.tests/pcre-ac-anchored}/nfa${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
20+
${RE} -b -r pcre -n -py ${.ALLSRC:M*.re} \
21+
> $@
22+
23+
${TEST_OUTDIR.tests/pcre-ac-anchored}/res${n}: \
24+
${TEST_SRCDIR.tests/pcre-ac}/out${n}-anchored.fsm \
25+
${TEST_OUTDIR.tests/pcre-ac-anchored}/got${n}.fsm
26+
27+
FSMTEST_RESULT += ${TEST_OUTDIR.tests/pcre-ac-anchored}/res${n}
28+
29+
.endfor
30+
31+
# note the absence of -b here
32+
.for n in ${TEST.tests/pcre-ac:T:Mout*-unanchored.fsm:R:C/^out//:C/-unanchored$//}
33+
34+
${TEST_OUTDIR.tests/pcre-ac-unanchored}/got${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
35+
${RE} -r pcre -py ${.ALLSRC:M*.re} \
36+
> $@
37+
38+
${TEST_OUTDIR.tests/pcre-ac-unanchored}/nfa${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
39+
${RE} -r pcre -n -py ${.ALLSRC:M*.re} \
40+
> $@
41+
42+
${TEST_OUTDIR.tests/pcre-ac-unanchored}/res${n}: \
43+
${TEST_SRCDIR.tests/pcre-ac}/out${n}-unanchored.fsm \
44+
${TEST_OUTDIR.tests/pcre-ac-unanchored}/got${n}.fsm
45+
46+
FSMTEST_RESULT += ${TEST_OUTDIR.tests/pcre-ac-unanchored}/res${n}
47+
48+
.endfor
49+

tests/pcre-ac/in1.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a|ab|abc|abcd|abcde|abcdef|abcdefg|abcdefgh|abcdefghi

tests/pcre-ac/in2.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abcdef|xyzabc|azbycz|xaybzc|fedcba

tests/pcre-ac/in3.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abcdef|xyzabc|abcdefef|xyzabcef|fcdef

tests/pcre-ac/in4.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(?i)abcdef|xyzabc|abcdefef|xyzabcef|fcdef

tests/pcre-ac/in5.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
^(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef)$

tests/pcre-ac/in6.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
^.*(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef).*$

tests/pcre-ac/in7.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.*(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef).*

tests/pcre-ac/out1-anchored.fsm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
0 -> 1 "a";
3+
1 -> 2 "b";
4+
2 -> 3 "c";
5+
3 -> 4 "d";
6+
4 -> 5 "e";
7+
5 -> 6 "f";
8+
6 -> 7 "g";
9+
7 -> 8 "h";
10+
8 -> 9 "i";
11+
12+
start: 0;
13+
end: 1, 1, 2, 3, 4, 5, 6, 7, 8, 9;

0 commit comments

Comments
 (0)