summaryrefslogtreecommitdiff
path: root/test/fixers/test_uncrustify_fixer_callback.vader
blob: c101a31a0dc41cdd36e40664a2d6d1d4feab614d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Before:
  Save g:ale_c_uncrustify_executable

  " Use an invalid global executable, so we don't match it.
  let g:ale_c_uncrustify_executable = 'xxxinvalid'

  call ale#test#SetDirectory('/testplugin/test/fixers')

After:
  Restore

  call ale#test#RestoreDirectory()

Execute(The clang-format callback should return the correct default values):
  call ale#test#SetFilename('../test-files/c/dummy.c')

  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \       . ' --no-backup -l C'
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

Execute(The uncrustify callback should include any additional options):
  call ale#test#SetFilename('../test-files/c/dummy.c')
  let b:ale_c_uncrustify_options = '--some-option'

  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l C --some-option',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

Execute(The uncrustify callback should set proper language):
  unlet b:ale_c_uncrustify_options

  set filetype=c
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l C',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=cpp
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l CPP',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=cs
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l CS',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=objc
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l OC',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=objcpp
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l OC+',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=d
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l D',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=java
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l JAVA',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=vala
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l VALA',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))

  set filetype=p
  AssertEqual
  \ {
  \   'command': ale#Escape(g:ale_c_uncrustify_executable)
  \     . ' --no-backup -l PAWN',
  \ },
  \ ale#fixers#uncrustify#Fix(bufnr(''))