diff options
author | Colten Webb <coltenwebb@gmail.com> | 2022-07-15 07:54:39 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-16 07:21:15 -0400 |
commit | 89d169ec0c4e9c1e6cf4a6373a1992dad7474d55 (patch) | |
tree | cd63fcc649cf7e862b96f8aa2ad11105a5d0ef58 | |
parent | 5434d1a355e127d44c6f116b4b7f8a1d254815d4 (diff) | |
download | haskell-89d169ec0c4e9c1e6cf4a6373a1992dad7474d55.tar.gz |
Add record-dot-syntax test
-rw-r--r-- | testsuite/tests/hiefile/should_run/RecordDotTypes.hs | 43 | ||||
-rw-r--r-- | testsuite/tests/hiefile/should_run/RecordDotTypes.stdout | 5 | ||||
-rw-r--r-- | testsuite/tests/hiefile/should_run/all.T | 1 |
3 files changed, 49 insertions, 0 deletions
diff --git a/testsuite/tests/hiefile/should_run/RecordDotTypes.hs b/testsuite/tests/hiefile/should_run/RecordDotTypes.hs new file mode 100644 index 0000000000..18f1ee33d9 --- /dev/null +++ b/testsuite/tests/hiefile/should_run/RecordDotTypes.hs @@ -0,0 +1,43 @@ +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE NoFieldSelectors #-} + +module Main where + +import TestUtils +import qualified Data.Map as M +import Data.Foldable + +data MyRecord = MyRecord + { a :: String + , b :: Integer + , c :: MyChild + } deriving (Eq, Show) + +newtype MyChild = MyChild + { z :: String + } deriving (Eq, Show) + +x = MyRecord { a = "Hello", b = 12, c = MyChild { z = "there" } } +y = x.a ++ show x.b ++ x.c.z +-- ^ ^ ^ ^^ +-- 1 2 3 45 + +p1,p2,p3,p4 :: (Int,Int) +p1 = (22,6) +p2 = (22,20) +p3 = (22,25) +p4 = (22,28) +p5 = (22,29) + +selectPoint' :: HieFile -> (Int,Int) -> HieAST Int +selectPoint' hf loc = + maybe (error "point not found") id $ selectPoint hf loc + +main = do + (df, hf) <- readTestHie "RecordDotTypes.hie" + forM_ [p1,p2,p3,p4,p5] $ \point -> do + putStr $ "At " ++ show point ++ ", got type: " + let types = concatMap nodeType $ getSourcedNodeInfo $ sourcedNodeInfo $ selectPoint' hf point + forM_ types $ \typ -> do + putStrLn (renderHieType df $ recoverFullType typ (hie_types hf)) diff --git a/testsuite/tests/hiefile/should_run/RecordDotTypes.stdout b/testsuite/tests/hiefile/should_run/RecordDotTypes.stdout new file mode 100644 index 0000000000..ad144fe5b8 --- /dev/null +++ b/testsuite/tests/hiefile/should_run/RecordDotTypes.stdout @@ -0,0 +1,5 @@ +At (22,6), got type: MyRecord +At (22,20), got type: Integer +At (22,25), got type: MyRecord +At (22,28), got type: String +At (22,29), got type: String
\ No newline at end of file diff --git a/testsuite/tests/hiefile/should_run/all.T b/testsuite/tests/hiefile/should_run/all.T index 7e258efbc6..7be119da97 100644 --- a/testsuite/tests/hiefile/should_run/all.T +++ b/testsuite/tests/hiefile/should_run/all.T @@ -1,3 +1,4 @@ test('PatTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('HieQueries', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('T20341', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) +test('RecordDotTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) |