summaryrefslogtreecommitdiffstats
path: root/doc/scriptexamples/exprtest.kvs
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /doc/scriptexamples/exprtest.kvs
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'doc/scriptexamples/exprtest.kvs')
-rw-r--r--doc/scriptexamples/exprtest.kvs24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/scriptexamples/exprtest.kvs b/doc/scriptexamples/exprtest.kvs
new file mode 100644
index 00000000..c07d199d
--- /dev/null
+++ b/doc/scriptexamples/exprtest.kvs
@@ -0,0 +1,24 @@
+# A stresstest for the expression evaluation engine
+
+alias(exprtest)
+{
+ %txt = "Testing expression:" $0;
+
+ %ret = ${ eval "return \$(" $0 ")"; }
+ if(%ret != $1)
+ {
+ %txt .= " ... Failed (return value" %ret "!=" $1")";
+ echo %txt
+ } else {
+ %txt .= " ... Success (return value $1)";
+ echo %txt
+ }
+}
+
+exprtest "5 - 0 - 1" 4
+exprtest "5 - (0 - 1)" 6
+exprtest "2+3-5+3+1-2-3-8+5*3-2" 4
+exprtest "2*2 + 2*2 - 2*2" 4
+exprtest "-1" -1
+exprtest "--1--1" 2
+exprtest "-1+1" -2