summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2010-03-27 15:59:48 +0000
committerAdrian Thurston <thurston@complang.org>2010-03-27 15:59:48 +0000
commit20faf1f07ac65e815c91da2f871bfa75071429e2 (patch)
tree3662687fed2f2a75f8d427961c7c338dbe181c52
parentd65c110f9c59d7aa0f472f5c215a29117f13863c (diff)
downloadcolm-20faf1f07ac65e815c91da2f871bfa75071429e2.tar.gz
added http and xml
-rw-r--r--test/TESTS2
-rw-r--r--test/http/Makefile79
-rw-r--r--test/http/TESTS6
-rw-r--r--test/http/http1.exp19
-rw-r--r--test/http/http1.in (renamed from test/http/input1)0
-rw-r--r--test/http/http2.exp65
-rw-r--r--test/http/http2.in (renamed from test/http/input2)0
-rw-r--r--test/http/http3.exp30
-rw-r--r--test/http/http3.in (renamed from test/http/input3)0
-rw-r--r--test/xml/Makefile65
-rw-r--r--test/xml/TESTS6
-rw-r--r--test/xml/xml.exp52
12 files changed, 256 insertions, 68 deletions
diff --git a/test/TESTS b/test/TESTS
index 62b25ed7..75acec57 100644
--- a/test/TESTS
+++ b/test/TESTS
@@ -4,6 +4,8 @@
SUBDIRS="
python
html
+ xml
+ http
"
TESTS="
diff --git a/test/http/Makefile b/test/http/Makefile
index d647261a..3d6fca9b 100644
--- a/test/http/Makefile
+++ b/test/http/Makefile
@@ -1,34 +1,45 @@
-#
-# Copyright 2002-2006 Adrian Thurston <thurston@complang.org>
-#
-
-# This file is part of Colm.
-#
-# Colm is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Colm is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Colm; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-SRC = $(wildcard *.lm)
-BIN = $(SRC:%.lm=%.bin)
-COLM = ../../colm/colm
-
-all: $(BIN)
-
-$(BIN): $(COLM)
-
-$(BIN): %.bin: %.lm
- $(COLM) $<
-
-clean:
- rm -f *.cpp *.bin
+SUBDIRS =
+
+TESTS = \
+ http.lm
+
+DIFFS = \
+ http1.diff \
+ http2.diff \
+ http3.diff
+
+all: Makefile $(DIFFS) $(SUBDIRS)
+
+.PHONY: clean $(SUBDIRS:%=%-clean)
+clean: $(SUBDIRS:%=%-clean)
+ rm -f *.bin
+$(SUBDIRS:%=%-clean):
+ cd $(@:%-clean=%) && $(MAKE) clean
+
+.PHONY: $(SUBDIRS)
+$(SUBDIRS):
+ cd $@ && $(MAKE)
+
+Makefile: ../genmf TESTS
+ ../genmf > Makefile
+
+http1.diff: http1.out http1.exp
+ @diff -u http1.exp http1.out > http1.diff || ( cat http1.diff; rm http1.diff )
+
+http1.out: http.bin
+ ./http.bin < http1.in > http1.out
+
+http2.diff: http2.out http2.exp
+ @diff -u http2.exp http2.out > http2.diff || ( cat http2.diff; rm http2.diff )
+
+http2.out: http.bin
+ ./http.bin < http2.in > http2.out
+
+http3.diff: http3.out http3.exp
+ @diff -u http3.exp http3.out > http3.diff || ( cat http3.diff; rm http3.diff )
+
+http3.out: http.bin
+ ./http.bin < http3.in > http3.out
+
+http.bin: http.lm ../../colm/colm
+ ../../colm/colm http.lm
diff --git a/test/http/TESTS b/test/http/TESTS
new file mode 100644
index 00000000..6dc362f8
--- /dev/null
+++ b/test/http/TESTS
@@ -0,0 +1,6 @@
+#!/bin/bash
+#
+
+TESTS="
+ http.lm
+"
diff --git a/test/http/http1.exp b/test/http/http1.exp
new file mode 100644
index 00000000..193c1087
--- /dev/null
+++ b/test/http/http1.exp
@@ -0,0 +1,19 @@
+HTTP/1.0 200 OK
+Date: Fri, 31 Dec 1999 23:59:59 GMT
+Content-Type: text/plain
+
+<request>
+ <request_line>
+ <method>GET</method>
+ <' '/>
+ <request_uri>/hi/there/</request_uri>
+ <' '/>
+ <http_version>
+ <'HTTP/'/>
+ <http_number>1.1</http_number>
+ </http_version>
+ <CRLF>&#13;&#10;</CRLF>
+ </request_line>
+ <_repeat_header/>
+ <CRLF>&#13;&#10;</CRLF>
+</request>
diff --git a/test/http/input1 b/test/http/http1.in
index c1416f84..c1416f84 100644
--- a/test/http/input1
+++ b/test/http/http1.in
diff --git a/test/http/http2.exp b/test/http/http2.exp
new file mode 100644
index 00000000..78f352cb
--- /dev/null
+++ b/test/http/http2.exp
@@ -0,0 +1,65 @@
+HTTP/1.0 200 OK
+Date: Fri, 31 Dec 1999 23:59:59 GMT
+Content-Type: text/plain
+
+<request>
+ <request_line>
+ <method>GET</method>
+ <' '/>
+ <request_uri>/hithere/</request_uri>
+ <' '/>
+ <http_version>
+ <'HTTP/'/>
+ <http_number>1.1</http_number>
+ </http_version>
+ <CRLF>&#13;&#10;</CRLF>
+ </request_line>
+ <_repeat_header>
+ <header>
+ <field_name>Host</field_name>
+ <':'/>
+ <field_value> localhost:3535&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>User-Agent</field_name>
+ <':'/>
+ <field_value> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Accept</field_name>
+ <':'/>
+ <field_value> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Accept-Language</field_name>
+ <':'/>
+ <field_value> en-us,en;q=0.5&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Accept-Encoding</field_name>
+ <':'/>
+ <field_value> gzip,deflate&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Accept-Charset</field_name>
+ <':'/>
+ <field_value> ISO-8859-1,utf-8;q=0.7,*;q=0.7&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Keep-Alive</field_name>
+ <':'/>
+ <field_value> 300&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Connection</field_name>
+ <':'/>
+ <field_value> keep-alive&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>Cache-Control</field_name>
+ <':'/>
+ <field_value> max-age=0&#13;&#10;</field_value>
+ </header>
+ </_repeat_header>
+ <CRLF>&#13;&#10;</CRLF>
+</request>
diff --git a/test/http/input2 b/test/http/http2.in
index 076222d5..076222d5 100644
--- a/test/http/input2
+++ b/test/http/http2.in
diff --git a/test/http/http3.exp b/test/http/http3.exp
new file mode 100644
index 00000000..2a74de3a
--- /dev/null
+++ b/test/http/http3.exp
@@ -0,0 +1,30 @@
+HTTP/1.0 200 OK
+Date: Fri, 31 Dec 1999 23:59:59 GMT
+Content-Type: text/plain
+
+<request>
+ <request_line>
+ <method>GET</method>
+ <' '/>
+ <request_uri>foo</request_uri>
+ <' '/>
+ <http_version>
+ <'HTTP/'/>
+ <http_number>1.1</http_number>
+ </http_version>
+ <CRLF>&#13;&#10;</CRLF>
+ </request_line>
+ <_repeat_header>
+ <header>
+ <field_name>hello</field_name>
+ <':'/>
+ <field_value> foo&#13;&#10;</field_value>
+ </header>
+ <header>
+ <field_name>hi</field_name>
+ <':'/>
+ <field_value> there&#13;&#10;&#9;my&#13;&#10; friend&#13;&#10; &#13;&#10; from outter space&#13;&#10;</field_value>
+ </header>
+ </_repeat_header>
+ <CRLF>&#13;&#10;</CRLF>
+</request>
diff --git a/test/http/input3 b/test/http/http3.in
index 16b817f1..16b817f1 100644
--- a/test/http/input3
+++ b/test/http/http3.in
diff --git a/test/xml/Makefile b/test/xml/Makefile
index d647261a..e5b290fd 100644
--- a/test/xml/Makefile
+++ b/test/xml/Makefile
@@ -1,34 +1,31 @@
-#
-# Copyright 2002-2006 Adrian Thurston <thurston@complang.org>
-#
-
-# This file is part of Colm.
-#
-# Colm is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Colm is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Colm; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-SRC = $(wildcard *.lm)
-BIN = $(SRC:%.lm=%.bin)
-COLM = ../../colm/colm
-
-all: $(BIN)
-
-$(BIN): $(COLM)
-
-$(BIN): %.bin: %.lm
- $(COLM) $<
-
-clean:
- rm -f *.cpp *.bin
+SUBDIRS =
+
+TESTS = \
+ xml.lm
+
+DIFFS = \
+ xml.diff
+
+all: Makefile $(DIFFS) $(SUBDIRS)
+
+.PHONY: clean $(SUBDIRS:%=%-clean)
+clean: $(SUBDIRS:%=%-clean)
+ rm -f *.bin
+$(SUBDIRS:%=%-clean):
+ cd $(@:%-clean=%) && $(MAKE) clean
+
+.PHONY: $(SUBDIRS)
+$(SUBDIRS):
+ cd $@ && $(MAKE)
+
+Makefile: ../genmf TESTS
+ ../genmf > Makefile
+
+xml.diff: xml.out xml.exp
+ @diff -u xml.exp xml.out > xml.diff || ( cat xml.diff; rm xml.diff )
+
+xml.out: xml.bin
+ ./xml.bin < xml.in > xml.out
+
+xml.bin: xml.lm ../../colm/colm
+ ../../colm/colm xml.lm
diff --git a/test/xml/TESTS b/test/xml/TESTS
new file mode 100644
index 00000000..8176f8c2
--- /dev/null
+++ b/test/xml/TESTS
@@ -0,0 +1,6 @@
+#!/bin/bash
+#
+
+TESTS="
+ xml.lm
+"
diff --git a/test/xml/xml.exp b/test/xml/xml.exp
new file mode 100644
index 00000000..b2e9284f
--- /dev/null
+++ b/test/xml/xml.exp
@@ -0,0 +1,52 @@
+SWITCH
+ token( KW_When );
+ token( KW_Eof );
+ token( KW_Err );
+ token( KW_Lerr );
+ token( KW_To );
+ token( KW_From );
+ token( TK_Word, tokstart, tokend );
+SWITCH
+ token( KW_Lex );
+ token( KW_Action );
+ token( KW_AlphType );
+ token( KW_Commit );
+ token( KW_Undo );
+ token( KW_Final );
+ token( KW_Translate );
+ token( KW_Token );
+ token( KW_Literal );
+ token( KW_NonTerm );
+ token( KW_Uses );
+ token( KW_Parser );
+ token( KW_Include );
+ token( KW_Write );
+ token( KW_Nfa );
+ token( KW_Pda );
+ token( KW_Rl );
+ token( KW_Cfl );
+ token( KW_Ignore );
+ token( KW_End );
+ token( KW_Pattern );
+ token( KW_Construct );
+ token( KW_Red );
+ token( KW_TypeId );
+ token( KW_TypeDef );
+ token( KW_If );
+ token( KW_Init );
+ token( KW_Reject );
+ token( KW_While );
+ token( KW_Else );
+ token( KW_SubParser );
+ token( KW_Next );
+ token( KW_Match );
+ token( KW_For );
+ token( KW_Iter );
+ token( KW_Find );
+ token( KW_Root );
+ token( KW_PrintXML );
+ token( KW_Then );
+ token( KW_Do );
+ token( KW_Namespace );
+ token( KW_Scanner );
+ token( TK_Word, tokstart, tokend );