summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_mzscheme.vim
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:09:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:09:20 +0000
commit029f72b1a93430b24b88eb3a72c6114d9f149737 (patch)
tree765d5c2041967f9c6fef195fe343d9234a030e90 /src/testdir/test_mzscheme.vim
parentInitial commit. (diff)
downloadvim-029f72b1a93430b24b88eb3a72c6114d9f149737.tar.xz
vim-029f72b1a93430b24b88eb3a72c6114d9f149737.zip
Adding upstream version 2:9.1.0016.upstream/2%9.1.0016
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/testdir/test_mzscheme.vim')
-rw-r--r--src/testdir/test_mzscheme.vim62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/testdir/test_mzscheme.vim b/src/testdir/test_mzscheme.vim
new file mode 100644
index 0000000..0bc9842
--- /dev/null
+++ b/src/testdir/test_mzscheme.vim
@@ -0,0 +1,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