Skip to content

Commit

Permalink
move tests into examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfowler committed Nov 29, 2023
1 parent c25d656 commit fca0788
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion circuit-notation.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Test-Suite library-testsuite
type: exitcode-stdio-1.0
main-is: unittests.hs
hs-source-dirs: tests
build-depends: base, circuit-notation, clash-prelude >= 1.0
build-depends: base, circuit-notation
18 changes: 13 additions & 5 deletions example/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
This file contains examples of using the Circuit Notation.
-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}

#if __GLASGOW_HASKELL__ < 810
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
#endif

{-# OPTIONS -fplugin=CircuitNotation #-}
Expand All @@ -34,9 +34,9 @@ This file contains examples of using the Circuit Notation.

module Example where

import Circuit
import Circuit

import Clash.Prelude (Signal, Vec(..))
import Clash.Prelude (Signal, Vec (..))

idCircuit :: Circuit a a
idCircuit = idC
Expand Down Expand Up @@ -139,6 +139,14 @@ vec0 = circuit \[] -> ()
vec00 :: Circuit (Vec 0 a) (Vec 0 a)
vec00 = circuit \[] -> []

-- test that signals can be duplicated
dupSignalC0 :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool)
dupSignalC0 = circuit $ \x -> (x, x)

dupSignalC1 :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool, Signal dom Bool)
dupSignalC1 = circuit $ \x -> do
y <- idC -< x
idC -< (y, y, x)

-- -- myDesire :: Circuit Int Char
-- -- myDesire = Circuit (\(aM2S,bS2M) -> let
Expand Down
14 changes: 0 additions & 14 deletions tests/unittests.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE Arrows #-}

-- This option is a test by itself: if we were to export a plugin with the
-- wrong type or name, GHC would refuse to compile this file.
{-# OPTIONS -fplugin=CircuitNotation #-}
Expand All @@ -11,15 +9,3 @@ import Clash.Prelude

main :: IO ()
main = pure ()

testIdCircuit :: Circuit (Signal dom Bool) (Signal dom Bool)
testIdCircuit = circuit $ \x -> x

-- test that signals can be duplicated
testDupCircuit :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool)
testDupCircuit = circuit $ \x -> (x, x)

testDup2Circuit :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool, Signal dom Bool)
testDup2Circuit = circuit $ \x -> do
y <- idC -< x
idC -< (y, y, x)

0 comments on commit fca0788

Please sign in to comment.