Update examples
This commit is contained in:
4
testsuite/unload/sjwtrap/Makefile
Normal file
4
testsuite/unload/sjwtrap/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
TEST= unload/sjwtrap
|
||||
EXTRA_OBJS=Null.o
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
6
testsuite/unload/sjwtrap/Null.hs
Normal file
6
testsuite/unload/sjwtrap/Null.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module Null where
|
||||
|
||||
import qualified Prelude
|
||||
import API
|
||||
|
||||
resource = null
|
9
testsuite/unload/sjwtrap/api/API.hs
Normal file
9
testsuite/unload/sjwtrap/api/API.hs
Normal file
@ -0,0 +1,9 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
|
||||
module API where
|
||||
|
||||
data Null = Null { a, b :: Int }
|
||||
|
||||
null :: Null
|
||||
null = Null { a = 42 , b = 1 }
|
||||
|
15
testsuite/unload/sjwtrap/prog/Main.hs
Normal file
15
testsuite/unload/sjwtrap/prog/Main.hs
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
--
|
||||
-- what happens if we try to use code that has been unloaded?
|
||||
--
|
||||
|
||||
main = do
|
||||
m_v <- load "../Null.o" ["../api"] [] "resource"
|
||||
(m,v) <- case m_v of
|
||||
LoadSuccess m v -> return (m,v)
|
||||
_ -> error "load failed"
|
||||
putStrLn ( show (a v) )
|
||||
unload m
|
1
testsuite/unload/sjwtrap/prog/expected
Normal file
1
testsuite/unload/sjwtrap/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
42
|
Reference in New Issue
Block a user