plutus-core-1.36.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.Test

Synopsis

Documentation

mapTestLimit ∷ (TestLimitTestLimit) → PropertyProperty Source #

Map the TestLimit of a Property with a given function.

withAtLeastTestsTestLimitPropertyProperty Source #

Set the number of times a property should be executed before it is considered successful, unless it's already higher than that.

mapTestLimitAtLeastTestLimit → (TestLimitTestLimit) → PropertyProperty Source #

Set the number of times a property should be executed before it is considered successful, unless the given function scales it higher than that.

checkFailsPropertyIO () Source #

Check that the given Property fails.

isSerialisableSome (ValueOf DefaultUni) → Bool Source #

Check whether the given constant can be serialised. Useful for tests of the parser/deserializer where we need to filter out unprintable/unserialisable terms. Technically, G1, G2 elements etc can be printed but not serialised, but here for simplicity we just assume that all unserialisable terms are unprintable too.

class ToTPlc a uni fun | a → uni fun where Source #

Class for ad-hoc overloading of things which can be turned into a PLC program. Any errors from the process should be caught.

Methods

toTPlc ∷ a → ExceptT SomeException IO (Program TyName Name uni fun ()) Source #

Instances

Instances details
ToTPlc a uni fun ⇒ ToTPlc (ExceptT SomeException IO a) uni fun Source # 
Instance details

Defined in PlutusCore.Test

ToTPlc (Program TyName Name uni fun ()) uni fun Source # 
Instance details

Defined in PlutusCore.Test

Methods

toTPlcProgram TyName Name uni fun () → ExceptT SomeException IO (Program TyName Name uni fun ()) Source #

(GEq uni, Typecheckable uni fun, PrettyUni uni, Pretty fun, Pretty a, Typeable a, Ord a, Default (CostingPart uni fun), Default (BuiltinsInfo uni fun), Default (RewriteRules uni fun)) ⇒ ToTPlc (Program TyName Name uni fun a) uni fun Source # 
Instance details

Defined in PlutusIR.Test

Methods

toTPlcProgram TyName Name uni fun a → ExceptT SomeException IO (Program0 TyName Name uni fun ()) Source #

class ToUPlc a uni fun | a → uni fun where Source #

Methods

toUPlc ∷ a → ExceptT SomeException IO (Program Name uni fun ()) Source #

Instances

Instances details
ToUPlc a uni fun ⇒ ToUPlc (ExceptT SomeException IO a) uni fun Source # 
Instance details

Defined in PlutusCore.Test

ToUPlc (Program NamedDeBruijn uni fun ()) uni fun Source # 
Instance details

Defined in PlutusCore.Test

Methods

toUPlcProgram NamedDeBruijn uni fun () → ExceptT SomeException IO (Program Name uni fun ()) Source #

ToUPlc (Program Name uni fun ()) uni fun Source # 
Instance details

Defined in PlutusCore.Test

Methods

toUPlcProgram Name uni fun () → ExceptT SomeException IO (Program Name uni fun ()) Source #

(Typecheckable uni fun, Hashable fun) ⇒ ToUPlc (Program TyName Name uni fun ()) uni fun Source # 
Instance details

Defined in PlutusCore.Test

Methods

toUPlcProgram TyName Name uni fun () → ExceptT SomeException IO (Program0 Name uni fun ()) Source #

(GEq uni, Typecheckable uni fun, PrettyUni uni, Pretty fun, Hashable fun, Pretty a, Typeable a, Ord a, Default (CostingPart uni fun), Default (BuiltinsInfo uni fun), Default (RewriteRules uni fun)) ⇒ ToUPlc (Program TyName Name uni fun a) uni fun Source # 
Instance details

Defined in PlutusIR.Test

Methods

toUPlcProgram TyName Name uni fun a → ExceptT SomeException IO (Program0 Name uni fun ()) Source #

pureTryException e ⇒ a → Either e a Source #

goldenUEvalProfileToUPlc a DefaultUni DefaultFunString → [a] → TestNested Source #

This is mostly useful for profiling a test that is normally tested with one of the other functions, as it's a drop-in replacement and you can then pass the output into traceToStacks.

goldenUEvalProfile'ToUPlc a DefaultUni DefaultFunString → [a] → TestNested Source #

This is mostly useful for profiling a test that is normally tested with one of the other functions, as it's a drop-in replacement and you can then pass the output into traceToStacks.

initialSrcSpanFilePathSrcSpan Source #

A made-up SrcSpan for testing.

newtype NoMarkRenameT ren m a Source #

A version of RenameT that fails to take free variables into account.

Constructors

NoMarkRenameT 

Fields

Instances

