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

Evaluation.Builtins.Bitwise.CIP0123

Description

Tests for CIP-0123(the second batch of bitwise builtins).

Synopsis

Documentation

shiftHomomorphism ∷ [TestTree] Source #

There should exist a monoid homomorphism between natural number addition and function composition for shifts over a fixed bytestring argument.

rotateHomomorphism ∷ [TestTree] Source #

There should exist a monoid homomorphism between integer addition and function composition for rotations over a fixed bytestring argument.

csbHomomorphism ∷ [TestTree] Source #

There should exist a monoid homomorphism between bytestring concatenation and natural number addition.

shiftClearProperty Source #

Shifting by more than the bit length (either positive or negative) clears the result.

rotateRolloverProperty Source #

Rotations by more than the bit length 'roll over' bits.

csbRotateProperty Source #

Rotations do not change how many set (and clear) bits there are.

shiftPosClearLowProperty Source #

Positive shifts clear low-index bits.

shiftNegClearHighProperty Source #

Negative shifts clear high-index bits.

rotateMoveBitsProperty Source #

Rotations move bits, but don't change them.

csbComplementProperty Source #

For any bytestring whose bit length is n and has k set bits, its complement should have n - k set bits.

csbInclusionExclusionProperty Source #

The inclusion-exclusion principle: specifically, for any x and y, the number of set bits in x XOR y should be the number of set bits in x OR y minus the number of set bits in x AND y.

csbXorProperty Source #

For any bytestring x, the number of set bits in x XOR x should be 0.

ffsReplicateProperty Source #

If we replicate any byte any (positive) number of times, the first set bit should be the same as in the case where we replicated it exactly once.

ffsXorProperty Source #

For any choice of bytestring, if we XOR it with itself, there should be no set bits; that is, finding the first set bit should give -1.

ffsIndexProperty Source #

If we find a valid index for the first set bit, then:

  1. The specified index should have a set bit; and
  2. Any valid smaller index should have a clear bit.

We hack the generator slightly here to ensure we don't end up with all-zeroes (or the empty bytestring), as otherwise, the test wouldn't be meaningful.

ffsZeroProperty Source #

Finding the first set bit in a bytestring with only zero bytes should always give -1.

shiftMinBoundProperty Source #

If given Int minBound as an argument, shifts behave sensibly.

rotateMinBoundProperty Source #

If given Int minBound as an argument, rotations behave sensibly.

ffs6453Property Source #

Test for a regression found here.