Skip to content

Commit

Permalink
Some tests for top-level Aho Corasick behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
katef committed Aug 4, 2020
1 parent b204c5e commit 93082d3
Show file tree
Hide file tree
Showing 23 changed files with 478 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SUBDIR += tests/minimise
SUBDIR += tests/native
SUBDIR += tests/pcre
SUBDIR += tests/pcre-classes
SUBDIR += tests/pcre-ac
SUBDIR += tests/pcre-anchor
SUBDIR += tests/pcre-repeat
SUBDIR += tests/pred
Expand Down
49 changes: 49 additions & 0 deletions tests/pcre-ac/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.include "../../share/mk/top.mk"

TEST.tests/pcre-ac != ls -1 tests/pcre-ac/out*-*.fsm
TEST_SRCDIR.tests/pcre-ac = tests/pcre-ac
TEST_OUTDIR.tests/pcre-ac-anchored = ${BUILD}/tests/pcre-ac-anchored
TEST_OUTDIR.tests/pcre-ac-unanchored = ${BUILD}/tests/pcre-ac-unanchored

DIR += ${TEST_OUTDIR.tests/pcre-ac-anchored}
DIR += ${TEST_OUTDIR.tests/pcre-ac-unanchored}

RE=${BUILD}/bin/re

.for n in ${TEST.tests/pcre-ac:T:Mout*-anchored.fsm:R:C/^out//:C/-anchored$//}

${TEST_OUTDIR.tests/pcre-ac-anchored}/got${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
${RE} -b -r pcre -py ${.ALLSRC:M*.re} \
> $@

${TEST_OUTDIR.tests/pcre-ac-anchored}/nfa${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
${RE} -b -r pcre -n -py ${.ALLSRC:M*.re} \
> $@

${TEST_OUTDIR.tests/pcre-ac-anchored}/res${n}: \
${TEST_SRCDIR.tests/pcre-ac}/out${n}-anchored.fsm \
${TEST_OUTDIR.tests/pcre-ac-anchored}/got${n}.fsm

FSMTEST_RESULT += ${TEST_OUTDIR.tests/pcre-ac-anchored}/res${n}

.endfor

# note the absence of -b here
.for n in ${TEST.tests/pcre-ac:T:Mout*-unanchored.fsm:R:C/^out//:C/-unanchored$//}

${TEST_OUTDIR.tests/pcre-ac-unanchored}/got${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
${RE} -r pcre -py ${.ALLSRC:M*.re} \
> $@

${TEST_OUTDIR.tests/pcre-ac-unanchored}/nfa${n}.fsm: ${TEST_SRCDIR.tests/pcre-ac}/in${n}.re
${RE} -r pcre -n -py ${.ALLSRC:M*.re} \
> $@

${TEST_OUTDIR.tests/pcre-ac-unanchored}/res${n}: \
${TEST_SRCDIR.tests/pcre-ac}/out${n}-unanchored.fsm \
${TEST_OUTDIR.tests/pcre-ac-unanchored}/got${n}.fsm

FSMTEST_RESULT += ${TEST_OUTDIR.tests/pcre-ac-unanchored}/res${n}

.endfor

1 change: 1 addition & 0 deletions tests/pcre-ac/in1.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a|ab|abc|abcd|abcde|abcdef|abcdefg|abcdefgh|abcdefghi
1 change: 1 addition & 0 deletions tests/pcre-ac/in2.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abcdef|xyzabc|azbycz|xaybzc|fedcba
1 change: 1 addition & 0 deletions tests/pcre-ac/in3.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abcdef|xyzabc|abcdefef|xyzabcef|fcdef
1 change: 1 addition & 0 deletions tests/pcre-ac/in4.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(?i)abcdef|xyzabc|abcdefef|xyzabcef|fcdef
1 change: 1 addition & 0 deletions tests/pcre-ac/in5.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef)$
1 change: 1 addition & 0 deletions tests/pcre-ac/in6.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^.*(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef).*$
1 change: 1 addition & 0 deletions tests/pcre-ac/in7.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.*(?:abcdef|xyzabc|abcdefef|xyzabcef|fcdef).*
13 changes: 13 additions & 0 deletions tests/pcre-ac/out1-anchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

0 -> 1 "a";
1 -> 2 "b";
2 -> 3 "c";
3 -> 4 "d";
4 -> 5 "e";
5 -> 6 "f";
6 -> 7 "g";
7 -> 8 "h";
8 -> 9 "i";

start: 0;
end: 1, 1, 2, 3, 4, 5, 6, 7, 8, 9;
27 changes: 27 additions & 0 deletions tests/pcre-ac/out1-unanchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

0 -> 0 ?;

0 -> 1 "a";
1 -> 2 "b";
2 -> 3 "c";
3 -> 4 "d";
4 -> 5 "e";
5 -> 6 "f";
6 -> 7 "g";
7 -> 8 "h";
8 -> 9 "i";

1 -> x;
2 -> x;
3 -> x;
4 -> x;
5 -> x;
6 -> x;
7 -> x;
8 -> x;
9 -> x;

x -> x ?;

start: 0;
end: x;
45 changes: 45 additions & 0 deletions tests/pcre-ac/out2-anchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

0 -> 00;
0 -> 10;
0 -> 20;
0 -> 30;
0 -> 40;

00 -> 01 "a";
01 -> 02 "b";
02 -> 03 "c";
03 -> 04 "d";
04 -> 05 "e";
05 -> 06 "f";

10 -> 11 "x";
11 -> 12 "y";
12 -> 13 "z";
13 -> 14 "a";
14 -> 15 "b";
15 -> 16 "c";

20 -> 21 "a";
21 -> 22 "z";
22 -> 23 "b";
23 -> 24 "y";
24 -> 25 "c";
25 -> 26 "z";

30 -> 31 "x";
31 -> 32 "a";
32 -> 33 "y";
33 -> 34 "b";
34 -> 35 "z";
35 -> 36 "c";

40 -> 41 "f";
41 -> 42 "e";
42 -> 43 "d";
43 -> 44 "c";
44 -> 45 "b";
45 -> 46 "a";

start: 0;
end: 06, 16, 26, 36, 46;

55 changes: 55 additions & 0 deletions tests/pcre-ac/out2-unanchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

0 -> 00;
0 -> 10;
0 -> 20;
0 -> 30;
0 -> 40;

0 -> 0 ?;

00 -> 01 "a";
01 -> 02 "b";
02 -> 03 "c";
03 -> 04 "d";
04 -> 05 "e";
05 -> 06 "f";

10 -> 11 "x";
11 -> 12 "y";
12 -> 13 "z";
13 -> 14 "a";
14 -> 15 "b";
15 -> 16 "c";

20 -> 21 "a";
21 -> 22 "z";
22 -> 23 "b";
23 -> 24 "y";
24 -> 25 "c";
25 -> 26 "z";

30 -> 31 "x";
31 -> 32 "a";
32 -> 33 "y";
33 -> 34 "b";
34 -> 35 "z";
35 -> 36 "c";

40 -> 41 "f";
41 -> 42 "e";
42 -> 43 "d";
43 -> 44 "c";
44 -> 45 "b";
45 -> 46 "a";

06 -> x;
16 -> x;
26 -> x;
36 -> x;
46 -> x;

x -> x ?;

start: 0;
end: x;

28 changes: 28 additions & 0 deletions tests/pcre-ac/out3-anchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

0 -> 01 "a";
01 -> 02 "b";
02 -> 03 "c";
03 -> 04 "d";
04 -> 05 "e";
05 -> 06 "f";
06 -> 07 "e";
07 -> 08 "f";

0 -> 10 "f";
10 -> 11 "c";
11 -> 12 "d";
12 -> 13 "e";
13 -> 14 "f";

0 -> 20 "x";
20 -> 21 "y";
21 -> 22 "z";
22 -> 23 "a";
23 -> 24 "b";
24 -> 25 "c";
25 -> 26 "e";
26 -> 27 "f";

start: 0;
end: 06, 08, 14, 25, 27;

38 changes: 38 additions & 0 deletions tests/pcre-ac/out3-unanchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

0 -> 0 ?;

0 -> 01 "a";
01 -> 02 "b";
02 -> 03 "c";
03 -> 04 "d";
04 -> 05 "e";
05 -> 06 "f";
06 -> 07 "e";
07 -> 08 "f";

0 -> 10 "f";
10 -> 11 "c";
11 -> 12 "d";
12 -> 13 "e";
13 -> 14 "f";

0 -> 20 "x";
20 -> 21 "y";
21 -> 22 "z";
22 -> 23 "a";
23 -> 24 "b";
24 -> 25 "c";
25 -> 26 "e";
26 -> 27 "f";

06 -> x;
08 -> x;
14 -> x;
25 -> x;
27 -> x;

x -> x ?;

start: 0;
end: x;

49 changes: 49 additions & 0 deletions tests/pcre-ac/out4-anchored.fsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

0 -> 01 "a";
0 -> 01 "A";
01 -> 02 "b";
01 -> 02 "B";
02 -> 03 "c";
02 -> 03 "C";
03 -> 04 "d";
03 -> 04 "D";
04 -> 05 "e";
04 -> 05 "E";
05 -> 06 "f";
05 -> 06 "F";
06 -> 07 "e";
06 -> 07 "E";
07 -> 08 "f";
07 -> 08 "F";

0 -> 10 "f";
0 -> 10 "F";
10 -> 11 "c";
10 -> 11 "C";
11 -> 12 "d";
11 -> 12 "D";
12 -> 13 "e";
12 -> 13 "E";
13 -> 14 "f";
13 -> 14 "F";

0 -> 20 "x";
0 -> 20 "X";
20 -> 21 "y";
20 -> 21 "Y";
21 -> 22 "z";
21 -> 22 "Z";
22 -> 23 "a";
22 -> 23 "A";
23 -> 24 "b";
23 -> 24 "B";
24 -> 25 "c";
24 -> 25 "C";
25 -> 26 "e";
25 -> 26 "E";
26 -> 27 "f";
26 -> 27 "F";

start: 0;
end: 06, 08, 14, 25, 27;

Loading

0 comments on commit 93082d3

Please sign in to comment.