annotate src/testdir/test_pyx2.vim @ 32788:80152cf7ce63 v9.0.1710

patch 9.0.1710: scrolloff options work slightly different Commit: https://github.com/vim/vim/commit/4a8eb6e7a9df10f79bf95301ced012f0d6a13088 Author: Christian Brabandt <cb@256bit.org> Date: Sun Aug 13 19:43:42 2023 +0200 patch 9.0.1710: scrolloff options work slightly different Problem: sidescrolloff and scrolloff options work slightly different than other global-local options Solution: Make it behave consistent for all global-local options It was noticed, that sidescrolloff and scrolloff options behave differently in comparison to other global-local window options like 'listchars' So make those two behave like other global-local options. Also add some extra documentation for a few special local-window options. Add a few tests to make sure all global-local window options behave similar closes: #12956 closes: #12643 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 13 Aug 2023 20:00:04 +0200
parents 5f9c2c7d3d73
children a0b0c1e07064
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for pyx* commands and functions with Python 2.
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 set pyx=2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
5 CheckFeature python
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 let s:py2pattern = '^2\.[0-7]\.\d\+'
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 let s:py3pattern = '^3\.\d\+\.\d\+'
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 func Test_has_pythonx()
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_true(has('pythonx'))
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 endfunc
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 func Test_pyx()
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 redir => var
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
18 pyx << trim EOF
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
19 import sys
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
20 print(sys.version)
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
21 EOF
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_match(s:py2pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endfunc
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 func Test_pyxdo()
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 pyx import sys
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 enew
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 pyxdo return sys.version.split("\n")[0]
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_match(s:py2pattern, split(getline('.'))[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 endfunc
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 func Test_pyxeval()
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 pyx import sys
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
37 call assert_match(s:py2pattern, split('sys.version'->pyxeval())[0])
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 endfunc
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 func Test_pyxfile()
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 " No special comments nor shebangs
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 redir => var
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 pyxfile pyxfile/pyx.py
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_match(s:py2pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " Python 2 special comment
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 redir => var
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 pyxfile pyxfile/py2_magic.py
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_match(s:py2pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 " Python 2 shebang
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 redir => var
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 pyxfile pyxfile/py2_shebang.py
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_match(s:py2pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 if has('python3')
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " Python 3 special comment
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 redir => var
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 pyxfile pyxfile/py3_magic.py
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_match(s:py3pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 " Python 3 shebang
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 redir => var
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 pyxfile pyxfile/py3_shebang.py
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 redir END
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call assert_match(s:py3pattern, split(var)[0])
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 endfunc
16688
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
74
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
75 func Test_Catch_Exception_Message()
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
76 try
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
77 pyx raise RuntimeError( 'TEST' )
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
78 catch /.*/
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
79 call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
80 endtry
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 10722
diff changeset
81 endfunc
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
82
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
83 " Test for various heredoc syntaxes
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
84 func Test_pyx2_heredoc()
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
85 pyx << END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
86 result='A'
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
87 END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
88 pyx <<
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
89 result+='B'
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
90 .
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
91 pyx << trim END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
92 result+='C'
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
93 END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
94 pyx << trim
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
95 result+='D'
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
96 .
20233
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
97 pyx << trim eof
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
98 result+='E'
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
99 eof
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
100 call assert_equal('ABCDE', pyxeval('result'))
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
101 endfunc
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
102
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
103 " vim: shiftwidth=2 sts=2 expandtab