-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wingman: "Intro and destruct" code action (#2077)
* Make intros' more configurable * Add a new "introduce and destruct" code action * Add tests * Add provider tests
- Loading branch information
Showing
13 changed files
with
121 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
plugins/hls-tactics-plugin/test/CodeAction/IntroDestructSpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module CodeAction.IntroDestructSpec where | ||
|
||
import Wingman.Types | ||
import Test.Hspec | ||
import Utils | ||
|
||
|
||
spec :: Spec | ||
spec = do | ||
let test l c = goldenTest IntroAndDestruct "" l c | ||
. mappend "IntroDestruct" | ||
|
||
describe "golden" $ do | ||
test 4 5 "One" | ||
test 2 5 "Many" | ||
test 4 11 "LetBinding" | ||
|
||
describe "provider" $ do | ||
mkTest | ||
"Can intro and destruct an algebraic ty" | ||
"IntroDestructProvider" 2 12 | ||
[ (id, IntroAndDestruct, "") | ||
] | ||
mkTest | ||
"Won't intro and destruct a non-algebraic ty" | ||
"IntroDestructProvider" 5 12 | ||
[ (not, IntroAndDestruct, "") | ||
] | ||
mkTest | ||
"Can't intro, so no option" | ||
"IntroDestructProvider" 8 17 | ||
[ (not, IntroAndDestruct, "") | ||
] | ||
|
6 changes: 6 additions & 0 deletions
6
plugins/hls-tactics-plugin/test/golden/IntroDestructLetBinding.expected.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test :: IO () | ||
test = do | ||
let x :: Bool -> Int | ||
x False = _w0 | ||
x True = _w1 | ||
pure () |
5 changes: 5 additions & 0 deletions
5
plugins/hls-tactics-plugin/test/golden/IntroDestructLetBinding.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test :: IO () | ||
test = do | ||
let x :: Bool -> Int | ||
x = _ | ||
pure () |
4 changes: 4 additions & 0 deletions
4
plugins/hls-tactics-plugin/test/golden/IntroDestructMany.expected.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
x :: Bool -> Maybe Int -> String -> Int | ||
x False = _w0 | ||
x True = _w1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x :: Bool -> Maybe Int -> String -> Int | ||
x = _ | ||
|
6 changes: 6 additions & 0 deletions
6
plugins/hls-tactics-plugin/test/golden/IntroDestructOne.expected.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Test where | ||
|
||
x :: Bool -> Int | ||
x False = _w0 | ||
x True = _w1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Test where | ||
|
||
x :: Bool -> Int | ||
x = _ | ||
|
9 changes: 9 additions & 0 deletions
9
plugins/hls-tactics-plugin/test/golden/IntroDestructProvider.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
hasAlgTy :: Maybe Int -> Int | ||
hasAlgTy = _ | ||
|
||
hasFunTy :: (Int -> Int) -> Int | ||
hasFunTy = _ | ||
|
||
isSaturated :: Bool -> Int | ||
isSaturated b = _ | ||
|