annotate src/testdir/test_mzscheme.vim @ 26791:43989ce10dd1

Added tag v8.2.3923 for changeset 83b35c75c21a8904aea5826f74243986eee140da
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 Dec 2021 18:30:05 +0100
parents 31cb78014fe4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21510
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test for MzScheme interface and mzeval() function
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 source check.vim
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 CheckFeature mzscheme
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func MzRequire()
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 redir => l:mzversion
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 mz (version)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 redir END
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 if strpart(l:mzversion, 1, 1) < "4"
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 " MzScheme versions < 4.x:
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 mz (require (prefix vim- vimext))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 else
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 " newer versions:
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 mz (require (prefix-in vim- 'vimext))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 mz (require r5rs)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 endif
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 endfunc
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 func Test_mzscheme()
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 new
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 let lines =<< trim END
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 1 line 1
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 2 line 2
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 3 line 3
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 END
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call setline(1, lines)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call MzRequire()
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 mz (define l '("item0" "dictionary with list OK" "item2"))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 mz (define h (make-hash))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 mz (hash-set! h "list" l)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call cursor(1, 1)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 " change buffer contents
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call assert_equal('1 changed line 1', getline(1))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 " scalar test
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 let tmp_string = mzeval('"string"')
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 let tmp_1000 = '1000'->mzeval()
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 call assert_equal('string1000', tmp_string .. tmp_1000)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 " dictionary containing a list
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call assert_equal('dictionary with list OK', mzeval("h")["list"][1])
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call cursor(2, 1)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 " circular list (at the same time test lists containing lists)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 mz (set-car! (cddr l) l)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 let l2 = mzeval("h")["list"]
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 call assert_equal(l2[2], l2)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 " funcrefs
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 mz (define vim:max (vim-eval "function('max')"))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 mz (define m (vim:max '(1 100 8)))
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 let m = mzeval('m')
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call assert_equal(100, m)
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 close!
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 endfunc
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
31cb78014fe4 patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 " vim: shiftwidth=2 sts=2 expandtab