summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/bre
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsrc/grep/tests/bre21
-rw-r--r--src/grep/tests/bre.awk33
-rw-r--r--src/grep/tests/bre.tests64
3 files changed, 118 insertions, 0 deletions
diff --git a/src/grep/tests/bre b/src/grep/tests/bre
new file mode 100755
index 0000000..5be164c
--- /dev/null
+++ b/src/grep/tests/bre
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Regression test for GNU grep.
+#
+# Copyright (C) 2001, 2006, 2009-2021 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+fail=0
+
+# . . . and the following by Henry Spencer.
+
+${AWK-awk} -f $abs_top_srcdir/tests/bre.awk $abs_top_srcdir/tests/bre.tests \
+ > bre.script || fail=1
+
+${re_shell-${SHELL-sh}} ./bre.script || fail=1
+
+Exit $fail
diff --git a/src/grep/tests/bre.awk b/src/grep/tests/bre.awk
new file mode 100644
index 0000000..519e270
--- /dev/null
+++ b/src/grep/tests/bre.awk
@@ -0,0 +1,33 @@
+# Copyright (C) 2001, 2006, 2009-2021 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+BEGIN {
+ FS="@";
+ n = 0;
+ printf ("# Generated Spencer BRE Test\n");
+ printf ("failures=0\n");
+}
+
+$0 ~ /^#/ { next; }
+
+NF == 3 {
+# printf ("status=$(echo '%s' | { grep -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; })\n",$3, $2);
+ printf ("status=$(echo '%s' | { grep -e '%s' > /dev/null 2>&1; echo $? ; })\n",$3, $2);
+ printf ("if test $status -ne %s ; then\n", $1);
+ printf ("\techo Spencer bre test \\#%d failed\n", ++n);
+ printf ("\tfailures=1\n");
+ printf ("fi\n");
+}
+
+NF == 4 {
+#don't alarm users
+# printf ("echo '%s' | grep -e '%s' > /dev/null 2>&1\n",$3, $2);
+# printf ("if test $? -ne %s ; then\n", $1);
+# printf ("\techo Expected non conformance \\#%d ... continuing\n", ++n);
+# printf ("fi\n");
+}
+
+END { printf ("exit $failures\n"); }
diff --git a/src/grep/tests/bre.tests b/src/grep/tests/bre.tests
new file mode 100644
index 0000000..9d01a3c
--- /dev/null
+++ b/src/grep/tests/bre.tests
@@ -0,0 +1,64 @@
+0@a\(b\)c@abc
+0@a(@a(
+2@a\(@EPAREN
+2@a\(b@EPAREN
+0@a(b@a(b
+0@a)@a)
+2@a\)@EPAREN
+2@\)@EPAREN
+0@a\(\)b@ab
+0@a^b@a^b
+0@a$b@a$b
+0@\($\)\(^\)@@TO CORRECT
+0@a*\(^b$\)c*@b
+0@|@|
+0@*@*
+0@\(\)@abc
+2@\(\{1\}a\)@BADRPT@TO CORRECT
+0@^*@*
+2@^\{1\}@BADRPT@TO CORRECT
+0@{@{
+1@a\(b*\)c\1d@abbcbd
+1@a\(b*\)c\1d@abbcbbbd
+1@^\(.\)\1@abc
+0@a\(\([bc]\)\2\)*d@abbccd
+1@a\(\([bc]\)\2\)*d@abbcbd
+0@a\(\(b\)*\2\)*d@abbbd
+0@\(a\)\1bcd@aabcd
+0@\(a\)\1bc*d@aabcd
+0@\(a\)\1bc*d@aabd
+0@\(a\)\1bc*d@aabcccd
+0@\(a\)\1bc*[ce]d@aabcccd@TO CORRECT
+0@^\(a\)\1b\(c\)*cd$@aabcccd
+0@a\(*\)b@a*b
+0@a\(**\)b@ab
+2@a\(***\)b@BADRPT@TO CORRECT
+0@*a@*a
+0@**a@a
+2@***a@BADRPT@TO CORRECT
+0@a\{1\}b@ab
+0@a\{1,\}b@ab
+0@a\{1,2\}b@aab
+2@a\{1@EBRACE
+2@a\{1a@EBRACE
+2@a\{1a\}@BADBR
+0@a\{,2\}@a\{,2\}
+0@a\{,\}@a\{,\}
+2@a\{\}@BADBR
+2@a\{1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