]> granicus.if.org Git - flex/commitdiff
and more fallout
authorWill Estes <wlestes@users.sourceforge.net>
Wed, 14 Nov 2001 23:09:47 +0000 (23:09 +0000)
committerWill Estes <wlestes@users.sourceforge.net>
Wed, 14 Nov 2001 23:09:47 +0000 (23:09 +0000)
tests/test-header-r/.cvsignore [new file with mode: 0644]
tests/test-header-r/Makefile.in [new file with mode: 0644]
tests/test-header-r/main.c [new file with mode: 0644]
tests/test-header-r/scanner.l [new file with mode: 0644]
tests/test-header-r/test.input [new file with mode: 0644]

diff --git a/tests/test-header-r/.cvsignore b/tests/test-header-r/.cvsignore
new file mode 100644 (file)
index 0000000..cd1d5c1
--- /dev/null
@@ -0,0 +1,5 @@
+Makefile
+scanner.c
+scanner.h
+test-header-r
+
diff --git a/tests/test-header-r/Makefile.in b/tests/test-header-r/Makefile.in
new file mode 100644 (file)
index 0000000..5c7cb78
--- /dev/null
@@ -0,0 +1,62 @@
+# Makefile.in for a single TEST.
+#
+# By default this Makefile will build the target "$(TESTNAME)"
+# from the sources "scanner.l" and "parser.y".
+#
+# $(TESTNAME) is supplied by the calling Makefile.
+# "parser.y"  is not necessary. You may delete this file
+#             if you do not require a parser.
+# "scanner.l" is necessary. It should build "scanner.c".
+#
+
+@SET_MAKE@
+
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@ -I. -I"@srcdir@" -I..
+DEFS = @DEFS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+SHELL = /bin/sh
+srcdir = @srcdir@
+VPATH = @srcdir@
+LN_S = @LN_S@
+YACC = @YACC@
+CC = @CC@
+AR = ar
+RANLIB = @RANLIB@
+YACC = @YACC@
+
+# Edit these if necessary for your specific test.
+TESTNAME = test-header-r
+FLEX = ../../flex --header="scanner.h"
+YFLAGS = --defines --output-file="parser.c" --name-prefix="test" 
+OBJS = scanner.o main.o
+
+# Force YACC to be bison (autoconf generates 'bison -y')
+YACC = @BISON@
+
+all: $(TESTNAME)
+
+$(TESTNAME): $(OBJS)
+       $(CC) $(CFLAGS) -o $(TESTNAME) $(OBJS) $(LDFLAGS) $(LIBS)
+
+scanner.c: $(srcdir)/scanner.l
+       $(FLEX) $(srcdir)/scanner.l
+
+scanner.o: scanner.c 
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c scanner.c
+
+main.o: $(srcdir)/main.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/main.c
+
+test: check
+
+check: $(TESTNAME)
+       ./$(TESTNAME) < $(srcdir)/test.input 
+
+distclean: clean
+       rm -f Makefile
+
+clean:
+       rm -f scanner.o scanner.c scanner.h main.o $(TESTNAME) OUTPUT
+
diff --git a/tests/test-header-r/main.c b/tests/test-header-r/main.c
new file mode 100644 (file)
index 0000000..079ad80
--- /dev/null
@@ -0,0 +1,40 @@
+#include "scanner.h"
+
+/* The scanner itself is not important here.
+ * We simply try to use all the functions that are exported in the
+ * header, to see if we get any compiler warnings.
+ */
+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);
+    printf("TEST RETURNING OK.\n");
+    return 0;
+}
+
+
+/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
diff --git a/tests/test-header-r/scanner.l b/tests/test-header-r/scanner.l
new file mode 100644 (file)
index 0000000..58026fc
--- /dev/null
@@ -0,0 +1,23 @@
+%{
+/* Build "scanner.c". 
+   The scanner is not important. 
+   This test is really about compilation. See "main.c".
+*/
+#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-header-r/test.input b/tests/test-header-r/test.input
new file mode 100644 (file)
index 0000000..2ce5001
--- /dev/null
@@ -0,0 +1,3 @@
+Any input is ok for this scanner.
+We only care if it links.
+