diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2016-07-21 19:59:05 +0000 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2016-07-21 19:59:18 +0000 |
commit | 8265c783dc26cb72e74a8fe89101049bb94c6db5 (patch) | |
tree | 476f09aaba42b71ab051e431761ec10504f7c130 /testsuite/tests/unboxedsums | |
parent | 6a4dc891fa7a8024d8f9f03b98ad675ff5fcbd91 (diff) | |
download | haskell-8265c783dc26cb72e74a8fe89101049bb94c6db5.tar.gz |
Fix and document Unique generation for sum TyCon and DataCons
Test Plan: validate
Reviewers: bgamari, austin
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2420
Diffstat (limited to 'testsuite/tests/unboxedsums')
-rw-r--r-- | testsuite/tests/unboxedsums/all.T | 5 | ||||
-rw-r--r-- | testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/unboxedsums/all.T b/testsuite/tests/unboxedsums/all.T index 274045f393..0b948b1477 100644 --- a/testsuite/tests/unboxedsums/all.T +++ b/testsuite/tests/unboxedsums/all.T @@ -1,3 +1,8 @@ +test('unboxedsums_unit_tests', + only_ways(['normal']), + compile_and_run, + ['-package ghc']) + test('unarise', omit_ways(['ghci']), compile_and_run, ['']) test('unboxedsums1', omit_ways(['ghci']), compile_and_run, ['']) test('unboxedsums2', omit_ways(['ghci']), compile_and_run, ['']) diff --git a/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs new file mode 100644 index 0000000000..d7a8d333a0 --- /dev/null +++ b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs @@ -0,0 +1,26 @@ +module Main where + +import TysWiredIn +import UniqSet +import Unique + +import System.IO +import Control.Monad + +main :: IO () +main = sequence_ + [ uniq_tests ] + + +uniq_tests :: IO () +uniq_tests = do + let tycons = map sumTyCon [2 .. 20] + datacons = [ sumDataCon alt arity | arity <- [ 2 .. 20 ] + , alt <- [ 1 .. arity ] ] + + us = mkUniqSet (map getUnique tycons) + `unionUniqSets` mkUniqSet (map getUnique datacons) + + when (sizeUniqSet us /= length tycons + length datacons) $ do + hPutStrLn stderr "Sum cons/tycons have same uniques." + hFlush stderr |