Commit 889407dc authored by Simon Marlow's avatar Simon Marlow

add test for #986

parent d07dcb88
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
.PHONY: test068
test068 :
@$(TEST_HC) -v0 -fforce-recomp --make conc068.hs -o conc068 -threaded
@yes abqszzzq 2>/dev/null | head -c 100000 | ./conc068 +RTS -N2
......@@ -156,3 +156,5 @@ test('conc064', exit_code(1), compile_and_run, [''])
test('conc065', ignore_output, compile_and_run, [''])
test('conc066', ignore_output, compile_and_run, [''])
test('conc067', ignore_output, compile_and_run, [''])
test('conc068', normal, run_command, ['$MAKE -s --no-print-directory test068'])
import Data.List
import Data.Char
import Control.Parallel
import System.IO
{-# NOINLINE fool #-}
-- 'fool' just makes sure CSE doesn't meddle with the code below
fool :: [a] -> [a]
fool (x:xs) = xs
main = do
hSetBuffering stdin NoBuffering
hs <- getContents
let -- create copies of the input
ts = map (:hs) ['a'..'z']
-- sum the characters of each copy
qs = map (foldl' (+) 0 . map ord . fool) ts
-- in parallel
rs = foldr (\x y -> x `par` y `par` (x:y)) [] qs
-- compare the results and print 'True' if they are all equal.
-- This should never print 'False'
print $ all (uncurry (==)) $ zip rs (tail rs)
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