Some more tests
This commit is contained in:
parent
9392afc74c
commit
a24320099c
12
run_tests.py
12
run_tests.py
|
@ -4,7 +4,9 @@ import unittest, subprocess, filecmp, argparse, os.path, os, shutil
|
||||||
REFERENCE_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tests")
|
REFERENCE_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tests")
|
||||||
|
|
||||||
REGEXES_DATA = [ #TODO
|
REGEXES_DATA = [ #TODO
|
||||||
[r"[a-zA-Z0-9]*"]
|
[r"[a-zA-Z0-9]*"],
|
||||||
|
[r"a", r"a|b"],
|
||||||
|
[r"a|b", r"a"],
|
||||||
]
|
]
|
||||||
|
|
||||||
def make_test(regexes, idx):
|
def make_test(regexes, idx):
|
||||||
|
@ -13,10 +15,10 @@ def make_test(regexes, idx):
|
||||||
p.communicate(bytes("\n".join(regexes), "utf-8"))
|
p.communicate(bytes("\n".join(regexes), "utf-8"))
|
||||||
self.assertEqual(0, p.returncode)
|
self.assertEqual(0, p.returncode)
|
||||||
|
|
||||||
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.re" % idx), os.path.join(data_dir, "test_%s.re" % idx)))
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.re" % idx), os.path.join(data_dir, "test_%s.re" % idx)), "The regex for testcase %s is incorrect" % idx)
|
||||||
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.enfa" % idx), os.path.join(data_dir, "test_%s.enfa" % idx)))
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.enfa" % idx), os.path.join(data_dir, "test_%s.enfa" % idx)), "The eNFA for testcase %s is incorrect" % idx)
|
||||||
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.mssc" % idx), os.path.join(data_dir, "test_%s.mssc" % idx)))
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.mssc" % idx), os.path.join(data_dir, "test_%s.mssc" % idx)), "The mssc'd DFA for testcase %s is incorrect" % idx)
|
||||||
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.min" % idx), os.path.join(data_dir, "test_%s.min" % idx)))
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.min" % idx), os.path.join(data_dir, "test_%s.min" % idx)), "The minimized DFA for testcase %s is incorrect" % idx)
|
||||||
|
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ namespace lxs {
|
||||||
std::string label = std::to_string(state);
|
std::string label = std::to_string(state);
|
||||||
s += std::to_string(state) + " [";
|
s += std::to_string(state) + " [";
|
||||||
if (state == d.starting)
|
if (state == d.starting)
|
||||||
s += "color=yellow";
|
s += "color=yellow ";
|
||||||
if (d.accepting.count(state) > 0) {
|
if (d.accepting.count(state) > 0) {
|
||||||
s += "color=green shape=doublecircle";
|
s += "color=green shape=doublecircle ";
|
||||||
label += "\\np=" + std::to_string(d.priority.find(state)->second) + "\\nac=" + d.acceptingToken.find(state)->second;
|
label += "\\np=" + std::to_string(d.priority.find(state)->second) + "\\nac=" + d.acceptingToken.find(state)->second;
|
||||||
}
|
}
|
||||||
s += " label=\"" + label + "\"]\n";
|
s += "label=\"" + label + "\"]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tmp : d.delta)
|
for (const auto& tmp : d.delta)
|
||||||
|
@ -47,12 +47,12 @@ namespace lxs {
|
||||||
std::string label = std::to_string(state);
|
std::string label = std::to_string(state);
|
||||||
s += std::to_string(state) + " [";
|
s += std::to_string(state) + " [";
|
||||||
if (state == n.starting)
|
if (state == n.starting)
|
||||||
s += "color=yellow";
|
s += "color=yellow ";
|
||||||
if (n.accepting.count(state) > 0) {
|
if (n.accepting.count(state) > 0) {
|
||||||
s += "color=green shape=doublecircle";
|
s += "color=green shape=doublecircle ";
|
||||||
label += "\\np=" + std::to_string(n.priority.find(state)->second) + "\\nac=" + n.acceptingToken.find(state)->second;
|
label += "\\np=" + std::to_string(n.priority.find(state)->second) + "\\nac=" + n.acceptingToken.find(state)->second;
|
||||||
}
|
}
|
||||||
s += " label=\"" + label + "\"]\n";
|
s += "label=\"" + label + "\"]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tmp : n.delta)
|
for (const auto& tmp : n.delta)
|
||||||
|
@ -78,12 +78,12 @@ namespace lxs {
|
||||||
std::string label = std::to_string(state);
|
std::string label = std::to_string(state);
|
||||||
s += std::to_string(state) + " [";
|
s += std::to_string(state) + " [";
|
||||||
if (state == e.starting)
|
if (state == e.starting)
|
||||||
s += "color=yellow";
|
s += "color=yellow ";
|
||||||
if (e.accepting.count(state) > 0) {
|
if (e.accepting.count(state) > 0) {
|
||||||
s += "color=green shape=doublecircle";
|
s += "color=green shape=doublecircle ";
|
||||||
label += "\\np=" + std::to_string(e.priority.find(state)->second) + "\\nac=" + e.acceptingToken.find(state)->second;
|
label += "\\np=" + std::to_string(e.priority.find(state)->second) + "\\nac=" + e.acceptingToken.find(state)->second;
|
||||||
}
|
}
|
||||||
s += " label=\"" + label + "\"]\n";
|
s += "label=\"" + label + "\"]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tmp : e.delta)
|
for (const auto& tmp : e.delta)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
digraph {
|
digraph {
|
||||||
rankdir=LR
|
rankdir=LR
|
||||||
in [shape=point style=invis]
|
in [shape=point style=invis]
|
||||||
0 [label="0" color=yellow]
|
0 [color=yellow label="0"]
|
||||||
1 [label="1"]
|
1 [label="1"]
|
||||||
2 [label="2"]
|
2 [label="2"]
|
||||||
3 [label="3"]
|
3 [label="3"]
|
||||||
4 [label="4" color=green shape=doublecircle]
|
4 [color=green shape=doublecircle label="4\np=0\nac=0"]
|
||||||
2 -> 3 [label="0"]
|
2 -> 3 [label="0"]
|
||||||
2 -> 3 [label="1"]
|
2 -> 3 [label="1"]
|
||||||
2 -> 3 [label="2"]
|
2 -> 3 [label="2"]
|
||||||
|
|
BIN
tests/test_0.min
BIN
tests/test_0.min
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,24 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR
|
||||||
|
in [shape=point style=invis]
|
||||||
|
0 [color=yellow label="0"]
|
||||||
|
1 [label="1"]
|
||||||
|
2 [color=green shape=doublecircle label="2\np=0\nac=0"]
|
||||||
|
3 [label="3"]
|
||||||
|
4 [label="4"]
|
||||||
|
5 [label="5"]
|
||||||
|
6 [label="6"]
|
||||||
|
7 [label="7"]
|
||||||
|
8 [color=green shape=doublecircle label="8\np=1\nac=1"]
|
||||||
|
1 -> 2 [label="a"]
|
||||||
|
4 -> 5 [label="a"]
|
||||||
|
6 -> 7 [label="b"]
|
||||||
|
0 -> 1 [label="ε"]
|
||||||
|
0 -> 3 [label="ε"]
|
||||||
|
3 -> 4 [label="ε"]
|
||||||
|
3 -> 6 [label="ε"]
|
||||||
|
5 -> 8 [label="ε"]
|
||||||
|
7 -> 8 [label="ε"]
|
||||||
|
in -> 0
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
a
|
||||||
|
(a|b)
|
|
@ -0,0 +1,24 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR
|
||||||
|
in [shape=point style=invis]
|
||||||
|
0 [color=yellow label="0"]
|
||||||
|
1 [label="1"]
|
||||||
|
2 [label="2"]
|
||||||
|
3 [label="3"]
|
||||||
|
4 [label="4"]
|
||||||
|
5 [label="5"]
|
||||||
|
6 [color=green shape=doublecircle label="6\np=0\nac=0"]
|
||||||
|
7 [label="7"]
|
||||||
|
8 [color=green shape=doublecircle label="8\np=1\nac=1"]
|
||||||
|
2 -> 3 [label="a"]
|
||||||
|
4 -> 5 [label="b"]
|
||||||
|
7 -> 8 [label="a"]
|
||||||
|
0 -> 1 [label="ε"]
|
||||||
|
0 -> 7 [label="ε"]
|
||||||
|
1 -> 2 [label="ε"]
|
||||||
|
1 -> 4 [label="ε"]
|
||||||
|
3 -> 6 [label="ε"]
|
||||||
|
5 -> 6 [label="ε"]
|
||||||
|
in -> 0
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
(a|b)
|
||||||
|
a
|
Loading…
Reference in New Issue