summaryrefslogtreecommitdiff
path: root/test/handler/test_swipl_handler.vader
blob: 9e425cf604b9321078ea5cffafe0ba28b70c55ea (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
Before:
  runtime ale_linters/prolog/swipl.vim

After:
  call ale#linter#Reset()

Execute (The swipl handler should handle oneline warning / error):
  call ale#test#SetFilename('test.pl')
  AssertEqual
  \ [
  \   {
  \     'lnum': 5,
  \     'col': 1,
  \     'text': 'Syntax error: Operator expected',
  \     'type': 'E',
  \   },
  \ ],
  \ ale_linters#prolog#swipl#Handle(bufnr(''), [
  \   'ERROR: /path/to/test.pl:5:1: Syntax error: Operator expected',
  \ ])

Execute (The swipl handler should handle a warning / error of two lines):
  call ale#test#SetFilename('test.pl')
  AssertEqual
  \ [
  \   {
  \     'lnum': 9,
  \     'col': 0,
  \     'text': 'Singleton variables: [M]',
  \     'type': 'W',
  \   },
  \ ],
  \ ale_linters#prolog#swipl#Handle(bufnr(''), [
  \   'Warning: /path/to/test.pl:9:',
  \   '        Singleton variables: [M]',
  \ ])

Execute (The swipl handler should join three or more lines with '. '):
  call ale#test#SetFilename('test.pl')
  AssertEqual
  \ [
  \   {
  \     'lnum': 10,
  \     'col': 0,
  \     'text': 'Clauses of fib/2 are not together in the source-file. Earlier definition at /path/to/test.pl:7. Current predicate: f/0. Use :- discontiguous fib/2. to suppress this message',
  \     'type': 'W',
  \   },
  \ ],
  \ ale_linters#prolog#swipl#Handle(bufnr(''), [
  \   'Warning: /path/to/test.pl:10:',
  \   '        Clauses of fib/2 are not together in the source-file',
  \   '          Earlier definition at /path/to/test.pl:7',
  \   '          Current predicate: f/0',
  \   '          Use :- discontiguous fib/2. to suppress this message',
  \ ])

Execute (The swipl handler should ignore warnings / errors 'No permission to call sandboxed ...'):
  call ale#test#SetFilename('test.pl')
  AssertEqual
  \ [],
  \ ale_linters#prolog#swipl#Handle(bufnr(''), [
  \   'ERROR: /path/to/test.pl:11:',
  \   '        No permission to call sandboxed `''$set_predicate_attribute''(_G3416:_G3417,_G3413,_G3414)''',
  \   '        Reachable from:',
  \   '                  system:''$set_pattr''(A,B,C,D)',
  \   '                  system:''$set_pattr''(vimscript:A,B,C)',
  \   '                  vimscript: (multifile A)',
  \   'ERROR: /path/to/test.pl:12:',
  \   '        No permission to call sandboxed `''$set_predicate_attribute''(_G205:_G206,_G202,_G203)''',
  \   '        Reachable from:',
  \   '                  system:''$set_pattr''(A,B,C,D)',
  \   '                  system:''$set_pattr''(vimscript:A,B,C)',
  \   '                  vimscript: (multifile A)',
  \   'ERROR: /path/to/test.pl:13:',
  \   '        No permission to call sandboxed `''$set_predicate_attribute''(_G1808:_G1809,_G1805,_G1806)''',
  \   '        Reachable from:',
  \   '                  system:''$set_pattr''(A,B,C,D)',
  \   '                  system:''$set_pattr''(vimscript:A,B,C)',
  \   '                  vimscript: (multifile A)',
  \ ])

Execute (The swipl handler should handle a warning / error with no line number):
  call ale#test#SetFilename('test.pl')
  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 0,
  \     'text': 'Exported procedure module_name:pred/0 is not defined',
  \     'type': 'E',
  \   },
  \ ],
  \ ale_linters#prolog#swipl#Handle(bufnr(''), [
  \   'ERROR: Exported procedure module_name:pred/0 is not defined',
  \ ])