Update examples
This commit is contained in:
5
testsuite/pdynload/spj2/Makefile
Normal file
5
testsuite/pdynload/spj2/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
TEST=pdynload/spj1
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
13
testsuite/pdynload/spj2/Plugin.hs
Normal file
13
testsuite/pdynload/spj2/Plugin.hs
Normal file
@ -0,0 +1,13 @@
|
||||
module Plugin where
|
||||
|
||||
-- user doesn't import the API
|
||||
-- and provides a polymorphic value
|
||||
|
||||
import API
|
||||
resource :: Interface
|
||||
|
||||
--
|
||||
-- should pass type check, and dump core
|
||||
--
|
||||
-- resource :: Num a => a
|
||||
resource = 7
|
6
testsuite/pdynload/spj2/api/API.hs
Normal file
6
testsuite/pdynload/spj2/api/API.hs
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
module API where
|
||||
|
||||
-- simple type
|
||||
type Interface = Int
|
||||
|
17
testsuite/pdynload/spj2/prog/Main.hs
Normal file
17
testsuite/pdynload/spj2/prog/Main.hs
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
src = "../Plugin.hs"
|
||||
wrap = "../Wrapper.hs"
|
||||
apipath = "../api"
|
||||
|
||||
main = do status <- make src ["-i"++apipath]
|
||||
case status of
|
||||
MakeSuccess _ _ -> f
|
||||
MakeFailure e -> mapM_ putStrLn e
|
||||
|
||||
where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource"
|
||||
case v of
|
||||
LoadSuccess _ (a :: Interface) -> putStrLn $ show a -- will crash
|
||||
LoadFailure es -> putStrLn $ show es
|
1
testsuite/pdynload/spj2/prog/expected
Normal file
1
testsuite/pdynload/spj2/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
7
|
Reference in New Issue
Block a user