summaryrefslogtreecommitdiffstats
path: root/tests/015
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-27 08:28:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-27 08:28:02 -0700
commitdc9e7657334b68f9acb8ca2145ffe1dad9908b57 (patch)
tree4d330fb32d72b6ce93add17783f2177f0228183d /tests/015
parent07df68250098caad4f7d457968c637694f7e2e43 (diff)
downloadtxr-dc9e7657334b68f9acb8ca2145ffe1dad9908b57.tar.gz
txr-dc9e7657334b68f9acb8ca2145ffe1dad9908b57.tar.bz2
txr-dc9e7657334b68f9acb8ca2145ffe1dad9908b57.zip
filter: regex-from-trie produces bad or syntax.
This is not a complete fix yet; the test case still fails. * filter.c (regex_from_trie): The (or ...) operator in the regex language is strictly binary. Do not produce a variable-argument or expression. * tests/015/trie.tl: New file.
Diffstat (limited to 'tests/015')
-rw-r--r--tests/015/trie.tl49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/015/trie.tl b/tests/015/trie.tl
new file mode 100644
index 00000000..f233c76e
--- /dev/null
+++ b/tests/015/trie.tl
@@ -0,0 +1,49 @@
+(load "../common")
+
+(defvarl tr0 (make-trie))
+(defvarl tr1 (make-trie))
+
+(defvarl dat ; '#"aaa aab aac aba abb abc caa cab cac")
+ '("2" "3" "5" "7" "11" "13" "17" "19" "23" "29" "31" "37" "41"
+ "43" "47" "53" "59" "61" "67" "71" "73" "79" "83" "89" "97" "101"
+ "103" "107" "109" "113" "127" "131" "137" "139" "149" "151" "157"
+ "163" "167" "173" "179" "181" "191" "193" "197" "199" "211" "223"
+ "227" "229" "233" "239" "241" "251" "257" "263" "269" "271" "277"
+ "281" "283" "293" "307" "311" "313" "317" "331" "337" "347" "349"
+ "353" "359" "367" "373" "379" "383" "389" "397" "401" "409" "419"
+ "421" "431" "433" "439" "443" "449" "457" "461" "463" "467" "479"
+ "487" "491" "499" "503" "509" "521" "523" "541" "547" "557" "563"
+ "569" "571" "577" "587" "593" "599" "601" "607" "613" "617" "619"
+ "631" "641" "643" "647" "653" "659" "661" "673" "677" "683" "691"
+ "701" "709" "719" "727" "733" "739" "743" "751" "757" "761" "769"
+ "773" "787" "797" "809" "811" "821" "823" "827" "829" "839" "853"
+ "857" "859" "863" "877" "881" "883" "887" "907" "911" "919" "929"
+ "937" "941" "947" "953" "967" "971" "977" "983" "991" "997"))
+
+(defvarl enu [mapcar tostring (range* 0 (len dat))])
+(defvarl ndt [mapcar (op mapcar (op + 64)) dat])
+(defvarl fdt [mapcar (ret `x@{1}y`) dat])
+(defvarl fen [mapcar (ret `x@{1}y`) enu])
+
+(each ((d dat)
+ (n enu))
+ (trie-add tr0 d n)
+ (trie-add tr1 d n))
+
+(trie-compress tr1)
+
+(defvarl rx0 (regex-compile (regex-from-trie tr0)))
+
+(mvtest
+ (build (each ((d dat)) (add (filter-string-tree tr0 d)))) enu
+ (build (each ((x ndt)) (add (filter-string-tree tr0 x)))) ndt
+ (build (each ((f fdt)) (add (filter-string-tree tr0 f)))) fen)
+
+(mvtest
+ (build (each ((d dat)) (add (filter-string-tree tr1 d)))) enu
+ (build (each ((x ndt)) (add (filter-string-tree tr1 x)))) ndt
+ (build (each ((f fdt)) (add (filter-string-tree tr1 f)))) fen)
+
+(mvtest
+ (build (each ((d dat)) (add [rx0 d]))) dat
+ (build (each ((n enu)) (add [rx0 n]))) (repeat '(nil) (len dat)))