[master] 22c4b13 Add tests for the boolean operators and fix not operator

Martin Blix Grydeland martin at varnish-cache.org
Tue Oct 1 14:48:18 CEST 2013


commit 22c4b1304d91c2554d77d72e520b43797e493b37
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Sep 20 15:14:26 2013 +0200

    Add tests for the boolean operators and fix not operator

diff --git a/bin/varnishtest/tests/l00001.vtc b/bin/varnishtest/tests/l00001.vtc
index 839accf..9b3197d 100644
--- a/bin/varnishtest/tests/l00001.vtc
+++ b/bin/varnishtest/tests/l00001.vtc
@@ -127,3 +127,24 @@ logexpect l1 -d 1 -g vxid -q "RespStatus !~ '^404$'" {
 	expect * =	ReqEnd
 	expect * =	End
 } -run
+
+# Test boolean and
+logexpect l1 -d 1 -g vxid -q "RespStatus == 200 and RespStatus ~ '^200$'" {
+	expect * *	Begin	req
+	expect * =	ReqEnd
+	expect * =	End
+} -run
+
+# Test boolean or
+logexpect l1 -d 1 -g vxid -q "RespStatus == 404 or RespStatus ~ '^200$'" {
+	expect * *	Begin	req
+	expect * =	ReqEnd
+	expect * =	End
+} -run
+
+# Test boolean !
+logexpect l1 -d 1 -g vxid -q "RespStatus == 404 or !RespStatus ~ '^404$'" {
+	expect * *	Begin	req
+	expect * =	ReqEnd
+	expect * =	End
+} -run
diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py
index 1377f71..6245ef8 100755
--- a/lib/libvarnishapi/generate.py
+++ b/lib/libvarnishapi/generate.py
@@ -58,7 +58,6 @@ tokens = {
         "T_NOMATCH":    "!~",
 
         # Boolean operators
-        "T_NOT":        "not",
         "T_AND":        "and",
         "T_OR":         "or",
 
diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index dbf539b..ba3d23b 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -218,7 +218,7 @@ vslq_exec(const struct vex *vex, struct VSL_transaction * const ptrans[])
 		if (r <= 0)
 			return (r);
 		return (vslq_exec(vex->b, ptrans));
-	case T_NOT:
+	case '!':
 		AN(vex->a);
 		AZ(vex->b);
 		r = vslq_exec(vex->a, ptrans);



More information about the varnish-commit mailing list