Update examples
This commit is contained in:
4
testsuite/dynload/should_fail_3/Makefile
Normal file
4
testsuite/dynload/should_fail_3/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
TEST= dynload/should_fail_3
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
19
testsuite/dynload/should_fail_3/Plugin.in
Normal file
19
testsuite/dynload/should_fail_3/Plugin.in
Normal file
@ -0,0 +1,19 @@
|
||||
--
|
||||
-- the plugin doesn't even make the resource_dyn a Dynamic.
|
||||
-- let's hope that makeWith strips out the invalid declarations
|
||||
--
|
||||
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
|
||||
module Plugin where
|
||||
|
||||
import API
|
||||
|
||||
import AltData.Typeable
|
||||
import GHC.Base
|
||||
|
||||
v :: Int
|
||||
v = 0xdeadbeef
|
||||
|
||||
resource_dyn = (typeOf plugin, unsafeCoerce v)
|
||||
|
12
testsuite/dynload/should_fail_3/Plugin.stub
Normal file
12
testsuite/dynload/should_fail_3/Plugin.stub
Normal file
@ -0,0 +1,12 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
|
||||
module Plugin ( resource_dyn ) where
|
||||
|
||||
import API
|
||||
import AltData.Dynamic
|
||||
|
||||
resource = plugin
|
||||
|
||||
resource_dyn :: Dynamic
|
||||
resource_dyn = toDyn resource
|
||||
|
22
testsuite/dynload/should_fail_3/api/API.hs
Normal file
22
testsuite/dynload/should_fail_3/api/API.hs
Normal file
@ -0,0 +1,22 @@
|
||||
{-# OPTIONS -cpp -fglasgow-exts #-}
|
||||
|
||||
module API where
|
||||
|
||||
import AltData.Typeable
|
||||
import GHC.Base
|
||||
|
||||
data Interface = Interface {
|
||||
function :: String
|
||||
}
|
||||
|
||||
instance Typeable Interface where
|
||||
#if __GLASGOW_HASKELL__ >= 603
|
||||
typeOf _ = mkTyConApp (mkTyCon "API.Interface") []
|
||||
#else
|
||||
typeOf _ = mkAppTy (mkTyCon "API.Interface") []
|
||||
#endif
|
||||
|
||||
plugin :: Interface
|
||||
plugin = Interface { function = "goodbye" }
|
||||
|
||||
unsafeCoerce = unsafeCoerce#
|
18
testsuite/dynload/should_fail_3/prog/Main.hs
Normal file
18
testsuite/dynload/should_fail_3/prog/Main.hs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
conf = "../Plugin.in"
|
||||
stub = "../Plugin.stub"
|
||||
|
||||
main = do
|
||||
status <- makeWith conf stub ["-i../api", "-i../../../../src/altdata"]
|
||||
o <- case status of
|
||||
MakeFailure e -> mapM_ putStrLn e >> error "failed"
|
||||
MakeSuccess _ o -> return o
|
||||
m_v <- dynload o ["../api"] [] "resource_dyn"
|
||||
case m_v of
|
||||
LoadFailure _ -> error "didn't compile"
|
||||
LoadSuccess _ v -> do putStrLn $ (function v)
|
||||
makeCleaner o
|
||||
|
9
testsuite/dynload/should_fail_3/prog/expected
Normal file
9
testsuite/dynload/should_fail_3/prog/expected
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
../Plugin.in:18:
|
||||
Couldn't match `Dynamic' against `(t, t1)'
|
||||
Expected type: Dynamic
|
||||
Inferred type: (t, t1)
|
||||
In the definition of `resource_dyn':
|
||||
resource_dyn = (typeOf plugin, unsafeCoerce v)
|
||||
|
||||
Fail: failed
|
8
testsuite/dynload/should_fail_3/prog/expected.604
Normal file
8
testsuite/dynload/should_fail_3/prog/expected.604
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
../Plugin.in:18:15:
|
||||
Couldn't match `Dynamic' against `(a, b)'
|
||||
Expected type: Dynamic
|
||||
Inferred type: (a, b)
|
||||
In the definition of `resource_dyn':
|
||||
resource_dyn = (typeOf plugin, unsafeCoerce v)
|
||||
a.out: failed
|
8
testsuite/dynload/should_fail_3/prog/expected.605
Normal file
8
testsuite/dynload/should_fail_3/prog/expected.605
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
../Plugin.in:18:15:
|
||||
Couldn't match `Dynamic' against `(a, b)'
|
||||
Expected type: Dynamic
|
||||
Inferred type: (a, b)
|
||||
In the definition of `resource_dyn':
|
||||
resource_dyn = (typeOf plugin, unsafeCoerce v)
|
||||
a.out: failed
|
Reference in New Issue
Block a user