diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/codeGen/should_run/cgrun031.hs | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/codeGen/should_run/cgrun031.hs')
-rw-r--r-- | testsuite/tests/codeGen/should_run/cgrun031.hs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/cgrun031.hs b/testsuite/tests/codeGen/should_run/cgrun031.hs new file mode 100644 index 0000000000..2a2c7a9b64 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/cgrun031.hs @@ -0,0 +1,45 @@ +{-# LANGUAGE MagicHash #-} +-- !! test GEN reps w/ unboxed values in them +-- !! NB: it was the static ones that were hosed... +-- +module Main ( main ) where + +--import PrelBase +import GHC.Base + +main = do + putStr (shows (sum ([1..1{-30-}]++[1..1{-40-}]++[11,22])) "\n") + putStr (shows (prog 1{-30-} 1{-40-}) "\n") + +data Foo a + = MkFoo [a] Int# [Int] Int# [(a,Int)] Int# + -- The above will cause a *horrible* GEN rep'n. + +prog :: Int -> Int -> Int + +prog size_1 size_2 + = let + list1 = static1 : (map mk_foo [1 .. size_1]) + list2 = static2 : (map mk_foo [1 .. size_2]) + in + I# (add_up 0# list1 (reverse list2)) + +static1 = MkFoo (error "static11") 11# [] 11# (error "static12") 11# +static2 = MkFoo (error "static21") 22# [] 22# (error "static22") 22# + +one, two :: Int +one = 1; two = 2 + +mk_foo i@(I# i#) + = MkFoo (error "list1") i# [i,i] i# (error "list2") i# + +add_up :: Int# -> [Foo a] -> [Foo a] -> Int# + +add_up acc [] [] = acc +add_up acc [] ys = add_up acc ys [] +add_up acc (x:xs) (y:ys) = add_up (acc +# add x y) xs ys +add_up acc (x:xs) [] = add_up acc xs [] + +add :: Foo a -> Foo a -> Int# +add (MkFoo _ _ _ _ _ x) (MkFoo _ _ _ _ _ y) + = x +# y |