diff options
Diffstat (limited to 'testsuite/tests/codeGen/should_run/cgrun065.hs')
-rw-r--r-- | testsuite/tests/codeGen/should_run/cgrun065.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/cgrun065.hs b/testsuite/tests/codeGen/should_run/cgrun065.hs new file mode 100644 index 0000000000..6934832013 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/cgrun065.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +module Main ( main ) where + +import GHC.Exts +import GHC.Prim +import GHC.ST + +main = putStr + (test_sizeofArray + ++ "\n" ++ test_sizeofMutableArray + ++ "\n" + ) + +test_sizeofArray :: String +test_sizeofArray = flip shows "\n" $ runST $ ST $ \ s# -> go 0 [] s# + where + go i@(I# i#) acc s# + | i < 1000 = case newArray# i# 0 s# of + (# s2#, marr# #) -> case unsafeFreezeArray# marr# s2# of + (# s3#, arr# #) -> case sizeofArray# arr# of + j# -> go (i+1) ((I# j#):acc) s3# + | otherwise = (# s#, reverse acc #) + +test_sizeofMutableArray :: String +test_sizeofMutableArray = flip shows "\n" $ runST $ ST $ \ s# -> go 0 [] s# + where + go i@(I# i#) acc s# + | i < 1000 = case newArray# i# 0 s# of + (# s2#, marr# #) -> case sizeofMutableArray# marr# of + j# -> go (i+1) ((I# j#):acc) s2# + | otherwise = (# s#, reverse acc #) + |