Three.hs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {-# LANGUAGE TemplateHaskell #-}
  2. module Internal.Utils.Three ( tests ) where
  3. import Agda.Utils.Three
  4. import Agda.Utils.Functor
  5. import Internal.Helpers
  6. -- | Tag the elements of the @n@th list with @n@, concatenate, partition, untag.
  7. -- Returns the same lists.
  8. prop_partition3_id :: [Int] -> [Int] -> [Int] -> Bool
  9. prop_partition3_id xs ys zs =
  10. (xs, ys, zs) == (map snd xs', map snd ys', map snd zs')
  11. where
  12. (xs', ys', zs') = partition3 fst $ concat
  13. [ map (One ,) xs
  14. , map (Two ,) ys
  15. , map (Three,) zs
  16. ]
  17. -- | Make three tagged copies of a list, shuffle (interleave only), partition, untag.
  18. -- Returns three copies of the original list.
  19. prop_partition3_same :: [Int] -> Bool
  20. prop_partition3_same xs =
  21. (xs, xs, xs) == (map snd xs', map snd ys', map snd zs')
  22. where
  23. (xs', ys', zs') = partition3 fst $ concat
  24. [ [ (One, x), (Two, x), (Three, x) ] | x <- xs ]
  25. ------------------------------------------------------------------------
  26. -- * All tests
  27. ------------------------------------------------------------------------
  28. -- Template Haskell hack to make the following $allProperties work
  29. -- under ghc-7.8.
  30. return [] -- KEEP!
  31. -- | All tests as collected by 'allProperties'.
  32. --
  33. -- Using 'allProperties' is convenient and superior to the manual
  34. -- enumeration of tests, since the name of the property is added
  35. -- automatically.
  36. tests :: TestTree
  37. tests = testProperties "Internal.Utils.Three" $allProperties