plutus-core-1.60.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
  • shiftHomomorphism :: [TestTree] #

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

rotateHomomorphism :: [TestTree] #

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

csbHomomorphism :: [TestTree] #

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

shiftClear :: Property #

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

csbInclusionExclusion :: Property #

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 #

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 #

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 #

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 #

Test for a regression found here.