Skip to content

Commit 50bd268

Browse files
author
Ishmum Jawad Khan
committed
[test] test added for pragma addition after shebang
1 parent 7817a10 commit 50bd268

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/functional/FunctionalCodeAction.hs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,35 @@ missingPragmaTests = testGroup "missing pragma warning code actions" [
561561
, ""
562562
, "f Record{a, b} = a"
563563
]
564+
liftIO $ T.lines contents @?= expected
565+
, testCase "After Shebang" $ do
566+
runSession hlsCommand fullCaps "test/testdata/addPragmas" $ do
567+
doc <- openDoc "AfterShebang.hs" "haskell"
568+
569+
_ <- waitForDiagnosticsFrom doc
570+
cas <- map fromAction <$> getAllCodeActions doc
571+
572+
liftIO $ "Add \"NamedFieldPuns\"" `elem` map (^. L.title) cas @? "Contains NamedFieldPuns code action"
573+
574+
executeCodeAction $ head cas
575+
576+
contents <- documentContents doc
577+
578+
let expected =
579+
[ "#! /usr/bin/env nix-shell"
580+
, "#! nix-shell --pure -i runghc -p \"haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])\""
581+
, ""
582+
, "{-# LANGUAGE NamedFieldPuns #-}"
583+
, "module AfterShebang where"
584+
, ""
585+
, "data Record = Record"
586+
, " { a :: Int,"
587+
, " b :: Double,"
588+
, " c :: String"
589+
, " }"
590+
, ""
591+
, "f Record{a, b} = a"
592+
]
564593

565594
liftIO $ T.lines contents @?= expected
566595
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /usr/bin/env nix-shell
2+
#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])"
3+
4+
module AfterShebang where
5+
6+
data Record = Record
7+
{ a :: Int,
8+
b :: Double,
9+
c :: String
10+
}
11+
12+
f Record{a, b} = a

0 commit comments

Comments
 (0)