From 582fe5e0c043f4533787473f2a9942e943ccd5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Sun, 27 Oct 2024 13:14:38 +0100 Subject: [PATCH] Add regression test for #365 --- rhine/test/Clock/FixedStep.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rhine/test/Clock/FixedStep.hs b/rhine/test/Clock/FixedStep.hs index 56e09dda..9d230e14 100644 --- a/rhine/test/Clock/FixedStep.hs +++ b/rhine/test/Clock/FixedStep.hs @@ -3,6 +3,10 @@ module Clock.FixedStep where +-- base +import Data.List (sort) +import Data.Maybe (catMaybes) + -- vector-sized import Data.Vector.Sized (toList) @@ -12,8 +16,13 @@ import Test.Tasty (testGroup) -- tasty-hunit import Test.Tasty.HUnit (testCase, (@?=)) +-- monad-schedule +import Control.Monad.Schedule.Trans (runScheduleIO) + -- rhine import FRP.Rhine + +-- rhine (test) import Util tests = @@ -50,4 +59,13 @@ tests = , Nothing , Just ([24, 21, 18, 15], 24) ] + , testGroup + "Schedule" + [ testCase "Can schedule two FixedStep clocks" $ do + let f300 = absoluteS @@ FixedStep @300 + let f500 = absoluteS @@ FixedStep @500 + output <- runScheduleIO @_ @Integer $ runRhine (f300 +@+ f500) $ replicate 10 () + let timestamps = either id id <$> catMaybes output + timestamps @?= sort timestamps + ] ]