-
Notifications
You must be signed in to change notification settings - Fork 14
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
Don't generate broken code #35
Comments
hmmm. do you have a specific example? It's not possible to find out everything during generation, because this is not a complete elm parser. But it might be possible to make some cases better. |
For example running on a file where parsing seems to fail (not sure why in my case) or an empty file, I get this output:
which is not valid elm. |
@gampleman I fixed an issue with modules that don't have any tests. would you mind testing with v1.0.2.? |
That is slightly better, although I think it would make sense for elm-verify-examples to report an error if a file doesn't have any examples, rather than leaving this to elm-test to complain about. (I also have to figure out what's going wrong with my file which has plenty of examples, but it seems that it manages to confuse the parser somehow). |
Can you share any code example? Did you add the file in your |
This seems to not generate any examples: module Visualization.Scale exposing (nice)
{-| Returns a new scale which extends the domain so that it lands on round values.
The second argument is the same as you would pass to ticks.
scale : ContinuousScale
scale = linear ( 0.5, 99 ) ( 50, 100 )
domain (nice scale 10) --> (0, 100)
-}
nice : Int -> Int
nice a =
a + 1 edit: as in it generates: module Doc.Visualization.ScaleSpec exposing (spec)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Visualization.Scale exposing(..)
spec : Test.Test
spec =
Test.describe "Visualization.Scale" <|
[
] |
The issue is that you need a newline in between the helper-function and the example. I'm looking in how to make that work. |
From the docs.
It's a known "issue" atm. Sorry for the inconvenience. |
That doesn't seem to make a difference for me. |
💭 hmmm... {-| Returns a new scale which extends the domain so that it lands on round values.
The second argument is the same as you would pass to ticks.
scale : ContinuousScale
scale = linear ( 0.5, 99 ) ( 50, 100 )
domain (nice scale 10) --> (0, 100)
-}
nice : Int -> Int
nice a =
a + 1 |
hmm that's pretty strange. This is what my tests/elm-verify-examples.json looks like: {
"root": "../src",
"tests" : [
"Visualization.List",
"Visualization.Path",
"Visualization.Scale"
]
} |
@gampleman sorry totally drop the ball here. is this still an issue for you? |
I've encountered it again, but I suspect this might be fixed with just better error reporting, since it tends to be in large files with a lot of stuff going on. So I think if we had better parse failure messages, this would be more straightforward to diagnose. |
Currently, if you mess up one of the formatting rules for the examples (i.e. miss a type signature for a definition), this tool will generate invalid test code, that only actually running the tests will reveal. However than one is left with the somewhat unpleasant experience of debugging generated code. Ideally this tool would actually error out in the generation phase if the code is invalid.
The text was updated successfully, but these errors were encountered: