Mercurial > vim
annotate src/testdir/test_cd.vim @ 16336:b1e69c9e4c67 v8.1.1173
patch 8.1.1173: suspend test has duplicated lines
commit https://github.com/vim/vim/commit/a8356bc1734195d130c6eeaf4858356ae3a3f722
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 14 14:31:11 2019 +0200
patch 8.1.1173: suspend test has duplicated lines
Problem: Suspend test has duplicated lines.
Solution: Use a function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Apr 2019 14:45:04 +0200 |
parents | a1d21fc6e457 |
children | bcc343175103 |
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 |