annotate src/testdir/test_mzscheme.vim @ 35308:22c03485f222 v9.1.0456

patch 9.1.0456: Left shift is incorrect with vartabstop and shiftwidth=0 Commit: https://github.com/vim/vim/commit/88d4f255b7b7a19bb4f6489e0ad0956e47d51fed Author: Gary Johnson <garyjohn@spocom.com> Date: Sat Jun 1 20:51:33 2024 +0200 patch 9.1.0456: Left shift is incorrect with vartabstop and shiftwidth=0 Problem: Left shift is incorrect with vartabstop and shiftwidth=0 Solution: make tabstop_at() function aware of shift direction (Gary Johnson) The problem was that with 'vartabstop' set and 'shiftwidth' equal 0, left shifts using << were shifting the line to the wrong column. The tabstop to the right of the first character in the line was being used as the shift amount instead of the tabstop to the left of that first character. The reason was that the tabstop_at() function always returned the value of the tabstop to the right of the given column and was not accounting for the direction of the shift. The solution was to make tabstop_at() aware of the direction of the shift and to choose the tabtop accordingly. A test was added to check this behavior and make sure it doesn't regress. While at it, also fix a few indentation/alignment issues. fixes: #14864 closes: #14887 Signed-off-by: Gary Johnson <garyjohn@spocom.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 01 Jun 2024 21:00:03 +0200
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