Skip to content

Commit

Permalink
Merge branch 'release-0.14.8'. Refs #294.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Apr 8, 2024
2 parents efa243c + 49b3505 commit 26a0655
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 178 deletions.
5 changes: 5 additions & 0 deletions yampa-test/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-04-07 Ivan Perez <[email protected]>
* Version bump (0.14.8) (#294).
* Move definitions to separate line (#292).
* Remove vertical space (#293).

2024-02-09 Ivan Perez <[email protected]>
* Version bump (0.14.7) (#289).

Expand Down
35 changes: 20 additions & 15 deletions yampa-test/tests/Test/FRP/Yampa/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ basicsf_t0r =
-- Yampa's Basic SF builders
prop_basic_identity_1 =
forAll myStream $ evalT $ Always $ prop (sf, pred)
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
sf = identity
pred = (==)
where
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
sf = identity
pred = (==)

prop_basic_identity_2 =
forAll myStream (evalT $ prop_always_equal identity (arr id))
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
where
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

-- ** constant

Expand All @@ -77,11 +79,12 @@ basicsf_t1r =

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

sf = constant 42.0
pred = const (== 42.0)
sf = constant 42.0
pred = const (== 42.0)

-- * Initialization

Expand Down Expand Up @@ -265,11 +268,12 @@ basicsf_t4r =

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

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

-- * Auxiliary

Expand All @@ -279,4 +283,5 @@ prop (a,b) = SP ((identity &&& a) >>^ uncurry b)
-- | Compares two SFs, resulting in true if they are always equal
prop_always_equal sf1 sf2 =
Always $ SP ((sf1 &&& sf2) >>> arr sameResult)
where sameResult = uncurry (==)
where
sameResult = uncurry (==)
21 changes: 12 additions & 9 deletions yampa-test/tests/Test/FRP/Yampa/Delays.hs
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,26 @@ delay_t5r = take 100 (drop 6 (embed sf (deltaEncode 0.1 (repeat ()))))
-- | Delaying by 0.0 has no effect
prop_delay_1 =
forAll myStream $ evalT $ prop_always_equal sfDelayed sf
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
where
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

sfDelayed = delay 0.0 undefined >>> sf
sf = arr (+1)
sfDelayed = delay 0.0 undefined >>> sf
sf = arr (+1)

-- | Delaying input signal by a small amount will fill in the "blank" signal
-- with the given value, which will become also the sample at the initial
-- time.
prop_delay_2 =
forAll myStream $ evalT $
(prop (sfDelayed, (\x y -> y == initialValue)))
where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
where
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

sfDelayed = delay 0.0001 initialValue
sfDelayed = delay 0.0001 initialValue

initialValue = 17
initialValue = 17

-- * Auxiliary

Expand All @@ -342,4 +344,5 @@ prop (a,b) = SP ((identity &&& a) >>^ uncurry b)
-- | Compares two SFs, resulting in true if they are always equal
prop_always_equal sf1 sf2 =
Always $ SP ((sf1 &&& sf2) >>> arr sameResult)
where sameResult = uncurry (==)
where
sameResult = uncurry (==)
31 changes: 17 additions & 14 deletions yampa-test/tests/Test/FRP/Yampa/EventS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ evsrc_t0r =
prop_event_noevent =
forAll myStream $ evalT $ Always $ prop (sfNever, const (== noEvent))

where myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
sfNever :: SF Float (Event Float)
sfNever = never
where
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
sfNever :: SF Float (Event Float)
sfNever = never

evsrc_t1 :: [Event Int]
evsrc_t1 = testSF1 (now 42)
Expand All @@ -127,13 +128,14 @@ prop_event_now =
And (prop (sf, p0)) -- Initially
(Next $ Always $ prop (sf, pn)) -- After first sample

where sf = Yampa.now 42.0
where
sf = Yampa.now 42.0

p0 x y = y == Event 42.0
pn x y = y == noEvent
p0 x y = y == Event 42.0
pn x y = y == noEvent

myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

evsrc_t2 :: [Event Int]
evsrc_t2 = testSF1 (after 0.0 42)
Expand All @@ -154,13 +156,14 @@ prop_event_after_0 =
And (prop (sf, p0)) -- Initially
(Next $ Always $ prop (sf, pn)) -- After first sample

where sf = after 0.0 42.0
where
sf = after 0.0 42.0

p0 x y = y == Event 42.0
pn x y = y == noEvent
p0 x y = y == Event 42.0
pn x y = y == noEvent

myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream
myStream :: Gen (SignalSampleStream Float)
myStream = uniDistStream

evsrc_t3 :: [Event Int]
evsrc_t3 = testSF1 (after 3.0 42)
Expand Down
13 changes: 7 additions & 6 deletions yampa-test/tests/Test/FRP/Yampa/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,16 @@ prop_derivative_1 =
forAll myStream $ evalT $
Next $ Always $ prop ((sfDer &&& sfDerByHand), const close)

where myStream :: Gen (SignalSampleStream Double)
myStream = fixedDelayStreamWith (\t -> sin(2 * pi * t)) der_step
where
myStream :: Gen (SignalSampleStream Double)
myStream = fixedDelayStreamWith (\t -> sin(2 * pi * t)) der_step

sfDer :: SF Time Time
sfDer = derivative
sfDer :: SF Time Time
sfDer = derivative

sfDerByHand = localTime >>> arr (\t -> (2 * pi * cos (2 * pi * t)))
sfDerByHand = localTime >>> arr (\t -> (2 * pi * cos (2 * pi * t)))

close (x,y) = abs (x-y) < 0.05
close (x,y) = abs (x-y) < 0.05

prop_derivative_2 =
forAll myStream $ evalT $
Expand Down
Loading

0 comments on commit 26a0655

Please sign in to comment.