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

Evaluation.Builtins.Bitwise.CIP0122

Description

Tests for CIP-0122 (the first batch of bitwise builtins)

Synopsis

Documentation

abelianSemigroupLaws ∷ String → DefaultFun → Bool → TestTree Source #

Checks that the given DefaultFun, under the given semantics, forms an abelian semigroup: that is, the operation both commutes and associates.

abelianMonoidLaws ∷ String → DefaultFun → Bool → ByteString → TestTree Source #

As abelianSemigroupLaws, but also checks that the provided ByteString is both a left and right identity.

idempotenceLaw ∷ String → DefaultFun → Bool → TestTree Source #

Checks that the provided DefaultFun, under the given semantics, is idempotent; namely, that f x x = x for any x.

absorbtionLaw ∷ String → DefaultFun → Bool → ByteString → TestTree Source #

Checks that the provided ByteString is an absorbing element for the given DefaultFun, under the given semantics. Specifically, given f as the operation and 0 as the absorbing element, for any x, f x 0 = f 0 x = 0.

leftDistributiveLaw ∷ String → String → DefaultFun → DefaultFun → Bool → TestTree Source #

Checks that the first DefaultFun distributes over the second from the left, given the specified semantics (as a Bool). More precisely, for DefaultFuns f and g, checks that f x (g y z) = g (f x y) (f x z).

distributiveLaws ∷ String → DefaultFun → Bool → TestTree Source #

Checks that the given function self-distributes both left and right.

xorInvoluteLaw ∷ TestTree Source #

If you XOR any ByteString with itself twice, nothing should change.

complementSelfInverse ∷ TestTree Source #

If you complement a ByteString twice, nothing should change.

deMorgan ∷ TestTree Source #

Checks that:

  • The complement of an AND is an OR of complements; and
  • The complement of an OR is an AND of complements.

getSet ∷ TestTree Source #

If you retrieve a bit value at an index, then write that same value to the same index, nothing should happen.

setGet ∷ TestTree Source #

If you write a bit value to an index, then retrieve the bit value at the same index, you should get back what you wrote.

setSet ∷ TestTree Source #

If you write twice to the same bit index, the second write should win.

writeBitsHomomorphismLaws ∷ TestTree Source #

Checks that:

  • Writing with an empty list of positions does nothing; and if you write a
  • boolean b with one list of positions, then a second, it is the same as
  • writing b with their concatenation.

replicateHomomorphismLaws ∷ TestTree Source #

Checks that:

  • Replicating any byte 0 times produces the empty ByteString; and
  • Replicating a byte n times, then replicating a byte m times and concatenating the results, is the same as replicating that byte n + m times.

replicateIndex ∷ TestTree Source #

Any call to replicateByteString must produce the same byte at every valid index, namely the byte specified.