Update examples
This commit is contained in:
4
testsuite/dynload/should_fail_1/Makefile
Normal file
4
testsuite/dynload/should_fail_1/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
TEST= dynload/should_fail_1
|
||||
EXTRA_OBJS=Plugin.o
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
15
testsuite/dynload/should_fail_1/Plugin.hs
Normal file
15
testsuite/dynload/should_fail_1/Plugin.hs
Normal file
@ -0,0 +1,15 @@
|
||||
--
|
||||
-- trying to be really mean.
|
||||
--
|
||||
|
||||
module Plugin where
|
||||
|
||||
import API
|
||||
import AltData.Dynamic
|
||||
|
||||
v :: Int -> Int
|
||||
v = \x -> 0xdeadbeef
|
||||
|
||||
resource_dyn :: Dynamic
|
||||
resource_dyn = toDyn v
|
||||
|
20
testsuite/dynload/should_fail_1/api/API.hs
Normal file
20
testsuite/dynload/should_fail_1/api/API.hs
Normal file
@ -0,0 +1,20 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
|
||||
module API where
|
||||
|
||||
import AltData.Typeable
|
||||
|
||||
data Interface = Interface {
|
||||
function :: String
|
||||
}
|
||||
|
||||
instance Typeable Interface where
|
||||
#if __GLASGOW_HASKELL__ >= 603
|
||||
typeOf i = mkTyConApp (mkTyCon "API.Interface") []
|
||||
#else
|
||||
typeOf i = mkAppTy (mkTyCon "API.Interface") []
|
||||
#endif
|
||||
|
||||
plugin :: Interface
|
||||
plugin = Interface { function = "goodbye" }
|
||||
|
11
testsuite/dynload/should_fail_1/prog/Main.hs
Normal file
11
testsuite/dynload/should_fail_1/prog/Main.hs
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
main = do
|
||||
m_v <- dynload "../Plugin.o" ["../api"]
|
||||
[] "resource_dyn"
|
||||
case m_v of
|
||||
LoadFailure _ -> putStrLn "didn't compile"
|
||||
LoadSuccess _ v -> putStrLn $ (function v)
|
||||
|
4
testsuite/dynload/should_fail_1/prog/expected
Normal file
4
testsuite/dynload/should_fail_1/prog/expected
Normal file
@ -0,0 +1,4 @@
|
||||
Couldn't match `API.Interface' against `Int -> Int'
|
||||
Expected type: API.Interface
|
||||
Inferred type: Int -> Int
|
||||
didn't compile
|
Reference in New Issue
Block a user