1" Test for MzScheme interface and mzeval() function
2
3source check.vim
4CheckFeature mzscheme
5
6func 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
18endfunc
19
20func Test_mzscheme()
21  new
22  let lines =<< trim END
23    1 line 1
24    2 line 2
25    3 line 3
26  END
27  call setline(1, lines)
28
29  call MzRequire()
30  mz (define l '("item0" "dictionary with list OK" "item2"))
31  mz (define h (make-hash))
32  mz (hash-set! h "list" l)
33
34  call cursor(1, 1)
35  " change buffer contents
36  mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
37  call assert_equal('1 changed line 1', getline(1))
38
39  " scalar test
40  let tmp_string = mzeval('"string"')
41  let tmp_1000 = '1000'->mzeval()
42  call assert_equal('string1000', tmp_string .. tmp_1000)
43
44  " dictionary containing a list
45  call assert_equal('dictionary with list OK', mzeval("h")["list"][1])
46
47  call cursor(2, 1)
48  " circular list (at the same time test lists containing lists)
49  mz (set-car! (cddr l) l)
50  let l2 = mzeval("h")["list"]
51  call assert_equal(l2[2], l2)
52
53  " funcrefs
54  mz (define vim:max (vim-eval "function('max')"))
55  mz (define m (vim:max '(1 100 8)))
56  let m = mzeval('m')
57  call assert_equal(100, m)
58
59  close!
60endfunc
61
62" vim: shiftwidth=2 sts=2 expandtab
63