blob: 0bc98421d305c483e46dbb69121615db6bb2209f (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
" Test for MzScheme interface and mzeval() function
source check.vim
CheckFeature mzscheme
func MzRequire()
redir => l:mzversion
mz (version)
redir END
if strpart(l:mzversion, 1, 1) < "4"
" MzScheme versions < 4.x:
mz (require (prefix vim- vimext))
else
" newer versions:
mz (require (prefix-in vim- 'vimext))
mz (require r5rs)
endif
endfunc
func Test_mzscheme()
new
let lines =<< trim END
1 line 1
2 line 2
3 line 3
END
call setline(1, lines)
call MzRequire()
mz (define l '("item0" "dictionary with list OK" "item2"))
mz (define h (make-hash))
mz (hash-set! h "list" l)
call cursor(1, 1)
" change buffer contents
mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
call assert_equal('1 changed line 1', getline(1))
" scalar test
let tmp_string = mzeval('"string"')
let tmp_1000 = '1000'->mzeval()
call assert_equal('string1000', tmp_string .. tmp_1000)
" dictionary containing a list
call assert_equal('dictionary with list OK', mzeval("h")["list"][1])
call cursor(2, 1)
" circular list (at the same time test lists containing lists)
mz (set-car! (cddr l) l)
let l2 = mzeval("h")["list"]
call assert_equal(l2[2], l2)
" funcrefs
mz (define vim:max (vim-eval "function('max')"))
mz (define m (vim:max '(1 100 8)))
let m = mzeval('m')
call assert_equal(100, m)
close!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
|