2050
|
1 Smoke test for MzScheme interface and mzeval() function
|
|
2
|
|
3 STARTTEST
|
|
4 :so mzscheme.vim
|
|
5 :set nocompatible viminfo+=nviminfo
|
|
6 :function! MzRequire()
|
|
7 :redir => l:mzversion
|
|
8 :mz (version)
|
|
9 :redir END
|
|
10 :if strpart(l:mzversion, 1, 1) < "4"
|
|
11 :" MzScheme versions < 4.x:
|
|
12 :mz (require (prefix vim- vimext))
|
|
13 :else
|
|
14 :" newer versions:
|
|
15 :mz (require (prefix-in vim- 'vimext))
|
|
16 :mz (require r5rs)
|
|
17 :endif
|
|
18 :endfunction
|
|
19 :silent call MzRequire()
|
|
20 :mz (define l '("item0" "dictionary with list OK" "item2"))
|
|
21 :mz (define h (make-hash))
|
|
22 :mz (hash-set! h "list" l)
|
|
23 /^1
|
|
24 :" change buffer contents
|
|
25 :mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
|
|
26 :" scalar test
|
|
27 :let tmp_string = mzeval('"string"')
|
|
28 :let tmp_1000 = mzeval('1000')
|
|
29 :if tmp_string . tmp_1000 == "string1000"
|
|
30 :let scalar_res = "OK"
|
|
31 :else
|
|
32 :let scalar_res = "FAILED"
|
|
33 :endif
|
|
34 :call append(search("^1"), "scalar test " . scalar_res)
|
|
35 :" dictionary containing a list
|
|
36 :let tmp = mzeval("h")["list"][1]
|
|
37 :/^2/put =tmp
|
|
38 :" circular list (at the same time test lists containing lists)
|
|
39 :mz (set-car! (cddr l) l)
|
|
40 :let l2 = mzeval("h")["list"]
|
4088
|
41 :if l2[2] == l2
|
2050
|
42 :let res = "OK"
|
|
43 :else
|
4074
|
44 :let res = "FAILED: " . l2[2]
|
2050
|
45 :endif
|
|
46 :call setline(search("^3"), "circular test " . res)
|
4074
|
47 :" funcrefs
|
|
48 :mz (define vim:max (vim-eval "function('max')"))
|
|
49 :mz (define m (vim:max '(1 100 8)))
|
|
50 :let m = mzeval('m')
|
|
51 :if m == 100
|
|
52 :let fref_res = "OK"
|
|
53 :else
|
|
54 :let fref_res = "FAILED: " . m
|
|
55 :end
|
|
56 :call append(line('$'), 'funcrefs '. fref_res)
|
2050
|
57 :?^1?,$w! test.out
|
|
58 :qa!
|
|
59 ENDTEST
|
|
60
|
|
61 1 line 1
|
|
62 2 line 2
|
|
63 3 line 3
|