summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/ListStaticPointers.hs
blob: 01c747d45afd8de5388c67fab0bd9feeed9089c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- A test to show that Static Pointers can be listed.
{-# LANGUAGE StaticPointers #-}
module Main where

import Control.Monad (when)
import Data.List ((\\))
import GHC.StaticPtr
import System.Exit

main = do
    found <- staticPtrKeys
    when (not $ eqBags found expected) $ do
      print ("expected", expected)
      print ("found", found)
      exitFailure
  where

    expected =
      [ staticKey $  static (\x -> x :: Int)
      , staticKey   (static return :: StaticPtr (Int -> IO Int))
      , staticKey $  static g
      ]

    eqBags :: Eq a => [a] -> [a] -> Bool
    eqBags xs ys = null (xs \\ ys) && null (ys \\ xs)

g :: Int -> Int
g = (+1)