annotate src/testdir/test_cd.vim @ 15062:3a94f7918980 v8.1.0542

patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account commit https://github.com/vim/vim/commit/f951416a8396a54bbbe21de1a8b16716428549f2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 22 03:08:29 2018 +0100 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account Problem: shiftwidth() does not take 'vartabstop' into account. Solution: Use the cursor position or a position explicitly passed. Also make >> and << work better with 'vartabstop'. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Thu, 22 Nov 2018 03:15:10 +0100
parents a1d21fc6e457
children bcc343175103
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for :cd
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_cd_large_path()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " This used to crash with a heap write overflow.
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 call assert_fails('cd ' . repeat('x', 5000), 'E472:')
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endfunc
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_cd_up_and_down()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let path = getcwd()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 cd ..
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
11 call assert_notequal(path, getcwd())
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 exe 'cd ' . path
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(path, getcwd())
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 endfunc
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
15
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
16 func Test_cd_no_arg()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
17 if has('unix')
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
18 " Test that cd without argument goes to $HOME directory on Unix systems.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
19 let path = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
20 cd
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
21 call assert_equal($HOME, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
22 call assert_notequal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
23 exe 'cd ' . path
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
24 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
25 else
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
26 " Test that cd without argument echoes cwd on non-Unix systems.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
27 call assert_match(getcwd(), execute('cd'))
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
28 endif
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
29 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
30
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
31 func Test_cd_minus()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
32 " Test the :cd - goes back to the previous directory.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
33 let path = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
34 cd ..
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
35 let path_dotdot = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
36 call assert_notequal(path, path_dotdot)
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
37 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
38 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
39 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
40 call assert_equal(path_dotdot, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
41 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
42 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
43 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
44
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
45 func Test_cd_with_cpo_chdir()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
46 e Xfoo
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
47 call setline(1, 'foo')
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
48 let path = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
49 set cpo+=.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
50
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
51 " :cd should fail when buffer is modified and 'cpo' contains dot.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
52 call assert_fails('cd ..', 'E747:')
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
53 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
54
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
55 " :cd with exclamation mark should succeed.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
56 cd! ..
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
57 call assert_notequal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
58
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
59 " :cd should succeed when buffer has been written.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
60 w!
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
61 exe 'cd ' . path
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
62 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
63
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
64 call delete('Xfoo')
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
65 set cpo&
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
66 bw!
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
67 endfunc