Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hedgehog builtins generators have horrible coverage #5833

Closed
effectfully opened this issue Mar 13, 2024 · 1 comment
Closed

hedgehog builtins generators have horrible coverage #5833

effectfully opened this issue Mar 13, 2024 · 1 comment
Labels
Internal Low priority Doesn't require immediate attention status: triaged Test

Comments

@effectfully
Copy link
Contributor

PlutusCore.Generators.Hedgehog.AST defines

genSomeTypeIn :: AstGen (SomeTypeIn DefaultUni)
genSomeTypeIn = Gen.frequency
    [ (1, pure $ SomeTypeIn DefaultUniInteger)
    , (1, pure $ SomeTypeIn DefaultUniByteString)
    , (1, pure $ SomeTypeIn DefaultUniString)
    , (1, pure $ SomeTypeIn DefaultUniUnit)
    , (1, pure $ SomeTypeIn DefaultUniBool)
    ]

plutus-core/test/Main.hs defines

genConstantForTest :: AstGen (Some (ValueOf DefaultUni))
genConstantForTest =
  Gen.frequency
    [ (3, someValue <$> pure ())
    , (3, someValue <$> Gen.bool)
    , -- Smallish Integers
      (5, someValue <$> Gen.integral (Range.linear (-k1) k1))
    , -- Big Integers, generally not Ints
      (5, someValue <$> Gen.integral (Range.linear (-k2) k2))
    , -- eg "\SOc_\t\GS'v\DC4FP@-pN`\na\SI\r"
      (10, someValue <$> Gen.text (Range.linear 0 100) Gen.ascii)
    , -- eg "\246'X\b<\195]\171Y"
      (3, someValue <$> Gen.text (Range.linear 0 100) Gen.latin1)
    , -- eg "\243\190\180\141"
      (3, someValue <$> Gen.utf8 (Range.linear 0 100) Gen.unicode)
    , -- eg "\1108177\609033\384623"
      (3, someValue <$> Gen.text (Range.linear 0 100) Gen.unicode)
    , -- Bytestring
      (10, someValue <$> Gen.bytes (Range.linear 0 100))
    ]
  where
    k1 = 1000000 :: Integer
    k2 = m * m
    m = fromIntegral (maxBound :: Int) :: Integer

All of those should handle more built-in types.

Ideally though, we should simply replace hedgehog with QuickCheck there wherever possible since we already have high-quality generators for QuickCheck and the latter is better anyway.

@github-actions github-actions bot added the status: needs triage GH issues that requires triage label Mar 13, 2024
@effectfully effectfully added Low priority Doesn't require immediate attention and removed status: needs triage GH issues that requires triage labels Mar 13, 2024
@effectfully
Copy link
Contributor Author

Was fixed by #6315.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Low priority Doesn't require immediate attention status: triaged Test
Projects
None yet
Development

No branches or pull requests

1 participant