Instances details
Monad m ⇒ MonadReader ren (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

askNoMarkRenameT ren m ren Source #

local ∷ (ren → ren) → NoMarkRenameT ren m a → NoMarkRenameT ren m a Source #

reader ∷ (ren → a) → NoMarkRenameT ren m a Source #

Alternative m ⇒ Alternative (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

emptyNoMarkRenameT ren m a Source #

(<|>)NoMarkRenameT ren m a → NoMarkRenameT ren m a → NoMarkRenameT ren m a Source #

someNoMarkRenameT ren m a → NoMarkRenameT ren m [a] Source #

manyNoMarkRenameT ren m a → NoMarkRenameT ren m [a] Source #

Applicative m ⇒ Applicative (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

pure ∷ a → NoMarkRenameT ren m a Source #

(<*>)NoMarkRenameT ren m (a → b) → NoMarkRenameT ren m a → NoMarkRenameT ren m b Source #

liftA2 ∷ (a → b → c) → NoMarkRenameT ren m a → NoMarkRenameT ren m b → NoMarkRenameT ren m c Source #

(*>)NoMarkRenameT ren m a → NoMarkRenameT ren m b → NoMarkRenameT ren m b Source #

(<*)NoMarkRenameT ren m a → NoMarkRenameT ren m b → NoMarkRenameT ren m a Source #

Functor m ⇒ Functor (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

fmap ∷ (a → b) → NoMarkRenameT ren m a → NoMarkRenameT ren m b Source #

(<$) ∷ a → NoMarkRenameT ren m b → NoMarkRenameT ren m a Source #

Monad m ⇒ Monad (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

(>>=)NoMarkRenameT ren m a → (a → NoMarkRenameT ren m b) → NoMarkRenameT ren m b Source #

(>>)NoMarkRenameT ren m a → NoMarkRenameT ren m b → NoMarkRenameT ren m b Source #

return ∷ a → NoMarkRenameT ren m a Source #

MonadQuote m ⇒ MonadQuote (NoMarkRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

liftQuoteQuote a → NoMarkRenameT ren m a Source #

noMarkRenameMonoid ren ⇒ (t → NoMarkRenameT ren m t) → t → m t Source #

newtype NoRenameT (ren ∷ Type) m a Source #

A version of RenameT that does not perform any renaming at all.

Constructors

NoRenameT 

Fields

Instances

Instances details
(Monad m, Monoid ren) ⇒ MonadReader ren (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

askNoRenameT ren m ren Source #

local ∷ (ren → ren) → NoRenameT ren m a → NoRenameT ren m a Source #

reader ∷ (ren → a) → NoRenameT ren m a Source #

Alternative m ⇒ Alternative (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

emptyNoRenameT ren m a Source #

(<|>)NoRenameT ren m a → NoRenameT ren m a → NoRenameT ren m a Source #

someNoRenameT ren m a → NoRenameT ren m [a] Source #

manyNoRenameT ren m a → NoRenameT ren m [a] Source #

Applicative m ⇒ Applicative (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

pure ∷ a → NoRenameT ren m a Source #

(<*>)NoRenameT ren m (a → b) → NoRenameT ren m a → NoRenameT ren m b Source #

liftA2 ∷ (a → b → c) → NoRenameT ren m a → NoRenameT ren m b → NoRenameT ren m c Source #

(*>)NoRenameT ren m a → NoRenameT ren m b → NoRenameT ren m b Source #

(<*)NoRenameT ren m a → NoRenameT ren m b → NoRenameT ren m a Source #

Functor m ⇒ Functor (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

fmap ∷ (a → b) → NoRenameT ren m a → NoRenameT ren m b Source #

(<$) ∷ a → NoRenameT ren m b → NoRenameT ren m a Source #

Monad m ⇒ Monad (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

(>>=)NoRenameT ren m a → (a → NoRenameT ren m b) → NoRenameT ren m b Source #

(>>)NoRenameT ren m a → NoRenameT ren m b → NoRenameT ren m b Source #

return ∷ a → NoRenameT ren m a Source #

MonadQuote m ⇒ MonadQuote (NoRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

liftQuoteQuote a → NoRenameT ren m a Source #

noRenameMonadQuote m ⇒ (t → m ()) → (t → NoRenameT ren m t) → t → m t Source #

newtype BrokenRenameT ren m a Source #

A broken version of RenameT whose local updates the scope globally (as opposed to locally).

Constructors

BrokenRenameT 

Fields

Instances

Instances details
Monad m ⇒ MonadReader ren (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

askBrokenRenameT ren m ren Source #

local ∷ (ren → ren) → BrokenRenameT ren m a → BrokenRenameT ren m a Source #

reader ∷ (ren → a) → BrokenRenameT ren m a Source #

Monad m ⇒ MonadState ren (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

getBrokenRenameT ren m ren Source #

put ∷ ren → BrokenRenameT ren m () Source #

state ∷ (ren → (a, ren)) → BrokenRenameT ren m a Source #

MonadPlus m ⇒ Alternative (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

emptyBrokenRenameT ren m a Source #

(<|>)BrokenRenameT ren m a → BrokenRenameT ren m a → BrokenRenameT ren m a Source #

someBrokenRenameT ren m a → BrokenRenameT ren m [a] Source #

manyBrokenRenameT ren m a → BrokenRenameT ren m [a] Source #

Monad m ⇒ Applicative (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

pure ∷ a → BrokenRenameT ren m a Source #

(<*>)BrokenRenameT ren m (a → b) → BrokenRenameT ren m a → BrokenRenameT ren m b Source #

liftA2 ∷ (a → b → c) → BrokenRenameT ren m a → BrokenRenameT ren m b → BrokenRenameT ren m c Source #

(*>)BrokenRenameT ren m a → BrokenRenameT ren m b → BrokenRenameT ren m b Source #

(<*)BrokenRenameT ren m a → BrokenRenameT ren m b → BrokenRenameT ren m a Source #

Functor m ⇒ Functor (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

fmap ∷ (a → b) → BrokenRenameT ren m a → BrokenRenameT ren m b Source #

(<$) ∷ a → BrokenRenameT ren m b → BrokenRenameT ren m a Source #

Monad m ⇒ Monad (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

(>>=)BrokenRenameT ren m a → (a → BrokenRenameT ren m b) → BrokenRenameT ren m b Source #

(>>)BrokenRenameT ren m a → BrokenRenameT ren m b → BrokenRenameT ren m b Source #

return ∷ a → BrokenRenameT ren m a Source #

MonadQuote m ⇒ MonadQuote (BrokenRenameT ren m) Source # 
Instance details

Defined in PlutusCore.Test

Methods

liftQuoteQuote a → BrokenRenameT ren m a Source #

runBrokenRenameT ∷ (Monad m, Monoid ren) ⇒ BrokenRenameT ren m a → m a Source #

brokenRename ∷ (MonadQuote m, Monoid ren) ⇒ (t → m ()) → (t → BrokenRenameT ren m t) → t → m t Source #

data Prerename Source #

Determines whether to perform renaming before running the scoping tests. Needed for passes that don't perform renaming themselves.

Constructors

PrerenameYes 
PrerenameNo 

data BindingRemoval Source #

Whether it's OK if the pass removes bindings. A renamer isn't supposed to do that, but for example an inliner may do it, since it's basically the entire point of an inliner.

Instances

Instances details
Show BindingRemoval 
Instance details

Defined in PlutusCore.Check.Scoping

Eq BindingRemoval 
Instance details

Defined in PlutusCore.Check.Scoping

prop_scopingFor Source #

Arguments

∷ (PrettyPlc (t NameAnn), Rename (t NameAnn), Scoping t) 
AstGen (t ann)

A generator of types/terms/programs.

BindingRemoval

Whether binding removal is expected for the pass.

Prerename

Whether renaming is required before running the scoping tests. Note that the scoping tests rely on global uniqueness themselves, hence for any pass that doesn't perform renaming internally this needs to be PrerenameYes.

→ (t NameAnnQuote (t NameAnn))

The runner of the pass.

Property 

Test scoping for a renamer.

test_scopingGood Source #

Arguments

∷ (PrettyPlc (t NameAnn), Rename (t NameAnn), Scoping t) 
String

The name of the pass we're about to test.

AstGen (t ann)

A generator of types/terms/programs.

BindingRemoval

Whether binding removal is expected for the pass.

Prerename

Whether renaming is required before running the scoping tests. Note that the scoping tests rely on global uniqueness themselves, hence for any pass that doesn't perform renaming internally this needs to be PrerenameYes.

→ (t NameAnnQuote (t NameAnn))

The runner of the pass.

TestTree 

Test that a pass does not break global uniqueness.

test_scopingBad Source #

Arguments

∷ (PrettyPlc (t NameAnn), Rename (t NameAnn), Scoping t) 
String

The name of the pass we're about to test.

AstGen (t ann)

A generator of types/terms/programs.

BindingRemoval

Whether binding removal is expected for the pass.

Prerename

Whether renaming is required before running the scoping tests. Note that the scoping tests rely on global uniqueness themselves, hence for any pass that doesn't perform renaming internally this needs to be PrerenameYes.

→ (t NameAnnQuote (t NameAnn))

The runner of the pass.

TestTree 

Test that a pass breaks global uniqueness.

test_scopingSpoilRenamer ∷ (PrettyPlc (t NameAnn), Rename (t NameAnn), Scoping t, Monoid ren) ⇒ AstGen (t ann) → (t NameAnnQuote ()) → (∀ m. (MonadQuote m, MonadReader ren m) ⇒ t NameAnn → m (t NameAnn)) → TestTree Source #

Test that the scoping machinery fails when the given renamer is spoiled in some way (e.g. marking is removed) to ensure that the machinery does catch bugs.

Tasty extras

Orphan instances

Monoid SrcSpan Source # 
Instance details

Semigroup SrcSpan Source # 
Instance details