@@ -80,7 +80,7 @@ ghcmodSpec =
80
80
-- ghc-mod tries to load the test file in the context of the hie project if we do not cd first.
81
81
testCommand testPlugins act " ghcmod" " info" arg res
82
82
83
- -- ---------------------------------
83
+ -- ------------------------------------------- ---------------------------------
84
84
85
85
it " runs the type command, find type" $ withCurrentDirectory " ./test/testdata" $ do
86
86
fp <- makeAbsolute " HaReRename.hs"
@@ -90,8 +90,10 @@ ghcmodSpec =
90
90
liftToGhc $ newTypeCmd (toPos (5 ,9 )) uri
91
91
arg = TP False uri (toPos (5 ,9 ))
92
92
res = IdeResultOk
93
- [(Range (toPos (5 ,9 )) (toPos (5 ,10 )), " Int" )
93
+ [ (Range (toPos (5 ,9 )) (toPos (5 ,10 )), " Int" )
94
+ , (Range (toPos (5 ,1 )) (toPos (5 ,14 )), " Int -> Int" )
94
95
]
96
+
95
97
testCommand testPlugins act " ghcmod" " type" arg res
96
98
it " runs the type command, find function type" $ withCurrentDirectory " ./test/testdata" $ do
97
99
fp <- makeAbsolute " HaReRename.hs"
@@ -101,7 +103,8 @@ ghcmodSpec =
101
103
liftToGhc $ newTypeCmd (toPos (2 ,11 )) uri
102
104
arg = TP False uri (toPos (2 ,11 ))
103
105
res = IdeResultOk
104
- [(Range (toPos (2 , 8 )) (toPos (2 ,16 )), " String -> IO ()" )
106
+ [ (Range (toPos (2 , 8 )) (toPos (2 ,16 )), " String -> IO ()" )
107
+ , (Range (toPos (2 , 1 )) (toPos (2 ,24 )), " IO ()" )
105
108
]
106
109
testCommand testPlugins act " ghcmod" " type" arg res
107
110
@@ -115,7 +118,6 @@ ghcmodSpec =
115
118
res = IdeResultOk []
116
119
testCommand testPlugins act " ghcmod" " type" arg res
117
120
118
- -- ----------------------------------------------------------------------------
119
121
it " runs the type command, simple" $ withCurrentDirectory " ./test/testdata" $ do
120
122
fp <- makeAbsolute " Types.hs"
121
123
let uri = filePathToUri fp
@@ -125,6 +127,7 @@ ghcmodSpec =
125
127
arg = TP False uri (toPos (6 ,16 ))
126
128
res = IdeResultOk
127
129
[ (Range (toPos (6 , 16 )) (toPos (6 ,17 )), " Int" )
130
+ , (Range (toPos (6 , 1 )) (toPos (7 , 16 )), " Maybe Int -> Int" )
128
131
]
129
132
testCommand testPlugins act " ghcmod" " type" arg res
130
133
@@ -138,7 +141,7 @@ ghcmodSpec =
138
141
res = IdeResultOk
139
142
[ (Range (toPos (6 , 6 )) (toPos (6 , 12 )), " Maybe Int" )
140
143
, (Range (toPos (6 , 5 )) (toPos (6 , 13 )), " Maybe Int" )
141
- -- TODO: why is this happening?
144
+ , ( Range (toPos ( 6 , 1 )) (toPos ( 7 , 16 )), " Maybe Int -> Int " )
142
145
]
143
146
testCommand testPlugins act " ghcmod" " type" arg res
144
147
@@ -153,7 +156,7 @@ ghcmodSpec =
153
156
[ (Range (toPos (6 , 11 )) (toPos (6 , 12 )), " Int" )
154
157
, (Range (toPos (6 , 6 )) (toPos (6 , 12 )), " Maybe Int" )
155
158
, (Range (toPos (6 , 5 )) (toPos (6 , 13 )), " Maybe Int" )
156
- -- TODO: why is this happening?
159
+ , ( Range (toPos ( 6 , 1 )) (toPos ( 7 , 16 )), " Maybe Int -> Int " )
157
160
]
158
161
testCommand testPlugins act " ghcmod" " type" arg res
159
162
@@ -166,6 +169,7 @@ ghcmodSpec =
166
169
arg = TP False uri (toPos (7 ,5 ))
167
170
res = IdeResultOk
168
171
[ (Range (toPos (7 , 5 )) (toPos (7 , 12 )), " Maybe Int" )
172
+ , (Range (toPos (6 , 1 )) (toPos (7 , 16 )), " Maybe Int -> Int" )
169
173
]
170
174
testCommand testPlugins act " ghcmod" " type" arg res
171
175
@@ -178,6 +182,7 @@ ghcmodSpec =
178
182
arg = TP False uri (toPos (7 ,15 ))
179
183
res = IdeResultOk
180
184
[ (Range (toPos (7 , 15 )) (toPos (7 , 16 )), " Int" )
185
+ , (Range (toPos (6 , 1 )) (toPos (7 , 16 )), " Maybe Int -> Int" )
181
186
]
182
187
testCommand testPlugins act " ghcmod" " type" arg res
183
188
@@ -190,6 +195,7 @@ ghcmodSpec =
190
195
arg = TP False uri (toPos (10 ,5 ))
191
196
res = IdeResultOk
192
197
[ (Range (toPos (10 , 5 )) (toPos (10 , 6 )), " Maybe Int" )
198
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
193
199
]
194
200
testCommand testPlugins act " ghcmod" " type" arg res
195
201
@@ -203,6 +209,7 @@ ghcmodSpec =
203
209
res = IdeResultOk
204
210
[ (Range (toPos (10 , 14 )) (toPos (10 , 15 )), " Maybe Int" )
205
211
, (Range (toPos (10 , 9 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
212
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
206
213
]
207
214
testCommand testPlugins act " ghcmod" " type" arg res
208
215
@@ -216,6 +223,7 @@ ghcmodSpec =
216
223
res = IdeResultOk
217
224
[ (Range (toPos (11 , 5 )) (toPos (11 , 11 )), " Maybe Int" )
218
225
, (Range (toPos (10 , 9 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
226
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
219
227
]
220
228
testCommand testPlugins act " ghcmod" " type" arg res
221
229
@@ -230,6 +238,7 @@ ghcmodSpec =
230
238
[ (Range (toPos (11 , 10 )) (toPos (11 , 11 )), " Int" )
231
239
, (Range (toPos (11 , 5 )) (toPos (11 , 11 )), " Maybe Int" )
232
240
, (Range (toPos (10 , 9 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
241
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
233
242
]
234
243
testCommand testPlugins act " ghcmod" " type" arg res
235
244
@@ -243,6 +252,7 @@ ghcmodSpec =
243
252
res = IdeResultOk
244
253
[ (Range (toPos (11 , 17 )) (toPos (11 , 18 )), " Int -> Int -> Int" )
245
254
, (Range (toPos (10 , 9 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
255
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
246
256
]
247
257
testCommand testPlugins act " ghcmod" " type" arg res
248
258
@@ -256,6 +266,7 @@ ghcmodSpec =
256
266
res = IdeResultOk
257
267
[ (Range (toPos (12 , 5 )) (toPos (12 , 12 )), " Maybe Int" )
258
268
, (Range (toPos (10 , 9 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
269
+ , (Range (toPos (10 , 1 )) (toPos (12 , 17 )), " Maybe Int -> Int" )
259
270
]
260
271
testCommand testPlugins act " ghcmod" " type" arg res
261
272
@@ -268,6 +279,7 @@ ghcmodSpec =
268
279
arg = TP False uri (toPos (16 ,5 ))
269
280
res = IdeResultOk
270
281
[ (Range (toPos (16 , 5 )) (toPos (16 , 6 )), " Int" )
282
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
271
283
]
272
284
testCommand testPlugins act " ghcmod" " type" arg res
273
285
@@ -280,6 +292,7 @@ ghcmodSpec =
280
292
arg = TP False uri (toPos (16 ,10 ))
281
293
res = IdeResultOk
282
294
[ (Range (toPos (16 , 10 )) (toPos (16 , 11 )), " Maybe Int" )
295
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
283
296
]
284
297
testCommand testPlugins act " ghcmod" " type" arg res
285
298
@@ -292,6 +305,8 @@ ghcmodSpec =
292
305
arg = TP False uri (toPos (17 ,13 ))
293
306
res = IdeResultOk
294
307
[ (Range (toPos (17 , 13 )) (toPos (17 , 19 )), " Int -> Maybe Int" )
308
+ , (Range (toPos (17 , 9 )) (toPos (17 , 28 )), " Maybe Int" )
309
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
295
310
]
296
311
testCommand testPlugins act " ghcmod" " type" arg res
297
312
@@ -304,6 +319,8 @@ ghcmodSpec =
304
319
arg = TP False uri (toPos (17 ,21 ))
305
320
res = IdeResultOk
306
321
[ (Range (toPos (17 , 21 )) (toPos (17 , 22 )), " Int" )
322
+ , (Range (toPos (17 , 9 )) (toPos (17 , 28 )), " Maybe Int" )
323
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
307
324
]
308
325
testCommand testPlugins act " ghcmod" " type" arg res
309
326
@@ -314,9 +331,10 @@ ghcmodSpec =
314
331
_ <- setTypecheckedModule uri
315
332
liftToGhc $ newTypeCmd (toPos (17 ,9 )) uri
316
333
arg = TP False uri (toPos (17 ,9 ))
317
- res = IdeResultOk []
318
- -- TODO: do we want this?
319
- -- (Range (toPos (17, 9)) (toPos (17, 10)), "Maybe Int")
334
+ res = IdeResultOk
335
+ [ (Range (toPos (17 , 9 )) (toPos (17 , 28 )), " Maybe Int" )
336
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
337
+ ]
320
338
testCommand testPlugins act " ghcmod" " type" arg res
321
339
322
340
it " runs the type command, do expr, function type" $ withCurrentDirectory " ./test/testdata" $ do
@@ -328,6 +346,7 @@ ghcmodSpec =
328
346
arg = TP False uri (toPos (18 ,10 ))
329
347
res = IdeResultOk
330
348
[ (Range (toPos (18 , 10 )) (toPos (18 , 11 )), " Maybe Int" )
349
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
331
350
]
332
351
testCommand testPlugins act " ghcmod" " type" arg res
333
352
@@ -340,6 +359,7 @@ ghcmodSpec =
340
359
arg = TP False uri (toPos (18 ,5 ))
341
360
res = IdeResultOk
342
361
[ (Range (toPos (18 , 5 )) (toPos (18 , 6 )), " Int" )
362
+ , (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int" )
343
363
]
344
364
testCommand testPlugins act " ghcmod" " type" arg res
345
365
@@ -350,20 +370,8 @@ ghcmodSpec =
350
370
_ <- setTypecheckedModule uri
351
371
liftToGhc $ newTypeCmd (toPos (15 ,5 )) uri
352
372
arg = TP False uri (toPos (15 ,5 ))
353
- res = IdeResultOk []
354
- -- TODO: the type is known, why not in the map?
355
- -- [(Range (toPos (15, 1)) (toPos (14, 11)), "Maybe Int -> Maybe Int")]
356
- testCommand testPlugins act " ghcmod" " type" arg res
357
-
358
- it " runs the type command, function parameter" $ withCurrentDirectory " ./test/testdata" $ do
359
- fp <- makeAbsolute " Types.hs"
360
- let uri = filePathToUri fp
361
- act = do
362
- _ <- setTypecheckedModule uri
363
- liftToGhc $ newTypeCmd (toPos (22 ,10 )) uri
364
- arg = TP False uri (toPos (22 ,10 ))
365
373
res = IdeResultOk
366
- [ (Range (toPos (22 , 10 )) (toPos (22 , 11 )), " a -> a " )
374
+ [ (Range (toPos (15 , 1 )) (toPos (19 , 19 )), " Maybe Int -> Maybe Int " )
367
375
]
368
376
testCommand testPlugins act " ghcmod" " type" arg res
369
377
@@ -376,6 +384,7 @@ ghcmodSpec =
376
384
arg = TP False uri (toPos (22 ,10 ))
377
385
res = IdeResultOk
378
386
[ (Range (toPos (22 , 10 )) (toPos (22 , 11 )), " a -> a" )
387
+ , (Range (toPos (22 , 1 )) (toPos (22 , 19 )), " (a -> a) -> a -> a" )
379
388
]
380
389
testCommand testPlugins act " ghcmod" " type" arg res
381
390
@@ -388,6 +397,8 @@ ghcmodSpec =
388
397
arg = TP False uri (toPos (25 ,26 ))
389
398
res = IdeResultOk
390
399
[ (Range (toPos (25 , 26 )) (toPos (25 , 27 )), " (b -> c) -> (a -> b) -> a -> c" )
400
+ , (Range (toPos (25 , 20 )) (toPos (25 , 29 )), " a -> c" )
401
+ , (Range (toPos (25 , 1 )) (toPos (25 , 34 )), " (b -> c) -> (a -> b) -> a -> c" )
391
402
]
392
403
testCommand testPlugins act " ghcmod" " type" arg res
393
404
@@ -398,9 +409,10 @@ ghcmodSpec =
398
409
_ <- setTypecheckedModule uri
399
410
liftToGhc $ newTypeCmd (toPos (25 ,20 )) uri
400
411
arg = TP False uri (toPos (25 ,20 ))
401
- res = IdeResultOk []
402
- -- TODO: do we want this?
403
- -- (Range (toPos (25, 20)) (toPos (25, 21)), "a -> c")
412
+ res = IdeResultOk
413
+ [ (Range (toPos (25 , 20 )) (toPos (25 , 29 )), " a -> c" )
414
+ , (Range (toPos (25 , 1 )) (toPos (25 , 34 )), " (b -> c) -> (a -> b) -> a -> c" )
415
+ ]
404
416
testCommand testPlugins act " ghcmod" " type" arg res
405
417
406
418
it " runs the type command, let binding, type of function" $ withCurrentDirectory " ./test/testdata" $ do
@@ -412,6 +424,7 @@ ghcmodSpec =
412
424
arg = TP False uri (toPos (25 ,33 ))
413
425
res = IdeResultOk
414
426
[ (Range (toPos (25 , 33 )) (toPos (25 , 34 )), " a -> c" )
427
+ , (Range (toPos (25 , 1 )) (toPos (25 , 34 )), " (b -> c) -> (a -> b) -> a -> c" )
415
428
]
416
429
testCommand testPlugins act " ghcmod" " type" arg res
417
430
@@ -422,9 +435,9 @@ ghcmodSpec =
422
435
_ <- setTypecheckedModule uri
423
436
liftToGhc $ newTypeCmd (toPos (25 ,5 )) uri
424
437
arg = TP False uri (toPos (25 ,5 ))
425
- res = IdeResultOk []
426
- -- TODO: the type is known, why not in the map?
427
- -- (Range (toPos (25, 1)) (toPos (25, 9)), "(b -> c) -> (a -> b) -> a -> c")
438
+ res = IdeResultOk
439
+ [ ( Range (toPos ( 25 , 1 )) (toPos ( 25 , 34 )), " (b -> c) -> (a -> b) -> a -> c " )
440
+ ]
428
441
testCommand testPlugins act " ghcmod" " type" arg res
429
442
430
443
it " runs the type command, infix operator" $ withCurrentDirectory " ./test/testdata" $ do
@@ -436,6 +449,7 @@ ghcmodSpec =
436
449
arg = TP False uri (toPos (28 ,25 ))
437
450
res = IdeResultOk
438
451
[ (Range (toPos (28 , 25 )) (toPos (28 , 28 )), " (a -> b) -> IO a -> IO b" )
452
+ , (Range (toPos (28 , 1 )) (toPos (28 , 35 )), " (a -> b) -> IO a -> IO b" )
439
453
]
440
454
testCommand testPlugins act " ghcmod" " type" arg res
441
455
@@ -463,6 +477,7 @@ ghcmodSpec =
463
477
, (Range (toPos (33 , 15 )) (toPos (33 , 19 )), " Int -> Test -> ShowS" )
464
478
, (Range (toPos (33 , 15 )) (toPos (33 , 19 )), " Test -> String" )
465
479
, (Range (toPos (33 , 15 )) (toPos (33 , 19 )), " [Test] -> ShowS" )
480
+ , (Range (toPos (33 , 15 )) (toPos (33 , 19 )), " Int -> Test -> ShowS" )
466
481
]
467
482
testCommand testPlugins act " ghcmod" " type" arg res
468
483
@@ -477,6 +492,7 @@ ghcmodSpec =
477
492
[ (Range (toPos (33 , 21 )) (toPos (33 , 23 )), " (Test -> Test -> Bool) -> (Test -> Test -> Bool) -> Eq Test" )
478
493
, (Range (toPos (33 , 21 )) (toPos (33 , 23 )), " Test -> Test -> Bool" )
479
494
, (Range (toPos (33 , 21 )) (toPos (33 , 23 )), " Test -> Test -> Bool" )
495
+ , (Range (toPos (33 , 21 )) (toPos (33 , 23 )), " Test -> Test -> Bool" )
480
496
]
481
497
testCommand testPlugins act " ghcmod" " type" arg res
482
498
@@ -495,6 +511,7 @@ ghcmodSpec =
495
511
let arg = TP False uri (toPos (5 ,9 ))
496
512
let res = IdeResultOk
497
513
[(Range (toPos (5 ,9 )) (toPos (5 ,10 )), " Int" )
514
+ , (Range (toPos (5 ,1 )) (toPos (5 ,14 )), " Int -> Int" )
498
515
]
499
516
testCommand testPlugins act " ghcmod" " type" arg res
500
517
0 commit comments