summaryrefslogtreecommitdiffstats
path: root/kspread/tests/generate-openformula-tests
diff options
context:
space:
mode:
Diffstat (limited to 'kspread/tests/generate-openformula-tests')
-rwxr-xr-xkspread/tests/generate-openformula-tests44
1 files changed, 44 insertions, 0 deletions
diff --git a/kspread/tests/generate-openformula-tests b/kspread/tests/generate-openformula-tests
new file mode 100755
index 00000000..f39ce2aa
--- /dev/null
+++ b/kspread/tests/generate-openformula-tests
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# IMPORTANT: this is like the slowest thing ever. But it works. Usually.
+# Requires an open instance of KSpread, with openformula-test.ods loaded.
+#
+
+KSPREAD=`dcopfind 'kspread*'`
+KSPREAD=`echo $KSPREAD | sed s/DCOPRef\(// | sed s/,\)//`
+for i in `seq 51 514`
+ do
+ CELLREF=`dcop $KSPREAD Document/Map/List1 cell 7 $i`
+ PASS=`dcop $CELLREF value`
+ if test $PASS = 1.000000
+ then
+ CELLREF=`dcop $KSPREAD Document/Map/List1 cell 2 $i`
+ formula=`dcop $CELLREF text`
+ formula=`echo $formula | sed s/\"/\\\\\\\\\"/g`
+
+#nothing if formula contains a cellref ...
+ if test -z "`echo $formula | grep B[1-9]`"
+ then
+ CELLREF=`dcop $KSPREAD Document/Map/List1 cell 3 $i`
+ result=`dcop $CELLREF text`
+#test whether we have a number
+ if test $result = True
+ then
+ VAL="true"
+ else if test $result = False
+ then
+ VAL="false"
+ else if test -z `echo $result | grep -P "^\d+([\.,]\d+)?$"`
+ then
+ VAL="\"${result}\""
+ else
+ result=`echo $result | sed s/,/./`
+ VAL=$result
+ fi;fi;fi
+ echo "CHECK_EVAL(\"=${formula}\", Value($VAL)); // row $i"
+ fi
+ else echo // Not passed for line $i.
+ fi
+done
+
+