summaryrefslogtreecommitdiffstats
path: root/kate/tests/highlight.do
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kate/tests/highlight.do
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/tests/highlight.do')
-rw-r--r--kate/tests/highlight.do89
1 files changed, 89 insertions, 0 deletions
diff --git a/kate/tests/highlight.do b/kate/tests/highlight.do
new file mode 100644
index 000000000..0b90b16b6
--- /dev/null
+++ b/kate/tests/highlight.do
@@ -0,0 +1,89 @@
+/* Test file for kate's stata syntax highlighting
+*/
+*! version 1.2.0 2mar2003 E. Leuven
+program define spellsplit
+ version 7
+ syntax [anything], spell(varlist min=2 max=2) [ by(varlist)]
+ tokenize `spell'
+ local date0 `1'
+ local date1 `2'
+ local f0 : format `date0'
+ local f1 : format `date1'
+
+ /* set default statistic */
+ local current "mean"
+
+ gettoken left anything : anything, match(prns)
+ while "`left'"!="" {
+ if "`prns'"!="" {
+ if !inlist("`left'","mean","sum") {
+ di as error "Statistic `left' not supported"
+ exit 198
+ }
+ local current "`left'"
+ }
+ else {
+ local `current'vars ``current'vars' `left'
+ }
+ gettoken left anything : anything, match(prns)
+ }
+ if ("`meanvars'"!="") {
+ confirm var `meanvars'
+ unab meanvars : `meanvars'
+ }
+ if ("`sumvars'"!="") {
+ confirm var `sumvars'
+ unab sumvars : `sumvars'
+ }
+
+ quietly {
+ g _count = 1
+ local xvars `meanvars' `sumvars' _count
+
+ /* create dummy by-var if no by option is specified */
+ if "`by'"=="" {
+ tempvar by
+ g byte `by' = 1
+ }
+ tempvar `xvars' `by'
+
+ /* create negative for subtraction when spell ends */
+ cap foreach v of varlist `xvars' {
+ g double ``v'' = -`v'
+ local txvars `txvars' ``v''
+ }
+ cap foreach v of varlist `by' {
+ g double ``v'' = `v'
+ local txvars `txvars' ``v''
+ }
+
+ stack `date0' `xvars' `by' `date1' `txvars', into(`date0' `xvars' `by') clear
+
+ /* calculate totals per date */
+ cap foreach v of varlist `xvars' {
+ egen double ``v'' = sum(`v'), by(`by' `date0')
+ }
+
+ /* unique dates only */
+ by `by' `date0', sort: keep if _n==1
+
+ /* calculate totals (+ when spell starts - when ends) */
+ sort `by'
+ cap foreach v of varlist `xvars' {
+ by `by': replace `v' = sum(``v'')
+ }
+ by `by': g `date1' = `date0'[_n + 1]
+
+ drop if `date0'>`date1'
+ drop _stack
+ drop if _count==0
+ order `by' `date0' `date1' `xvars'
+ format `date0' `f0'
+ format `date1' `f1'
+
+ cap for var `meanvars': replace X = X/_count
+
+ compress
+ }
+
+end \ No newline at end of file