Skip to content

Commit

Permalink
yampa-test: Organize module Basic following Yampa's order. Refs #217.
Browse files Browse the repository at this point in the history
Understanding which parts of Yampa are tested and which ones are not is
generally hard. To facilitate keeping track of which elements are tested
and which ones are not, this commit organizes the elements of Basic in
the same order and with the same haddock section separators as they have
in Yampa's counterpart.
  • Loading branch information
ivanperez-keera committed May 21, 2022
1 parent af3a339 commit 0f797b8
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions yampa-test/tests/Test/FRP/Yampa/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ import TestsCommon
tests :: TestTree
tests = testGroup "Regression tests for FRP.Yampa.Basic"
[ testProperty "identity (fixed)" (property $ basicsf_t0 ~= basicsf_t0r)
, testProperty "constant (fixed)" (property $ basicsf_t1 ~= basicsf_t1r)
, testProperty "initially (fixed)" (property $ basicsf_t4 ~= basicsf_t4r)
, testProperty "identity (qc)" prop_basic_identity_1
, testProperty "identity (qc)" prop_basic_identity_2
, testProperty "constant (fixed)" (property $ basicsf_t1 ~= basicsf_t1r)
, testProperty "constant (qc)" prop_basic_constant
, testProperty "initially (fixed)" (property $ basicsf_t4 ~= basicsf_t4r)
, testProperty "initially (qc)" prop_basic_initially
]

-- * Basic signal functions

basicsf_t0 :: [Double]
basicsf_t0 = testSF1 identity
basicsf_t0r =
Expand All @@ -37,22 +39,6 @@ basicsf_t0r =
, 20.0, 21.0, 22.0, 23.0, 24.0
]

basicsf_t1 :: [Double]
basicsf_t1 = testSF1 (constant 42.0)
basicsf_t1r =
[ 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0
, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0
, 42.0, 42.0, 42.0, 42.0, 42.0
]

basicsf_t4 :: [Double]
basicsf_t4 = testSF1 (initially 42.0)
basicsf_t4r =
[ 42.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0
, 20.0, 21.0, 22.0, 23.0, 24.0
]

-- Yampa's Basic SF builders
prop_basic_identity_1 =
forAll myStream $ evalT $ Always $ prop (sf, pred)
Expand All @@ -66,6 +52,14 @@ prop_basic_identity_2 =
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

basicsf_t1 :: [Double]
basicsf_t1 = testSF1 (constant 42.0)
basicsf_t1r =
[ 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0
, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0, 42.0
, 42.0, 42.0, 42.0, 42.0, 42.0
]

prop_basic_constant =
forAll myStream $ evalT $ Always $ prop (sf, pred)
where myStream :: Gen (SignalSampleStream Float)
Expand All @@ -74,13 +68,7 @@ prop_basic_constant =
sf = constant 42.0
pred = const (== 42.0)

prop_basic_initially =
forAll myStream $ evalT $ prop (sf, pred)
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

sf = initially 42.0
pred = const (== 42.0)
-- * Initialization

prop_insert =
forAll initialValueG $ \initialValue ->
Expand All @@ -101,6 +89,24 @@ prop_insert =
finalValueG :: Gen Float
finalValueG = arbitrary

basicsf_t4 :: [Double]
basicsf_t4 = testSF1 (initially 42.0)
basicsf_t4r =
[ 42.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0
, 20.0, 21.0, 22.0, 23.0, 24.0
]

prop_basic_initially =
forAll myStream $ evalT $ prop (sf, pred)
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

sf = initially 42.0
pred = const (== 42.0)

-- * Auxiliary

-- prop :: SF a b -> (a -> b ->
prop (a,b) = SP ((identity &&& a) >>^ uncurry b)

Expand Down

0 comments on commit 0f797b8

Please sign in to comment.