Skip to content

Commit

Permalink
[test] test added for pragma addition after shebang
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishmum Jawad Khan committed Feb 23, 2021
1 parent 7817a10 commit 50bd268
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/functional/FunctionalCodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,35 @@ missingPragmaTests = testGroup "missing pragma warning code actions" [
, ""
, "f Record{a, b} = a"
]
liftIO $ T.lines contents @?= expected
, testCase "After Shebang" $ do
runSession hlsCommand fullCaps "test/testdata/addPragmas" $ do
doc <- openDoc "AfterShebang.hs" "haskell"

_ <- waitForDiagnosticsFrom doc
cas <- map fromAction <$> getAllCodeActions doc

liftIO $ "Add \"NamedFieldPuns\"" `elem` map (^. L.title) cas @? "Contains NamedFieldPuns code action"

executeCodeAction $ head cas

contents <- documentContents doc

let expected =
[ "#! /usr/bin/env nix-shell"
, "#! nix-shell --pure -i runghc -p \"haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])\""
, ""
, "{-# LANGUAGE NamedFieldPuns #-}"
, "module AfterShebang where"
, ""
, "data Record = Record"
, " { a :: Int,"
, " b :: Double,"
, " c :: String"
, " }"
, ""
, "f Record{a, b} = a"
]

liftIO $ T.lines contents @?= expected
]
Expand Down
12 changes: 12 additions & 0 deletions test/testdata/addPragmas/AfterShebang.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env nix-shell
#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])"

module AfterShebang where

data Record = Record
{ a :: Int,
b :: Double,
c :: String
}

f Record{a, b} = a

0 comments on commit 50bd268

Please sign in to comment.