Skip to content

Commit 1c8abc8

Browse files
committed
Reinstate some pretty related things
1 parent c86ff3e commit 1c8abc8

File tree

4 files changed

+26
-23
lines changed
  • libs
    • cardano-ledger-conformance
    • cardano-ledger-core/testlib/Test/Cardano/Ledger

4 files changed

+26
-23
lines changed

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxo.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import qualified Data.Text as T
2323
import Lens.Micro ((&), (.~), (^.))
2424
import qualified MAlonzo.Code.Ledger.Foreign.API as Agda
2525
import Prettyprinter ((<+>))
26-
import qualified Prettyprinter as PP
27-
import Test.Cardano.Ledger.Common (Arbitrary (..), Gen, showExpr)
26+
import Test.Cardano.Ledger.Common (Arbitrary (..), Gen, ppString, showExpr, vcat)
2827
import Test.Cardano.Ledger.Conformance (
2928
ExecSpecRule (..),
3029
SpecTranslate (..),
@@ -50,7 +49,6 @@ import Test.Cardano.Ledger.Generic.GenState (
5049
runGenRS,
5150
)
5251
import qualified Test.Cardano.Ledger.Generic.GenState as GenSize
53-
import qualified Test.Cardano.Ledger.Generic.PrettyCore as PP
5452
import qualified Test.Cardano.Ledger.Generic.Proof as Proof
5553
import Test.Cardano.Ledger.Generic.TxGen (genAlonzoTx)
5654

@@ -95,16 +93,16 @@ instance ExecSpecRule "UTXO" ConwayEra where
9593
Agda.utxoStep externalFunctions env st sig
9694

9795
extraInfo _ ctx env@UtxoEnv {..} st@UTxOState {..} sig st' =
98-
PP.vcat
96+
vcat
9997
[ "Impl:"
100-
, PP.ppString (showConwayTxBalance uePParams ueCertState utxosUtxo sig)
101-
, "initial TotalAda:" <+> PP.ppString (showExpr $ totalAda st)
98+
, ppString (showConwayTxBalance uePParams ueCertState utxosUtxo sig)
99+
, "initial TotalAda:" <+> ppString (showExpr $ totalAda st)
102100
, "final TotalAda: " <+> case st' of
103-
Right (x, _) -> PP.ppString (showExpr $ totalAda x)
101+
Right (x, _) -> ppString (showExpr $ totalAda x)
104102
Left _ -> "N/A"
105103
, mempty
106104
, "Spec:"
107-
, PP.ppString
105+
, ppString
108106
( either show T.unpack . runSpecTransM ctx $
109107
Agda.utxoDebug externalFunctions
110108
<$> toSpecRep env

libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Data.Bifunctor (Bifunctor (..))
2121
import qualified Data.Text as T
2222
import Lens.Micro ((^.))
2323
import qualified MAlonzo.Code.Ledger.Foreign.API as Agda
24-
import qualified Prettyprinter as PP
24+
import Test.Cardano.Ledger.Common (ppString, showExpr, vcat)
2525
import Test.Cardano.Ledger.Conformance (
2626
ExecSpecRule (..),
2727
SpecTranslate,
@@ -42,9 +42,7 @@ import Test.Cardano.Ledger.Constrained.Conway (
4242
utxoStateSpec,
4343
utxoTxSpec,
4444
)
45-
import qualified Test.Cardano.Ledger.Generic.PrettyCore as PP
4645
import Test.Cardano.Ledger.Shelley.Utils (runSTS)
47-
import Test.Cardano.Ledger.TreeDiff (showExpr)
4846

4947
instance
5048
SpecTranslate ConwayTxBodyTransContext (ConwayTxCert ConwayEra) =>
@@ -69,15 +67,15 @@ instance
6967
stFinal = first showOpaqueErrorString $ runSTS @"UTXO" @ConwayEra globals env st sig
7068
utxoInfo = extraInfo @"UTXO" @ConwayEra globals ctx env st sig stFinal
7169
in
72-
PP.vcat
70+
vcat
7371
[ "UTXOW"
7472
, "Impl:"
7573
, "witsVKeyNeeded"
76-
, PP.ppString . showExpr $
74+
, ppString . showExpr $
7775
getConwayWitsVKeyNeeded @ConwayEra (utxosUtxo st) (sig ^. bodyTxL)
7876
, "witsVKeyHashes"
7977
, "Spec:"
80-
, PP.ppString result
78+
, ppString result
8179
, mempty
8280
, "UTXO"
8381
, utxoInfo

libs/cardano-ledger-conformance/test/Test/Cardano/Ledger/Conformance/ExecSpecRule/MiniTrace.hs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import Test.Cardano.Ledger.Conformance.ExecSpecRule.Conway (
3939
namePoolCert,
4040
nameTxCert,
4141
)
42-
import Test.Cardano.Ledger.Generic.PrettyCore (PrettyA (..))
4342
import Test.Cardano.Ledger.Generic.Proof (Proof (..), WitRule (..), goSTS)
4443
import qualified Test.Cardano.Ledger.Generic.Proof as Proof
4544

@@ -50,8 +49,8 @@ minitraceEither ::
5049
forall s e.
5150
( ExecSpecRule s e
5251
, ExecState s e ~ State (EraRule s e)
53-
, PrettyA (Signal (EraRule s e))
54-
, PrettyA (State (EraRule s e))
52+
, ToExpr (Signal (EraRule s e))
53+
, ToExpr (State (EraRule s e))
5554
) =>
5655
WitRule s e ->
5756
Int ->
@@ -77,8 +76,8 @@ minitraceEither witrule n0 = do
7776
Left ps ->
7877
pure
7978
( Left
80-
( [ "\nSIGNAL = " ++ show (prettyA signal2)
81-
, "\nSTATE = " ++ show (prettyA state)
79+
( [ "\nSIGNAL = " ++ show (toExpr signal2)
80+
, "\nSTATE = " ++ show (toExpr state)
8281
, "\nPredicateFailures"
8382
]
8483
++ map show (NE.toList ps)
@@ -96,8 +95,8 @@ minitrace ::
9695
forall s e.
9796
( ExecSpecRule s e
9897
, ExecState s e ~ State (EraRule s e)
99-
, PrettyA (Signal (EraRule s e))
100-
, PrettyA (State (EraRule s e))
98+
, ToExpr (Signal (EraRule s e))
99+
, ToExpr (State (EraRule s e))
101100
) =>
102101
WitRule s e ->
103102
Int ->
@@ -112,8 +111,8 @@ minitraceProp ::
112111
forall s e.
113112
( ExecSpecRule s e
114113
, ExecState s e ~ State (EraRule s e)
115-
, PrettyA (Signal (EraRule s e))
116-
, PrettyA (State (EraRule s e))
114+
, ToExpr (Signal (EraRule s e))
115+
, ToExpr (State (EraRule s e))
117116
) =>
118117
WitRule s e ->
119118
Int ->

libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Common.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ module Test.Cardano.Ledger.Common (
4141

4242
-- * Miscellanous helpers
4343
tracedDiscard,
44+
45+
-- * Prettyprinter related
46+
ppString,
47+
vcat,
4448
) where
4549

4650
import Control.DeepSeq (NFData)
4751
import Control.Monad as X (forM_, replicateM, replicateM_, unless, void, when, (>=>))
4852
import qualified Debug.Trace as Debug
53+
import Prettyprinter (Doc, pretty, vcat)
4954
import Test.Cardano.Ledger.Binary.TreeDiff (
5055
ToExpr (..),
5156
ansiExpr,
@@ -122,3 +127,6 @@ runGen ::
122127
Gen a ->
123128
a
124129
runGen seed size gen = unGen gen (mkQCGen seed) size
130+
131+
ppString :: String -> Doc a
132+
ppString = pretty

0 commit comments

Comments
 (0)