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

:dumptests doesn't print one test case per line #1314

Closed
brianhuffman opened this issue Dec 11, 2021 · 6 comments
Closed

:dumptests doesn't print one test case per line #1314

brianhuffman opened this issue Dec 11, 2021 · 6 comments

Comments

@brianhuffman
Copy link
Contributor

The REPL documentation for :? :dumptests suggests that "each line" of the resulting file should contain the inputs and expected output for one random test. However, since version 2.12.0, values of larger types (arrays or records) are pretty-printed with lots of extra line breaks, so each test case covers many lines. For example:

Cryptol> :set tests=3
Cryptol> :dumptests foo.txt \(xs:[4][32]) -> xs == xs

This produces the following 12-line file:

True    [0x63ed9cea,
0xb442e53d,
0xda7f35e6,
0xa5221c2d]
True    [0x39b0818b,
0x1d79967e,
0xed26edc2,
0x2314627f]
True    [0x407dd58e,
0x3d12445c,
0x29f39490,
0xd4086e5d]
@brianhuffman
Copy link
Contributor Author

Bisection shows that PR #1263 is where the problem originates.

@brianhuffman
Copy link
Contributor Author

The problem is in the definition of the renderOneLine function in Utils/PP.hs:

renderOneLine :: Doc -> String
renderOneLine d = PP.renderString (PP.layoutCompact (runDoc mempty d))

The layoutCompact style in prettyprinter doesn't do single-line layouts; it just skips indentation. We'll need to implement this another way.

@robdockins
Copy link
Contributor

I think maybe we can implement this by writing a custom rendering function that never emits any newlines. It should be easier than changing the pretty printing library.

@brianhuffman
Copy link
Contributor Author

It would probably be worth asking the prettyprinter devs if there is a recommended way to do one-line layouts.

@kquick
Copy link
Member

kquick commented Feb 28, 2022

Potentially useful example: https://hackage.haskell.org/package/silkscreen-0.0.0.4

@RyanGlScott
Copy link
Contributor

Fixed in #1759.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants