Skip to content

Commit 53664f9

Browse files
committed
tests: Ghc9 shows [Char] as String by default
This seems like an improvement, so just update the test-suite
1 parent 0ac2303 commit 53664f9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

ghcide/test/exe/Main.hs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,14 +2140,14 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
21402140
[ (DsWarning, (6, 8), "Defaulting the following constraint")
21412141
, (DsWarning, (6, 16), "Defaulting the following constraint")
21422142
]
2143-
"Add type annotation ‘[Char]’ to ‘\"debug\""
2143+
("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"")
21442144
(T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}"
21452145
, "{-# LANGUAGE OverloadedStrings #-}"
21462146
, "module A (f) where"
21472147
, ""
21482148
, "import Debug.Trace"
21492149
, ""
2150-
, "f = seq (\"debug\" :: [Char]) traceShow \"debug\""
2150+
, "f = seq (\"debug\" :: " <> listOfChar <> ") traceShow \"debug\""
21512151
])
21522152
, testSession "add default type to satisfy two contraints" $
21532153
testFor
@@ -2160,14 +2160,14 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
21602160
, "f a = traceShow \"debug\" a"
21612161
])
21622162
[ (DsWarning, (6, 6), "Defaulting the following constraint") ]
2163-
"Add type annotation ‘[Char]’ to ‘\"debug\""
2163+
("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"")
21642164
(T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}"
21652165
, "{-# LANGUAGE OverloadedStrings #-}"
21662166
, "module A (f) where"
21672167
, ""
21682168
, "import Debug.Trace"
21692169
, ""
2170-
, "f a = traceShow (\"debug\" :: [Char]) a"
2170+
, "f a = traceShow (\"debug\" :: " <> listOfChar <> ") a"
21712171
])
21722172
, testSession "add default type to satisfy two contraints with duplicate literals" $
21732173
testFor
@@ -2180,14 +2180,14 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
21802180
, "f = seq (\"debug\" :: [Char]) (seq (\"debug\" :: [Char]) (traceShow \"debug\"))"
21812181
])
21822182
[ (DsWarning, (6, 54), "Defaulting the following constraint") ]
2183-
"Add type annotation ‘[Char]’ to ‘\"debug\""
2183+
("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"")
21842184
(T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}"
21852185
, "{-# LANGUAGE OverloadedStrings #-}"
21862186
, "module A (f) where"
21872187
, ""
21882188
, "import Debug.Trace"
21892189
, ""
2190-
, "f = seq (\"debug\" :: [Char]) (seq (\"debug\" :: [Char]) (traceShow (\"debug\" :: [Char])))"
2190+
, "f = seq (\"debug\" :: [Char]) (seq (\"debug\" :: [Char]) (traceShow (\"debug\" :: " <> listOfChar <> ")))"
21912191
])
21922192
]
21932193
where
@@ -3172,7 +3172,7 @@ addSigLensesTests =
31723172
, ("pattern Some a = Just a", "pattern Some :: a -> Maybe a")
31733173
, ("qualifiedSigTest= C.realPart", "qualifiedSigTest :: C.Complex a -> a")
31743174
, ("head = 233", "head :: Integer")
3175-
, ("rank2Test (k :: forall a . a -> a) = (k 233 :: Int, k \"QAQ\")", "rank2Test :: (forall a. a -> a) -> (Int, [Char])")
3175+
, ("rank2Test (k :: forall a . a -> a) = (k 233 :: Int, k \"QAQ\")", "rank2Test :: (forall a. a -> a) -> (Int, " <> listOfChar <> ")")
31763176
, ("symbolKindTest = Proxy @\"qwq\"", "symbolKindTest :: Proxy \"qwq\"")
31773177
, ("promotedKindTest = Proxy @Nothing", "promotedKindTest :: Proxy 'Nothing")
31783178
, ("typeOperatorTest = Refl", "typeOperatorTest :: a :~: a")
@@ -4098,10 +4098,11 @@ highlightTests = testGroup "highlight"
40984098
highlights <- getHighlights doc (Position 4 15)
40994099
liftIO $ highlights @?= List
41004100
-- Span is just the .. on 8.10, but Rec{..} before
4101+
[
41014102
#if MIN_GHC_API_VERSION(8,10,0)
4102-
[ DocumentHighlight (R 4 8 4 10) (Just HkWrite)
4103+
DocumentHighlight (R 4 8 4 10) (Just HkWrite)
41034104
#else
4104-
[ DocumentHighlight (R 4 4 4 11) (Just HkWrite)
4105+
DocumentHighlight (R 4 4 4 11) (Just HkWrite)
41054106
#endif
41064107
, DocumentHighlight (R 4 14 4 20) (Just HkRead)
41074108
]
@@ -5420,3 +5421,11 @@ assertJust :: MonadIO m => String -> Maybe a -> m a
54205421
assertJust s = \case
54215422
Nothing -> liftIO $ assertFailure s
54225423
Just x -> pure x
5424+
5425+
-- | Before ghc9, lists of Char is displayed as [Char], but with ghc9 and up, it's displayed as String
5426+
listOfChar :: T.Text
5427+
#if MIN_GHC_API_VERSION(9,0,1)
5428+
listOfChar = "String"
5429+
#else
5430+
listOfChar = "[Char]"
5431+
#endif

0 commit comments

Comments
 (0)