]> ocean-lang.org Git - ocean/commitdiff
indent_test: integrate into Makefile scheme nicely.
authorNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 04:01:45 +0000 (14:01 +1000)
committerNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 04:03:58 +0000 (14:03 +1000)
The test code is now included in indent_test.mdc,
and there is a '.mk'.
  make tests

will run the test.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/indent_test.mdc [moved from csrc/indent_test.cgm with 83% similarity]
csrc/itest.code [deleted file]

similarity index 83%
rename from csrc/indent_test.cgm
rename to csrc/indent_test.mdc
index 974c1676e55c5e531e64733b3906bd9876a77d6d..792e152523055781b282ac2d261fcae324f0fc79 100644 (file)
@@ -1,11 +1,25 @@
-
-# header
-
 This parser is primarily for testing indent and linebreak handling.
 It reads a very simple code fragment with if/else statements and
 simple assignments with expressions, and then prints out the same
 with complete bracketing and indenting.
 
+# File: indent_test.mk
+       myCFLAGS := -Wall -g -fplan9-extensions
+       CFLAGS := $(filter-out $(myCFLAGS),$(CFLAGS)) $(myCFLAGS)
+       LDLIBS:= libparser.o libscanner.o libmdcode.o -licuuc
+
+       all :: itest
+       itest.c itest.h : indent_test.mdc parsergen libparser.o libscanner.o libmdcode.o
+               ./parsergen -o itest --LALR --tag indent indent_test.mdc
+       indent_test.mk: indent_test.mdc md2c
+               ./md2c indent_test.mdc
+       itest: itest.c
+
+       tests:: itest itest.code
+               ./itest itest.code
+
+# indent: header
+
  ./parsergen -o itest --LALR indent_test.cgm
  cc -o itest itest.c lib*.o -licuuc -lgmp
  ./itest itest.code
@@ -21,7 +35,8 @@ with complete bracketing and indenting.
                struct statement *elsepart;
        };
 
-# code
+# indent: code
+       #include <unistd.h>
        #include <stdlib.h>
        #include <fcntl.h>
        #include <sys/mman.h>
@@ -108,7 +123,7 @@ with complete bracketing and indenting.
        }
 
 
-# grammar
+# indent: grammar
 
 ~~~~~~
 
@@ -227,4 +242,44 @@ $*expression
                                $0 = calloc(1, sizeof(struct expression));
                                $0->op = $1.txt;
                        }$
+~~~~~~
+
+# File: itest.code
+
+       # test code
+       ~~~~~~
+       hello = yes; mister = no;
+       there = x;
+       all = y;
+       if cond + cond2 :
+               hello = x;
+               hello2 = x;
+
+               sum = val +
+                val;
+
+               if condX:
+                foo = x *
+                    x +
+                    y
+                    / two;
+        else if cond2:
+               there1 =x
+               there1a=x
+       there2=x
+       there3=x;
+       all = y;
+       if true {yes=x;} else : no=x
+       if true: yes = no; no = yes;
+
+       if false {
+               print = OK
+       } else {
+               print = not_OK
+       }
+
+       if a:
+               if b:
+                       c= d
+       x = y
 
diff --git a/csrc/itest.code b/csrc/itest.code
deleted file mode 100644 (file)
index 86b71a4..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-
-# stuff
-
-       hello = yes; mister = no;
-       there = x;
-       all = y;
-       if cond + cond2 :
-               hello = x;
-               hello2 = x;
-
-               sum = val +
-                val;
-
-               if condX:
-                foo = x *
-                    x +
-                    y
-                    / two;
-        else if cond2:
-               there1 =x
-               there1a=x
-       there2=x
-       there3=x;
-       all = y;
-       if true {yes=x;} else : no=x
-       if true: yes = no; no = yes;
-
-       if false {
-               print = OK
-       } else {
-               print = not_OK
-       }
-
-       if a:
-               if b:
-                       c= d
-       x = y
-