{-# LANGUAGE NoImplicitPrelude #-}
module Copilot.Verifier.Examples.ShouldFail.Partial.DivByZero where
import Language.Copilot
import Copilot.Compile.C99
import Copilot.Verifier ( Verbosity, VerifierOptions(..)
, defaultVerifierOptions, verifyWithOptions )
spec :: Spec
spec :: Spec
spec = do
let stream :: Stream Int16
stream :: Stream Int16
stream = String -> Maybe [Int16] -> Stream Int16
forall a. Typed a => String -> Maybe [a] -> Stream a
extern String
"stream" Maybe [Int16]
forall a. Maybe a
Nothing
PropRef Universal
_ <- String -> Prop Universal -> Writer [SpecItem] (PropRef Universal)
forall a. String -> Prop a -> Writer [SpecItem] (PropRef a)
prop String
"nonzero" (Stream Bool -> Prop Universal
forAll (Stream Int16
stream Stream Int16 -> Stream Int16 -> Stream Bool
forall a. (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool
/= Stream Int16
0))
String -> Stream Bool -> [Arg] -> Spec
trigger String
"streamDiv" ((Stream Int16
stream Stream Int16 -> Stream Int16 -> Stream Int16
forall a. (Typed a, Integral a) => Stream a -> Stream a -> Stream a
`div` Stream Int16
stream) Stream Int16 -> Stream Int16 -> Stream Bool
forall a. (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool
== Stream Int16
1) [Stream Int16 -> Arg
forall a. Typed a => Stream a -> Arg
arg Stream Int16
stream]
verifySpec :: Verbosity -> IO ()
verifySpec :: Verbosity -> IO ()
verifySpec Verbosity
verb = do
Spec
spec' <- Spec -> IO Spec
forall a. Spec' a -> IO Spec
reify Spec
spec
VerifierOptions -> CSettings -> [String] -> String -> Spec -> IO ()
verifyWithOptions VerifierOptions
defaultVerifierOptions{verbosity = verb}
CSettings
mkDefaultCSettings
[]
String
"divByZeroFail" Spec
spec'