summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Millaway <john43@users.sourceforge.net>2003-03-26 03:26:50 +0000
committerJohn Millaway <john43@users.sourceforge.net>2003-03-26 03:26:50 +0000
commit5a7b88e170427ad83fd135047a86b0ff95a6228a (patch)
treeaaaef6deb65293b9c528b9b7c6d8892cf17aebb3
parentce54b84dd4ad714f07fb67e65d7579b03e9f220a (diff)
Added test for #line directives.
-rw-r--r--configure.in1
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/descriptions6
-rw-r--r--tests/test-linedir-r/.cvsignore6
-rw-r--r--tests/test-linedir-r/Makefile.am56
-rw-r--r--tests/test-linedir-r/check-lines.awk7
-rw-r--r--tests/test-linedir-r/main.c58
-rw-r--r--tests/test-linedir-r/scanner.l45
-rw-r--r--tests/test-linedir-r/test.input3
9 files changed, 184 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 366aeca..7742cf1 100644
--- a/configure.in
+++ b/configure.in
@@ -111,6 +111,7 @@ tests/test-string-r/Makefile
tests/test-yyextra/Makefile
tests/test-lineno-nr/Makefile
tests/test-lineno-r/Makefile
+tests/test-linedir-r/Makefile
tests/test-debug-r/Makefile
tests/test-debug-nr/Makefile
tests/test-mem-nr/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index daeefcb..f3d6b10 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,6 +46,7 @@ DIST_SUBDIRS = \
test-debug-r \
test-lineno-r \
test-lineno-nr \
+ test-linedir-r \
TEMPLATE \
test-array-nr \
test-array-r \
@@ -84,6 +85,7 @@ SUBDIRS = \
test-debug-r \
test-lineno-r \
test-lineno-nr \
+ test-linedir-r \
test-array-nr \
test-array-r \
test-c-cpp-nr \
diff --git a/tests/descriptions b/tests/descriptions
index 90e8420..2445520 100644
--- a/tests/descriptions
+++ b/tests/descriptions
@@ -10,23 +10,29 @@ bison-yylloc - Reentrant scanner + pure parser. Requires bison.
bison-yylval - Reentrant scanner + pure parser. Requires bison.
c-cpp-nr - Compile a C scanner with C++ compiler, nonreentrant.
c-cpp-r - Compile a C scanner with C++ compiler, reentrant.
+c++-basic - The C++ scanner.
+c++-multiple-scanners - Multiple C++ scanners.
debug-nr - Use yy_flex_debug, non-reentrant.
debug-r - Use debugging functions, reentrant.
header-nr - Test generated header file, non-reentrant.
header-r - Test generated header file, reentrant.
include-by-buffer - YY_BUFFER_STATE, yy_push_state, etc.
include-by-reentrant - Nested scanners.
+linedir-r - Check #line directives.
lineno-nr - Use %option yylineno, non-reentrant.
lineno-r - Use %option yylineno, reentrant.
mem-nr - Override memory api, non-reentrant.
mem-r - Override memory api, reentrant.
multiple-scanners-nr - #include and run two separate scanners, non-reentrant.
multiple-scanners-r - #include and run two separate scanners, reentrant.
+noansi-nr - test %option noansi-*, non-reentrant.
+noansi-r - test %option noansi-*, reentrant.
posix - Test %option posix-compat.
posixly-correct - Test POSIXLY_CORRECT variable.
prefix-nr - Verify prefixes are working, nonreentrant.
prefix-r - Verify prefixes are working, reentrant.
pthread - Pthreads test. A NO-OP if libpthread not found.
+reject - Check REJECT code.
string-nr - Scan strings, non-reentrant.
string-r - Scan strings, reentrant.
table-opts - Try every table compression option.
diff --git a/tests/test-linedir-r/.cvsignore b/tests/test-linedir-r/.cvsignore
new file mode 100644
index 0000000..8642445
--- /dev/null
+++ b/tests/test-linedir-r/.cvsignore
@@ -0,0 +1,6 @@
+Makefile
+Makefile.in
+scanner.c
+scanner.h
+test-linedir-r
+OUTPUT
diff --git a/tests/test-linedir-r/Makefile.am b/tests/test-linedir-r/Makefile.am
new file mode 100644
index 0000000..f440925
--- /dev/null
+++ b/tests/test-linedir-r/Makefile.am
@@ -0,0 +1,56 @@
+# This file is part of flex.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+
+# Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE.
+
+
+FLEX = $(top_builddir)/flex
+
+builddir = @builddir@
+
+EXTRA_DIST = scanner.l test.input main.c
+CLEANFILES = scanner.c scanner.h test-linedir-r OUTPUT $(OBJS)
+OBJS = scanner.o main.o
+
+AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir) -I$(builddir)
+#LDFLAGS = $(top_srcdir)/libfl.a
+LFLAGS = --header="scanner.h"
+#YFLAGS = --defines --output=parser.c
+
+testname = test-linedir-r
+
+scanner.c: $(srcdir)/scanner.l
+ $(FLEX) $(LFLAGS) $<
+
+parser.c: $(srcdir)/parser.y
+ $(BISON) $(YFLAGS) $<
+
+$(testname)$(EXEEXT): $(OBJS)
+ $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LOADLIBES)
+
+test: $(testname)$(EXEEXT)
+ ./$(testname)$(EXEEXT) < $(srcdir)/test.input
+ cat -n scanner.c | grep '#line' | grep scanner.c | awk -f $(srcdir)/check-lines.awk
+ cat -n scanner.h | grep '#line' | grep scanner.h | awk -f $(srcdir)/check-lines.awk
+
+.c.o:
+ $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $<
+
+scanner.h: scanner.c
+main.o: scanner.h
diff --git a/tests/test-linedir-r/check-lines.awk b/tests/test-linedir-r/check-lines.awk
new file mode 100644
index 0000000..6a1e5ec
--- /dev/null
+++ b/tests/test-linedir-r/check-lines.awk
@@ -0,0 +1,7 @@
+{
+ if( /#line/ && $1 != ($3 - 1)) {
+ printf "Line directive mismatch at line %d: %s\n", NR, $0;
+ exit 1;
+ }
+}
+
diff --git a/tests/test-linedir-r/main.c b/tests/test-linedir-r/main.c
new file mode 100644
index 0000000..6ba9808
--- /dev/null
+++ b/tests/test-linedir-r/main.c
@@ -0,0 +1,58 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+#include "scanner.h"
+
+int
+main ( int argc, char** argv )
+{
+ yyscan_t scanner;
+ FILE *fp;
+ char * extra = "EXTRA";
+
+ testlex_init(&scanner);
+ testset_in(stdin,scanner);
+ testset_out(stdout,scanner);
+ testset_extra(extra,scanner);
+
+ fp = testget_in(scanner);
+ fp = testget_out(scanner);
+
+ while(testlex(scanner)) {
+ char * text;
+ int line;
+ line = testget_lineno(scanner);
+ text = testget_text(scanner);
+
+ if( (char*)testget_extra(scanner) != extra)
+ break;
+
+ if ( !text || line < 0)
+ continue;
+ }
+ testlex_destroy(scanner);
+ return 0;
+}
+
+
+/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
diff --git a/tests/test-linedir-r/scanner.l b/tests/test-linedir-r/scanner.l
new file mode 100644
index 0000000..e87cc60
--- /dev/null
+++ b/tests/test-linedir-r/scanner.l
@@ -0,0 +1,45 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* Build "scanner.c".
+ The scanner is not important.
+ This test is really about getting the line directives correct.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+%}
+
+%option reentrant
+%option 8bit outfile="scanner.c" prefix="test"
+%option nounput nomain noyywrap
+%option warn
+
+%%
+
+.|\n { }
+
+%%
+
diff --git a/tests/test-linedir-r/test.input b/tests/test-linedir-r/test.input
new file mode 100644
index 0000000..2ce5001
--- /dev/null
+++ b/tests/test-linedir-r/test.input
@@ -0,0 +1,3 @@
+Any input is ok for this scanner.
+We only care if it links.
+