Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Evaluation.Builtins.Bitwise.CIP0123
Description
Tests for CIP-0123(the second batch of bitwise builtins).
Synopsis
- shiftHomomorphism ∷ [TestTree]
- rotateHomomorphism ∷ [TestTree]
- csbHomomorphism ∷ [TestTree]
- shiftClear ∷ Property
- rotateRollover ∷ Property
- csbRotate ∷ Property
- shiftPosClearLow ∷ Property
- shiftNegClearHigh ∷ Property
- rotateMoveBits ∷ Property
- csbComplement ∷ Property
- csbInclusionExclusion ∷ Property
- csbXor ∷ Property
- ffsReplicate ∷ Property
- ffsXor ∷ Property
- ffsIndex ∷ Property
- ffsZero ∷ Property
- shiftMinBound ∷ Property
- rotateMinBound ∷ Property
- ffs6453 ∷ Property
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.
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.
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
.
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.
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
.
If we find a valid index for the first set bit, then:
- The specified index should have a set bit; and
- 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.
Finding the first set bit in a bytestring with only zero bytes should always give -1.