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

Interplay of >>> and prop> #175

Open
sgraf812 opened this issue Nov 16, 2017 · 5 comments
Open

Interplay of >>> and prop> #175

sgraf812 opened this issue Nov 16, 2017 · 5 comments
Labels
info needed More information needed from issue reporter

Comments

@sgraf812
Copy link

Consider this:

-- |
-- >>> let x = 1
-- prop> x == 1
main = putStrLn "Hello World"

This complains that the output of let x = 1 didn't match prop> x == 1. If the prop> were a >>> instead, this would at least pass the first line (independent of #174, which would happen the line after).

@andreasabel andreasabel added the info needed More information needed from issue reporter label Jan 3, 2018
@andreasabel
Copy link
Collaborator

andreasabel commented Jan 3, 2018

Thanks for reporting. It is not entirely clear what feature you are requesting here. Could you elaborate more, e.g. on the expected behavior?

@sgraf812
Copy link
Author

sgraf812 commented Jan 6, 2018

The line after >>> is always parsed as expected output (as long as it doesn't start with >>>). So, currently the above doctest states that the assignment let x = 1 should output the string prop> x == 1, which of course it doesn't.

This is rather surprising behavior, I rather expected that the second line would declare an ordinary quickcheck property.

A workaround is to insert an empty line inbetween, as in #174.

@sol
Copy link
Owner

sol commented Jan 7, 2018

I think this is an extension of #174. As we currently don't share the scope between properties and examples, code like

-- >>> let x = 1
-- prop> x == 1

is not something you commonly want to write.

@sgraf812 can you check what haddock does here. If haddock parses this as an example and a property then we want to do the same in doctest.

@sgraf812
Copy link
Author

sgraf812 commented Jan 7, 2018

Judging from this function, haddock will most likely parse this as example + result. That makes no observable difference for haddock, I think, because results and properties are formatted the same. It does to doctest, though.

Maybe we should fix haddock first (e.g. add a property case to resultAndMoreExamples)? Also, wouldn't it make sense for doctest to depend on the haddock parser directly if we keep compatibility between the two anyway?

@amigalemming
Copy link

The problem might be solved by multi-line properties: #131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed More information needed from issue reporter
Projects
None yet
Development

No branches or pull requests

4 participants