summaryrefslogtreecommitdiffstats
path: root/kspread/tests/generate-openformula-tests
blob: f39ce2aacfe7cbbf6c6f147784dbb6e59e263177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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