Skip to content

test pack #137

@thedavidmeister

Description

@thedavidmeister

Tighten the underflow test: make it pure and target the threshold precisely.

Mark the test pure (no state read/write).
Bound signedCoefficient to ≥1 to avoid discards.
Pin exponent to a value ≤ int32.min − 77 to deterministically exercise the lossy‑zero path.

Apply this diff:

  • function testPackNegativeExponentLossyZero(int256 signedCoefficient, int256 exponent) external view {
  •    exponent = bound(exponent, type(int256).min, int256(type(int32).min) - 77);
    
  •    vm.assume(signedCoefficient != 0);
    
  • function testPackNegativeExponentLossyZero(int256 signedCoefficient, int256 exponent) external pure {
  •    signedCoefficient = bound(signedCoefficient, 1, type(int256).max);
    
  •    exponent = bound(exponent, int256(type(int32).min) - 77, int256(type(int32).min) - 77);
       (Float float, bool lossless) = this.packLossyExternal(signedCoefficient, exponent);
       assertFalse(lossless, "lossless");
       assertEq(Float.unwrap(float), Float.unwrap(LibDecimalFloat.FLOAT_ZERO), "float");
    
    }

Consider adding a sibling test for the “within 1..76” underflow window to assert non‑zero, lossy pack clamped at int32.min.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions