CallGraph.hs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {-# LANGUAGE ImplicitParams #-}
  2. module Internal.Termination.CallGraph ( tests ) where
  3. import Agda.Termination.CallGraph
  4. import Agda.Termination.CutOff
  5. import Agda.Termination.SparseMatrix
  6. import qualified Data.List as List
  7. import Internal.Helpers
  8. import Internal.Termination.CallMatrix ( callMatrix )
  9. ------------------------------------------------------------------------------
  10. -- prop_complete :: (?cutoff :: CutOff) => Property
  11. -- prop_complete =
  12. -- forAll (callGraph :: Gen (CallGraph [Integer])) $ \cs ->
  13. -- isComplete (complete cs)
  14. -- -- | Returns 'True' iff the call graph is complete.
  15. -- isComplete :: (Ord cinfo, Monoid cinfo, ?cutoff :: CutOff) => CallGraph cinfo -> Bool
  16. -- isComplete s = (s `union` (s `combine` s)) `notWorse` s
  17. ------------------------------------------------------------------------
  18. -- * Generators and properties
  19. ------------------------------------------------------------------------
  20. -- | Generates a call graph.
  21. callGraph :: Arbitrary cinfo => Gen (CallGraph cinfo)
  22. callGraph = do
  23. indices <- fmap List.nub arbitrary
  24. n <- natural
  25. let noMatrices | List.null indices = 0
  26. | otherwise = n `min` 3 -- Not too many.
  27. fromList <$> vectorOf noMatrices (matGen indices)
  28. where
  29. matGen indices = do
  30. [s, t] <- vectorOf 2 (elements indices)
  31. [c, r] <- vectorOf 2 (choose (0, 2)) -- Not too large.
  32. m <- callMatrix (Size { rows = r, cols = c })
  33. mkCall s t m <$> arbitrary
  34. ------------------------------------------------------------------------
  35. -- * All tests
  36. ------------------------------------------------------------------------
  37. -- (ASR 2018-01-06) Since some properties use implicit parameters we
  38. -- cannot use 'allProperties' for collecting all the tests (see
  39. -- https://github.com/nick8325/quickcheck/issues/193 ).
  40. tests :: TestTree
  41. tests = testGroup "Internal.Termination.CallGraph" []
  42. -- [ testProperty "prop_complete" prop_complete
  43. -- , testProperty "prop_ensureCompletePrecondition"
  44. -- ]
  45. where ?cutoff = DontCutOff -- CutOff 2 -- don't cut off in tests!