-
Notifications
You must be signed in to change notification settings - Fork 212
/
TypeErrorSpec.hs
43 lines (36 loc) · 1.58 KB
/
TypeErrorSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{-# OPTIONS_GHC -fdefer-type-errors #-}
{-# OPTIONS_GHC -fno-warn-deferred-out-of-scope-variables #-}
{-# OPTIONS_GHC -fno-warn-deferred-type-errors #-}
{-# OPTIONS_GHC -fno-warn-dodgy-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Cardano.Wallet.Primitive.Types.UTxOSelectionSpec.TypeErrorSpec
( spec
) where
import Prelude
import Cardano.Wallet.Primitive.Types.UTxOSelection
( UTxOSelection (..), UTxOSelectionNonEmpty (..) )
import Test.Hspec
( Expectation, Spec, describe, it )
import Test.ShouldNotTypecheck
( shouldNotTypecheck )
-- The data constructors for 'UTxOSelection' and 'UTxOSelectionNonEmpty' are
-- not exported, by design, as their internal data structures have invariants
-- that must be preserved across all operations.
--
-- Exporting these constructors would make it possible for functions outside
-- the 'UTxOSelection' module to break these invariants.
--
-- Therefore, we test here that they are not exported.
--
spec :: Spec
spec = describe "UTxOSelection type error tests" $ do
it "Data constructor is not exported for UTxOSelection"
testDataConstructorNotExportedForUTxOSelection
it "Data constructor is not exported for UTxOSelectionNonEmpty"
testDataConstructorNotExportedForUTxOSelectionNonEmpty
testDataConstructorNotExportedForUTxOSelection :: Expectation
testDataConstructorNotExportedForUTxOSelection =
shouldNotTypecheck UTxOSelection
testDataConstructorNotExportedForUTxOSelectionNonEmpty :: Expectation
testDataConstructorNotExportedForUTxOSelectionNonEmpty =
shouldNotTypecheck UTxOSelectionNonEmpty