diff options
Diffstat (limited to 'testsuite/tests/hiefile')
-rw-r--r-- | testsuite/tests/hiefile/should_run/SpliceTypes.hs | 47 | ||||
-rw-r--r-- | testsuite/tests/hiefile/should_run/SpliceTypes.stdout | 9 | ||||
-rw-r--r-- | testsuite/tests/hiefile/should_run/all.T | 1 |
3 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/tests/hiefile/should_run/SpliceTypes.hs b/testsuite/tests/hiefile/should_run/SpliceTypes.hs new file mode 100644 index 0000000000..6ea4134692 --- /dev/null +++ b/testsuite/tests/hiefile/should_run/SpliceTypes.hs @@ -0,0 +1,47 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Main where + +import TestUtils +import qualified Data.Map as M +import Data.Foldable +import Language.Haskell.TH.Syntax + + +newtype T = T { getT :: Int } + +instance Lift T where + liftTyped v = [||T $$(liftTyped (getT v))||] +-- ^ ^ ^ ^ ^ +-- 1 2 3 4 5 +-- + +top_level :: () +top_level = $$([|| () ||]) +-- ^ ^ +-- 1 2 + +p1,p2, p3, p4:: (Int,Int) +p1 = (14,18) +p2 = (14,21) +p3 = (14,24) +p4 = (14,29) +p5 = (14,41) + +q1 = (20, 19) +q2 = (20, 21) + +selectPoint' :: HieFile -> (Int,Int) -> HieAST Int +selectPoint' hf loc = + maybe (error "point not found") id $ selectPoint hf loc + +main = do + (df, hf) <- readTestHie "SpliceTypes.hie" + forM_ [p1,p2,p3, p4, p5, q1, q2] $ \point -> do + let types = concatMap nodeType $ getSourcedNodeInfo $ sourcedNodeInfo $ selectPoint' hf point + case types of + [] -> putStrLn $ "No types at " ++ show point + _ -> do + putStr $ "At " ++ show point ++ ", got type: " + forM_ types $ \typ -> do + putStrLn (renderHieType df $ recoverFullType typ (hie_types hf)) diff --git a/testsuite/tests/hiefile/should_run/SpliceTypes.stdout b/testsuite/tests/hiefile/should_run/SpliceTypes.stdout new file mode 100644 index 0000000000..aa2398203a --- /dev/null +++ b/testsuite/tests/hiefile/should_run/SpliceTypes.stdout @@ -0,0 +1,9 @@ +No types at (14,18) +At (14,21), got type: Int -> T +No types at (14,24) +At (14,29), got type: Int -> Code m Int +forall t (m :: * -> *). (Lift t, Quote m) => t -> Code m t +forall (m :: * -> *). Quote m => Int -> Code m Int +At (14,41), got type: T +No types at (20,19) +No types at (20,21) diff --git a/testsuite/tests/hiefile/should_run/all.T b/testsuite/tests/hiefile/should_run/all.T index 7be119da97..5536034d6b 100644 --- a/testsuite/tests/hiefile/should_run/all.T +++ b/testsuite/tests/hiefile/should_run/all.T @@ -2,3 +2,4 @@ test('PatTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestU 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']) +test('SpliceTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) |