plutus-core-1.70.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.

shiftClear ∷ Property Source #

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

rotateRollover ∷ Property Source #

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

csbRotate ∷ Property Source #

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

shiftPosClearLow ∷ Property Source #

Positive shifts clear low-index bits.

shiftNegClearHigh ∷ Property Source #

Negative shifts clear high-index bits.

rotateMoveBits ∷ Property Source #

Rotations move bits, but don't change them.

rotateInverse ∷ Property Source #

A pos rotation and neg rotation cancel each other out.

rotateIdentity ∷ Property Source #

Rotation with multiples of bitLen is identity.

csbComplement ∷ Property Source #

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

csbInclusionExclusion ∷ Property 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.

csbXor ∷ Property Source #

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

ffsReplicate ∷ Property 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.

ffsXor ∷ Property 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.

ffsIndex ∷ Property 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.

ffsZero ∷ Property Source #

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

shiftMinBound ∷ Property Source #

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

rotateMinBound ∷ Property Source #

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

ffs6453 ∷ Property Source #

Test for a regression found here.