Run fusion property test with arbitrary layouters#96
Run fusion property test with arbitrary layouters#96sjakobi merged 8 commits intohaskell-prettyprinter:masterfrom
Conversation
prettyprinter/test/Testsuite/Main.hs
Outdated
| instance Arbitrary LayoutOptions where | ||
| arbitrary = LayoutOptions <$> oneof | ||
| [ AvailablePerLine <$> arbitrary <*> arbitrary | ||
| -- , pure Unbounded -- https://github.com/quchen/prettyprinter/issues/91 |
There was a problem hiding this comment.
If I uncomment this, the fusion tests trigger #91:
Shallow fusion does not change rendering: FAIL (0.02s)
*** Failed! (after 56 tests):
Exception:
»SFail« must not appear in a rendered »SimpleDocStream«. This is a bug in the layout algorithm! Please report this as a bug
CallStack (from HasCallStack):
error, called at src/Data/Text/Prettyprint/Doc/Render/Util/Panic.hs:13:21 in prettyprinter-1.5.1-inplace:Data.Text.Prettyprint.Doc.Render.Util.Panic
oakland <(commence inverse)>buttonaccrue tapewormtrackercrowfoot
spheroid ( printer ` ""sailboatbackfieldendorse transit gazelletacticsdrumbeat dogsled dropper puppy dashboard
skydive miser eyeglass apple guidancetonic
oakland southward )
woodlark
minnow
slowdown
<function>
LayoutOptions {layoutPageWidth = Unbounded}
Exception thrown while showing test case:
»SFail« must not appear in a rendered »SimpleDocStream«. This is a bug in the layout algorithm! Please report this as a bug
CallStack (from HasCallStack):
error, called at src/Data/Text/Prettyprint/Doc/Render/Util/Panic.hs:13:21 in prettyprinter-1.5.1-inplace:Data.Text.Prettyprint.Doc.Render.Util.Panic
Use --quickcheck-replay=857723 to reproduce.
Two things could IMHO help analyzing these failures:
-
Shrinking: I wonder whether it might be easiest to just use
hedgehoginstead ofQuickCheck, since that has built-in shrinking. What do you think about this @quchen? -
A diagnostic representation of the
Doc(A diagnostic representation for "Doc" #90).
There was a problem hiding this comment.
The arabitrary should be explicit ranges, otherwise you get ribbons of 1e-5 and 2 for example.
There was a problem hiding this comment.
The
arabitraryshould be explicitranges, otherwise you get ribbons of 1e-5 and 2 for example.
Why would that be a problem? I don't really understand the ribbon width logic so far, but I know that layoutWadlerLeijen clamps the result to a valid range:
I usually try to not to constrain the generated values unless they cause problems – "nonsense" inputs are often helpful at finding bugs in edge cases.
|
I haven’t used Hedgehog and I’m fairly familiar with Quickcheck, but certainly not opposed to using new technology in order to improve tests. Automatic shrinking does sound cool, I should read up on that! |
92dd87b to
4cd68f6
Compare
|
I'd like to build on this in my PRs, so I'll merge soon. Further improvements will hopefully happen as I use these tests. Regarding shrinking: |
Context: #95