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

Could we have multiline expectations? #419

Open
philderbeast opened this issue Feb 15, 2024 · 3 comments
Open

Could we have multiline expectations? #419

philderbeast opened this issue Feb 15, 2024 · 3 comments

Comments

@philderbeast
Copy link

Could we have multiline expectations (when GHC gets multiline strings ghc-proposals/ghc-proposals#569)?

-- >>> render . docProjectConfigPath $ ProjectConfigPath $ "D.config" :| ["C.config", "B.config", "A.project" ]
-- "D.config\n  imported by: C.config\n  imported by: B.config\n  imported by: A.project"

This would then become something like;

-- >>> render . docProjectConfigPath $ ProjectConfigPath $ "D.config" :| ["C.config", "B.config", "A.project" ]
-- """
-- D.config
--  imported by: C.config
--  imported by: B.config
--  imported by: A.project
-- """

The snippet is taken from haskell/cabal#9578.

@sol
Copy link
Owner

sol commented May 21, 2024

@philderbeast with GHC 9.10.1 out, can this output be produced by GHCi? If yes, then I think it should already work, if no then it may be out-of-scope for doctest. doctest is a tool to verify that example GHCi sessions work. It's a documentation tool, not primarily a testing tool. Hspec is a better option for testing.

@sol
Copy link
Owner

sol commented Nov 9, 2024

Reconsidering this, what we may do is:

  1. Compare actual and expected verbatim
  2. If verbatim comparison fails, then try to parse actual and expected into a Haskell AST. If parsing for both succeeds, then compare the ASTs.

This would then also enable things like:

>>> [1..3]
[1, 2, 3]
-- instead of [1,2,3]

or

>>> person
Person {
  name = "Joe"
, age = 23
}
-- instead of Person {name = "Joe", age = 23}

@philderbeast
Copy link
Author

with GHC 9.10.1 out, can this output be produced by GHCi?

It looks like we'd need at least GHC 9.12.1 for multiline strings.

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

2 participants