{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications  #-}
{-# LANGUAGE TypeFamilies  #-}
{-# LANGUAGE FlexibleContexts  #-}

module Tests.AssessmentIntervals
  ( tests
  ) where

import           EventDataTheory
import           Hasklepias.AssessmentIntervals
import           Test.Tasty
import           Test.Tasty.QuickCheck

prop_baseline :: (iv ~ Interval a, Ord a, SizedIv iv) => Moment iv -> iv -> Property
prop_baseline :: forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_baseline Moment iv
dur iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Baseline i, SizedIv (Interval a)) =>
Moment (Interval a) -> i a -> BaselineInterval a
baselineMeets Moment iv
dur iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
Meets

prop_baselineFinishedBy
  :: (iv ~ Interval a, Ord a, SizedIv iv) => Moment iv -> iv -> Property
prop_baselineFinishedBy :: forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_baselineFinishedBy Moment iv
d iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Baseline i, SizedIv (Interval a), Ord a) =>
Moment (Interval a) -> i a -> BaselineInterval a
baselineFinishedBy Moment iv
d iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
FinishedBy

prop_baselineBefore
  :: (iv ~ Interval a, Ord a, SizedIv iv) => Moment iv -> Moment iv -> iv -> Property
prop_baselineBefore :: forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> Moment iv -> iv -> Property
prop_baselineBefore Moment iv
s Moment iv
d iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Baseline i, SizedIv (Interval a)) =>
Moment (Interval a)
-> Moment (Interval a) -> i a -> BaselineInterval a
baselineBefore Moment iv
s Moment iv
d iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
Before

prop_followup :: (iv ~ Interval a, Ord a, Ord (Moment iv), Num (Moment iv), SizedIv iv) => 
  Moment iv -> iv -> Property
prop_followup :: forall iv a.
(iv ~ Interval a, Ord a, Ord (Moment iv), Num (Moment iv),
 SizedIv iv) =>
Moment iv -> iv -> Property
prop_followup Moment iv
d iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Followup i a, SizedIv (Interval a), Ord (Moment (Interval a)),
 Num (Moment (Interval a)), Intervallic i) =>
Moment (Interval a) -> i a -> FollowupInterval a
followup Moment iv
d iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
StartedBy

prop_followupMetBy :: (iv ~ Interval a, Ord a, SizedIv iv) => Moment iv -> iv -> Property
prop_followupMetBy :: forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_followupMetBy Moment iv
d iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Followup i a, SizedIv (Interval a), Intervallic i) =>
Moment (Interval a) -> i a -> FollowupInterval a
followupMetBy Moment iv
d iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
MetBy

prop_followupAfter
  :: (iv ~ Interval a, Ord a, SizedIv iv) => Moment iv -> Moment iv -> iv -> Property
prop_followupAfter :: forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> Moment iv -> iv -> Property
prop_followupAfter Moment iv
s Moment iv
d iv
i = forall a (i0 :: * -> *) (i1 :: * -> *).
(Iv (Interval a), Intervallic i0, Intervallic i1) =>
i0 a -> i1 a -> IntervalRelation
relate (forall (i :: * -> *) a.
(Followup i a, SizedIv (Interval a), Intervallic i) =>
Moment (Interval a)
-> Moment (Interval a) -> i a -> FollowupInterval a
followupAfter Moment iv
s Moment iv
d iv
i) iv
i forall a. (Eq a, Show a) => a -> a -> Property
=== IntervalRelation
After

tests :: TestTree
tests :: TestTree
tests = TestName -> [(TestName, Property)] -> TestTree
testProperties
  TestName
"Property tests of AssessmentIntervals"
  [ (TestName
"baseline meets index", forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_baseline @(Interval Int)))
  , ( TestName
"baselineFinishedBy finishes index"
    , forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_baselineFinishedBy @(Interval Int))
    )
  , (TestName
"baselineBefore precedes index", forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> Moment iv -> iv -> Property
prop_baselineBefore @(Interval Int)))
  , (TestName
"followup starts index"        , forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, Ord (Moment iv), Num (Moment iv),
 SizedIv iv) =>
Moment iv -> iv -> Property
prop_followup @(Interval Int)))
  , (TestName
"followupMetBy metBy index"    , forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> iv -> Property
prop_followupMetBy @(Interval Int)))
  , (TestName
"followupAfter after index"    , forall prop. Testable prop => prop -> Property
property (forall iv a.
(iv ~ Interval a, Ord a, SizedIv iv) =>
Moment iv -> Moment iv -> iv -> Property
prop_followupAfter @(Interval Int)))
  ]