-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscan-modules.feature
172 lines (159 loc) · 4.21 KB
/
scan-modules.feature
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Feature: company-ghc scan modules
Scenario: Scan simple import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import System.IO
"""
And I execute company-ghc-scan-modules
# Prelude always added
Then scanned modules are:
"""
(("System.IO") ("Prelude"))
"""
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import Data.Text
import System.IO
"""
And I execute company-ghc-scan-modules
# Prelude always added
Then scanned modules are:
"""
(("System.IO") ("Data.Text") ("Prelude"))
"""
Given the haskell buffer template
When I replace template "IMPORT" by ""
And I execute company-ghc-scan-modules
# Prelude always added
Then scanned modules are "(("Prelude"))"
Scenario: Scan qualified import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import qualified Data.Text
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.Text" . "Data.Text") ("Prelude"))
"""
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.Text.Lazy" . "TL") ("Data.Text" . "T") ("Prelude"))
"""
Scenario: Scan selective import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import Control.Monad ()
import Data.Text (Text, strip)
import Data.ByteString hiding (splitAt)
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.ByteString") ("Data.Text") ("Control.Monad") ("Prelude"))
"""
Scenario: Scan safe import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import safe Control.Applicative
import safe qualified Data.Monoid
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.Monoid" . "Data.Monoid") ("Control.Applicative") ("Prelude"))
"""
Scenario: Scan package import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import "mtl" Control.Monad.Trans
import safe qualified "mtl" Control.Monad.State as State
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Control.Monad.State" . "State") ("Control.Monad.Trans") ("Prelude"))
"""
Scenario: Scan import with newline
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import
Data.Text
import
safe
qualified
"bytestring"
Data.ByteString
as
B
(
readFile,
writeFile
)
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.ByteString" . "B") ("Data.Text") ("Prelude"))
"""
Scenario: Scan incomplete import
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import
import Control.Applicative
import
import Control.
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Control.") ("Control.Applicative") ("Prelude"))
"""
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
import Control.Applicative ((<$>),
import Data.Text
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.Text") ("Control.Applicative") ("Prelude"))
"""
Given the buffer is empty
When I insert:
"""
import Control.Monad
import qualified Data.Map as M (
"""
And I execute company-ghc-scan-modules
Then scanned modules are:
"""
(("Data.Map" . "M") ("Control.Monad") ("Prelude"))
"""
Scenario: Not scan import in string,comment
Given the haskell buffer template
When I replace template "IMPORT" by:
"""
{-
import Data.Text
-}
"import Data.ByteString"
"""
And I execute company-ghc-scan-modules
Then scanned modules are "(("Prelude"))"