blob: 87c25d4863f5ba4378e85995bbf5c4846a615bcf [file] [log] [blame]
Bram Moolenaar644fdff2010-05-30 13:26:21 +02001Tests for undo file.
2Since this script is sourced we need to explicitly break changes up in
3undo-able pieces. Do that by setting 'undolevels'.
4
5STARTTEST
6:so small.vim
7:"
8:" Test 'undofile': first a simple one-line change.
Bram Moolenaardd10ce92010-08-07 13:27:48 +02009:set nocompatible viminfo+=nviminfo visualbell
Bram Moolenaar00ec6852010-08-01 15:47:03 +020010:set ul=100 undofile nomore
Bram Moolenaar0ddd1b52014-08-16 17:34:34 +020011:set ff=unix
Bram Moolenaar644fdff2010-05-30 13:26:21 +020012:e! Xtestfile
13ggdGithis is one line:set ul=100
14:s/one/ONE/
15:set ul=100
16:w
17:bwipe!
18:e Xtestfile
19u:.w! test.out
20:"
21:" Test 'undofile', change in original file fails check
22:set noundofile
23:e! Xtestfile
24:s/line/Line/
25:w
26:set undofile
27:bwipe!
28:e Xtestfile
Bram Moolenaarf4274fe2010-08-01 17:37:17 +020029:" TODO: this beeps
Bram Moolenaar644fdff2010-05-30 13:26:21 +020030u:.w >>test.out
31:"
32:" Test 'undofile', add 10 lines, delete 6 lines, undo 3
33:set undofile
34ggdGione
35two
36three
37four
38five
39six
40seven
41eight
42nine
43ten:set ul=100
443Gdd:set ul=100
45dd:set ul=100
46dd:set ul=100
47dd:set ul=100
48dd:set ul=100
49dd:set ul=100
50:w
51:bwipe!
52:e Xtestfile
53uuu:w >>test.out
54:"
Bram Moolenaar374d32d2012-01-04 19:34:37 +010055:" Test that reading the undofiles when setting undofile works
56:set noundofile ul=0
57i
58u:e! Xtestfile
59:set undofile ul=100
60uuuuuu:w >>test.out
Bram Moolenaar0e1673a2010-07-30 21:49:07 +020061:" And now with encryption, cryptmethod=zip
Bram Moolenaara3ff49f2010-05-30 22:48:02 +020062:e! Xtestfile
Bram Moolenaar0e1673a2010-07-30 21:49:07 +020063:set undofile cm=zip
Bram Moolenaarf4274fe2010-08-01 17:37:17 +020064ggdGimonday
Bram Moolenaara3ff49f2010-05-30 22:48:02 +020065tuesday
66wednesday
67thursday
68friday:set ul=100
69kkkdd:set ul=100
70dd:set ul=100
71dd:set ul=100
72:X
73foobar
74foobar
75:w!
76:bwipe!
77:e Xtestfile
78foobar
79:set key=
80uu:w >>test.out
81:"
82:"
Bram Moolenaar0e1673a2010-07-30 21:49:07 +020083:" With encryption, cryptmethod=blowfish
Bram Moolenaara3ff49f2010-05-30 22:48:02 +020084:e! Xtestfile
Bram Moolenaar8f4ac012014-08-10 13:38:34 +020085rubbish
Bram Moolenaar0e1673a2010-07-30 21:49:07 +020086:set undofile cm=blowfish
Bram Moolenaarf4274fe2010-08-01 17:37:17 +020087ggdGijan
Bram Moolenaara3ff49f2010-05-30 22:48:02 +020088feb
89mar
90apr
91jun:set ul=100
92kk0ifoo :set ul=100
93dd:set ul=100
94ibar :set ul=100
95:X
96foobar
97foobar
98:w!
99:bwipe!
100:e Xtestfile
101foobar
102:set key=
103/bar
104:.w >>test.out
105u:.w >>test.out
106u:.w >>test.out
107u:.w >>test.out
108:"
Bram Moolenaar8f4ac012014-08-10 13:38:34 +0200109:" With encryption, cryptmethod=blowfish2
110:e! Xtestfile
111rubbish
112:set undofile cm=blowfish2
113ggdGijan
114feb
115mar
116apr
117jun:set ul=100
118kk0ifoo :set ul=100
119dd:set ul=100
120ibar :set ul=100
121:X
122foo2bar
123foo2bar
124:w!
125:bwipe!
126:e Xtestfile
127foo2bar
128:set key=
129/bar
130:.w >>test.out
131u:.w >>test.out
132u:.w >>test.out
133u:.w >>test.out
134:"
Bram Moolenaar644fdff2010-05-30 13:26:21 +0200135:" Rename the undo file so that it gets cleaned up.
Bram Moolenaar206f0112014-03-12 16:51:55 +0100136:if has("vms")
137: call rename("_un_Xtestfile", "Xtestundo")
138:else
139: call rename(".Xtestfile.un~", "Xtestundo")
140:endif
Bram Moolenaar644fdff2010-05-30 13:26:21 +0200141:qa!
142ENDTEST
143
1441111 -----
1452222 -----
146
147123456789