@@ -46,6 +46,7 @@ import Development.IDE.Plugin.CodeAction (matchRegExMultipleImp
4646import Test.Hls
4747
4848import qualified Development.IDE.GHC.ExactPrint
49+ import Development.IDE.Plugin.CodeAction (NotInScope (.. ))
4950import qualified Development.IDE.Plugin.CodeAction as Refactor
5051import qualified Test.AddArgument
5152
@@ -68,6 +69,7 @@ tests =
6869 , codeActionTests
6970 , codeActionHelperFunctionTests
7071 , completionTests
72+ , extractNotInScopeNameTests
7173 ]
7274
7375initializeTests :: TestTree
@@ -1907,6 +1909,36 @@ suggestAddRecordFieldImportTests = testGroup "suggest imports of record fields w
19071909 contentAfterAction <- documentContents doc
19081910 liftIO $ after @=? contentAfterAction
19091911
1912+ extractNotInScopeNameTests :: TestTree
1913+ extractNotInScopeNameTests =
1914+ testGroup " extractNotInScopeName" [
1915+ testGroup " HasField" [
1916+ testGroup " unqualified" [
1917+ testGroup " nice ticks" [
1918+ testCase " Simple type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" baz\" Cheval Bool’" @=? Just (NotInScopeThing " Cheval" ),
1919+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" bar\" (Hibou Int) a0’" @=? Just (NotInScopeThing " Hibou" ),
1920+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" foo\" (Tortue Int) Int’" @=? Just (NotInScopeThing " Tortue" )
1921+ ],
1922+ testGroup " parenthesis" [
1923+ testCase " Simple type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" blup\" Calamar Bool’" @=? Just (NotInScopeThing " Calamar" ),
1924+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" biz\" (Ornithorink Int) a0’" @=? Just (NotInScopeThing " Ornithorink" ),
1925+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘HasField \" blork\" (Salamandre Int) Int’" @=? Just (NotInScopeThing " Salamandre" )
1926+ ]
1927+ ],
1928+ testGroup " qualified" [
1929+ testGroup " nice ticks" [
1930+ testCase " Simple type" $ Refactor. extractNotInScopeName " No instance for ‘GHC.HasField \" baz\" Cheval Bool’" @=? Just (NotInScopeThing " Cheval" ),
1931+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘Record.HasField \" bar\" (Hibou Int) a0’" @=? Just (NotInScopeThing " Hibou" ),
1932+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘Youpi.HasField \" foo\" (Tortue Int) Int’" @=? Just (NotInScopeThing " Tortue" )
1933+ ],
1934+ testGroup " parenthesis" [
1935+ testCase " Simple type" $ Refactor. extractNotInScopeName " No instance for ‘GHC.Tortue.HasField \" blup\" Calamar Bool’" @=? Just (NotInScopeThing " Calamar" ),
1936+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘Youpi.Salamandre.HasField \" biz\" (Ornithorink Int) a0’" @=? Just (NotInScopeThing " Ornithorink" ),
1937+ testCase " Parametric type" $ Refactor. extractNotInScopeName " No instance for ‘Foo.Bar.HasField \" blork\" (Salamandre Int) Int’" @=? Just (NotInScopeThing " Salamandre" )
1938+ ]
1939+ ]
1940+ ]
1941+ ]
19101942suggestAddCoerceMissingConstructorImportTests :: TestTree
19111943suggestAddCoerceMissingConstructorImportTests = testGroup " suggest imports of newtype constructor when using coerce"
19121944 [ testGroup " The newtype constructor is suggested when a matching representation error"
0 commit comments