From 77d244ddd2b00d3188fd4301f39d7f9fbc923e67 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 27 Sep 2009 21:18:40 -0700 Subject: [PATCH] Add grep ere tests. --- tests/runtime/test-regsexp.scm | 119 ++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/tests/runtime/test-regsexp.scm b/tests/runtime/test-regsexp.scm index 473e280b0..963dc8374 100644 --- a/tests/runtime/test-regsexp.scm +++ b/tests/runtime/test-regsexp.scm @@ -231,6 +231,7 @@ USA. (4 0 0) (3 0 0) (2 0 0) (1 0 0)))) )) +;;; Ripped off from "grep/tests/bre.tests". (define-test 'grep-bre (map (lambda (entry) (match-strings-test (car entry) (cdr entry))) @@ -339,4 +340,120 @@ USA. ((seq (repeat> 0 1 "-") (+ (char-set "0123456789")) (string-end)) - "-5")))) \ No newline at end of file + "-5")))) + +;;; Ripped off from "grep/tests/ere.tests". +(define-test 'grep-ere + (map (lambda (entry) + (match-strings-test (car entry) (cdr entry))) + `(((alt "abc" "de") + "abc") + ((alt "a" "b" "c") + ("abc" 1)) + ((seq "a" (any-char) "c") + "abc") + ((seq "a" (char-set "bc") "d") + "abd") + ((seq "a" (* "b") "c") + "abc") + ((seq "a" (+ "b") "c") + "abc") + ((seq "a" (? "b") "c") + "abc") + ((seq "a" (char-set "b") "c") + "abc") + ((seq "a" (char-set "ab") "c") + "abc") + ((seq "a" (inverse-char-set "ab") "c") + ("abc" #f) + "adc") + ((seq "a" (char-set ,(char-set->alphabet char-set:alphabetic)) "c") + "abc" + "adc") + ((seq "a" (+ (char-set ,(char-set->alphabet char-set:numeric))) "c") + "a019c") + ((seq "A" (+ (char-set ,(char-set->alphabet char-set:lower-case))) "C") + "AabC") + ((seq "a" (+ (char-set ,(char-set->alphabet char-set:upper-case))) "c") + "aBCc") + ((seq "a" (repeat> 20 20 (char-set "ab"))) + "aaaaabaaaabaaaabaaaab") + ((seq "a" + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab")) + "aaaaabaaaabaaaabaaaab") + ((seq "a" + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (char-set "ab") (char-set "ab") (char-set "ab") (char-set "ab") + (alt "wee" "week") + (alt "knights" "night")) + "aaaaabaaaabaaaabaaaabweeknights") + ((seq (char-set "ab") (char-set "cd") (char-set "ef") (char-set "gh") + (char-set "ij") (char-set "kl") (char-set "mn")) + ("acegikmoq" 7)) + ((seq (char-set "ab") (char-set "cd") (char-set "ef") (char-set "gh") + (char-set "ij") (char-set "kl") (char-set "mn") (char-set "op")) + ("acegikmoq" 8)) + ((seq (char-set "ab") (char-set "cd") (char-set "ef") (char-set "gh") + (char-set "ij") (char-set "kl") (char-set "mn") (char-set "op") + (char-set "qr")) + ("acegikmoqy" 9)) + ((seq (char-set "ab") (char-set "cd") (char-set "ef") (char-set "gh") + (char-set "ij") (char-set "kl") (char-set "mn") (char-set "op") + (char-set "q")) + ("acegikmoqy" 9)) + ("aBc" + ("Abc" #f)) + ((seq "a" (* (char-set "Bc")) "d") + "acBd" + "aBcd" + "aBcBcBd" + ("aBCd" #f) + ("abcd" #f) + ("abBCcd" #f)) + ((seq "a" (inverse-char-set "b") "c") + ("abc" #f) + "aBc" + "adc") + ((seq (char-set "a") "b" (char-set "c")) + "abc") + ((seq (char-set "a") "b" (char-set "a")) + "aba") + ((seq (char-set "abc") "b" (char-set "abc")) + "abc") + ((seq (char-set "abc") "b" (char-set "abd")) + ("abc" #f) + "abd") + ((seq "a" (+ (seq (? "b") "c")) "d") + "accd") + ((* "a") + ("b" 0)) + ((seq (alt "wee" "week") (alt "knights" "night")) + "weeknights") + ((seq (alt "we" "wee" "week" "frob") (alt "knights" "night" "day")) + "weeknights") + ("abcdefghijklmnop" + "abcdefghijklmnop") + ("abcdefghijklmnopqrstuv" + "abcdefghijklmnopqrstuv") + ((alt (seq "CC" (char-set "13") "1") + (seq (repeat> 21 21 "a") + (char-set "23") + (char-set "EO") + (char-set "123") + (char-set "Es") + (char-set "12") + (repeat> 15 15 "a") + "aa" + (char-set "34") + (char-set "EW") + "aaaaaaa" + (char-set "X") + "a")) + "CC11")))) \ No newline at end of file -- 2.25.1