diff src/testdir/test_mzscheme.vim @ 21510:31cb78014fe4 v8.2.1305

patch 8.2.1305: some tests are still old style Commit: https://github.com/vim/vim/commit/622b3568fa1baf07671d31390815fb0a55a99891 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 27 20:02:41 2020 +0200 patch 8.2.1305: some tests are still old style Problem: Some tests are still old style. Solution: Convert tests 52 and 70 to new style. (Yegappan Lakshmanan, closes #6544) Fix error in FinishTesting().
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 Jul 2020 20:15:07 +0200
parents
children
line wrap: on
line diff
new file mode 100644
--- /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