diff --git a/test/CFG/CSpec.hs b/test/CFG/CSpec.hs index bdf17c6b2b6e0810a39d72a61ef6bd0a5522b2e1..d9d630598c510b247f0452370063761777fb08ed 100644 --- a/test/CFG/CSpec.hs +++ b/test/CFG/CSpec.hs @@ -17,6 +17,7 @@ import CFG.Types spec :: Spec spec = do instrsToCTest + interruptsSpec compileToCTest compileToCAllTest externDecls @@ -127,8 +128,6 @@ instrsToCTest = describe "instrsToC" $ do it "works for a given example" $ runDecision (instrsToC Nothing KindFunction example1Input) `shouldBe` example1Output 0 - interruptsSpec - compileToCTest :: Spec compileToCTest = describe "compileToC" $ do it "works with a function" $ @@ -236,19 +235,25 @@ extern void bar(); interruptsSpec :: Spec -interruptsSpec = - context "with interrupts" $ do +interruptsSpec = do + describe "instrsToC" $ + context "with interrupts" $ do + + it "doesn't trigger interrupts before kickoff" $ + runDecision (instrsToC (Just $ S.fromList [42]) KindFunction [Call "foobar" TypeSyscall True]) + `shouldNotContain'` "interrupt" - it "doesn't trigger interrupts before kickoff" $ - runDecision (instrsToC (Just $ S.fromList [42]) KindFunction [Call "foobar" TypeSyscall True]) - `shouldNotContain'` "interrupt" + it "doesn't trigger interrupts in ISRs" $ + runDecision (instrsToC (Just $ S.fromList [23]) KindISR [Call "foo" TypeSyscall False]) + `shouldNotContain'` "interrupt" - it "doesn't trigger interrupts in ISRs" $ - runDecision (instrsToC (Just $ S.fromList [23]) KindISR [Call "foo" TypeSyscall False]) - `shouldNotContain'` "interrupt" + it "triggers all available interrupts" $ + runDecision (instrsToC (Just $ S.fromList [23, 42]) KindSubtask [Call "foo" TypeSyscall False]) + `shouldSatisfy` (\x -> "23" `T.isInfixOf` x && "42" `T.isInfixOf` x) - it "triggers all available interrupts" $ - runDecision (instrsToC (Just $ S.fromList [23, 42]) KindSubtask [Call "foo" TypeSyscall False]) + describe "preIdleHook" $ + it "triggers all interrupts" $ + runDecision (preIdleHook (Just $ S.fromList [23, 42])) `shouldSatisfy` (\x -> "23" `T.isInfixOf` x && "42" `T.isInfixOf` x)