Commit e0d161fa authored by ross's avatar ross

[project @ 2004-11-19 00:24:53 by ross]

add a modernized version of fed001, which is a GHC-only test of obsolete syntax
parent ac6c88ab
......@@ -10,7 +10,9 @@ def f( opts ):
setTestOpts(f)
# Doesn't work with External Core due to __labels
test('fed001', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
test('fed001', compose(only_compiler_types(['ghc']),
expect_fail_for(['extcore','optextcore'])),
compile_and_run, [''])
# Omit GHCi for these two, as they use foreign export
test('ffi001', omit_ways(['ghci']), compile_and_run, [''])
......@@ -52,3 +54,6 @@ test('ffi010', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
test('ffi011', normal, compile_and_run, [''])
test('ffi012', normal, compile_and_run, [''])
# Doesn't work with External Core due to __labels
test('ffi013', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
import Foreign
import Foreign.C.Types
foreign import ccall "wrapper"
mkComparator :: (Ptr Int -> Ptr Int -> IO CInt)
-> IO (FunPtr (Ptr Int -> Ptr Int -> IO CInt))
foreign import ccall
qsort :: Ptr Int -> CSize -> CSize -> FunPtr (Ptr Int -> Ptr Int -> IO CInt)
-> IO ()
compareInts :: Ptr Int -> Ptr Int -> IO CInt
compareInts a1 a2 = do
i1 <- peek a1
i2 <- peek a2
return (fromIntegral (i1 - i2 :: Int))
main :: IO ()
main = do
c <- mkComparator compareInts
let values = [ 12, 56, 90, 34, 78 ] :: [Int]
n = length values
withArray values $ \ buf -> do
qsort buf (fromIntegral n) (fromIntegral (sizeOf (head values))) c
values' <- peekArray n buf
print values'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment