]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_writefile_function.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / test / test_writefile_function.vader
1 Before:
2   call ale#test#SetDirectory('/testplugin/test')
3
4   let g:new_line_test_file = tempname()
5
6 After:
7   noautocmd :e! ++ff=unix
8   setlocal buftype=nofile
9
10   if filereadable(g:new_line_test_file)
11     call delete(g:new_line_test_file)
12   endif
13
14   unlet! g:new_line_test_file
15
16   call ale#test#RestoreDirectory()
17
18 Given(A file with Windows line ending characters):
19   first\r
20   second\r
21   third\r
22
23 Execute(Carriage returns should be included for ale#util#Writefile):
24   call ale#test#SetFilename(g:new_line_test_file)
25
26   setlocal buftype=
27   noautocmd :w
28   noautocmd :e! ++ff=dos
29
30   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
31
32   AssertEqual
33   \ ["first\r", "second\r", "third\r", ''],
34   \ readfile(g:new_line_test_file, 'b')
35
36 Given(A file with extra carriage returns):
37   first\r\r
38   second\r\r\r
39   third\r
40   fourth
41
42 Execute(Carriage returns should be de-depulicated):
43   call ale#test#SetFilename(g:new_line_test_file)
44
45   setlocal buftype=
46   noautocmd :w
47   noautocmd :e! ++ff=dos
48
49   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
50
51   AssertEqual
52   \ ["first\r", "second\r", "third\r", "fourth\r", ''],
53   \ readfile(g:new_line_test_file, 'b')
54
55 Given(A file with Unix line ending characters):
56   first
57   second
58   third
59
60 Execute(Unix file lines should be written as normal):
61   call ale#test#SetFilename(g:new_line_test_file)
62
63   setlocal buftype=
64   noautocmd :w
65   noautocmd :e! ++ff=unix
66
67   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
68
69   AssertEqual
70   \ ['first', 'second', 'third', ''],
71   \ readfile(g:new_line_test_file, 'b')
72
73 Execute(Newline at end of file should be preserved even when nofixeol):
74   call ale#test#SetFilename(g:new_line_test_file)
75
76   setlocal buftype=
77   noautocmd :w
78   noautocmd :e! ++ff=unix
79   set eol
80   set nofixeol
81
82   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
83
84   AssertEqual
85   \ ['first', 'second', 'third', ''],
86   \ readfile(g:new_line_test_file, 'b')
87
88 Execute(Newline should not be appended on write when noeol and nofixeol):
89   call ale#test#SetFilename(g:new_line_test_file)
90
91   setlocal buftype=
92   noautocmd :w
93   noautocmd :e! ++ff=unix
94   set noeol
95   set nofixeol
96
97   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
98
99   AssertEqual
100   \ ['first', 'second', 'third'],
101   \ readfile(g:new_line_test_file, 'b')
102
103 Execute(Newline should be appended on write when noeol and fixeol):
104   call ale#test#SetFilename(g:new_line_test_file)
105
106   setlocal buftype=
107   noautocmd :w
108   noautocmd :e! ++ff=unix
109   set noeol
110   set fixeol
111
112   call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
113
114   AssertEqual
115   \ ['first', 'second', 'third', ''],
116   \ readfile(g:new_line_test_file, 'b')
117