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

Support let expressions in describe and test functions #30

Open
ceddlyburge opened this issue Feb 21, 2022 · 3 comments
Open

Support let expressions in describe and test functions #30

ceddlyburge opened this issue Feb 21, 2022 · 3 comments

Comments

@ceddlyburge
Copy link
Contributor

The test runner cannot currently handle a let expression used inside a describe or test function, like below and in #29

tests : Test
tests =
    describe "RobotSimulator"
        [ describe "init"
            (let
                robot =
                    defaultRobot
             in  
             [ test "coordinates" <|
                \() -> Expect.equal { x = 0, y = 0 } robot.coordinates
             , test "bearing" <|
                \() -> Expect.equal North robot.bearing
             ]   
            ) 
        , ...
@jiegillet
Copy link
Contributor

I wrote some code that can traverse complex code and grab tests along the way. It might be a bit too general for our use case, but it works. It's not pushed anywhere yet.

Along the way, it grabs all the describe descriptions and the test description. So at the end I have something like ["description 1", "description 2", "should work at night"] so I can build the final name.
We could use this to check for a specific description related to tasks, if we require a specific description format like "task 1".

Another idea is to create an alias function

task : Int -> String ->  List Test -> Test
task _ = describe

that I could also parse along the way, but that's a bit more convoluted.

Oh, I just remembered @mpizenberg has already implemented something like that on his fork.

Anyway, plenty of options, we should take this opportunity to extract the task ID and add a "task_id":1 field to the final json.

Thoughts?

@mpizenberg
Copy link
Member

mpizenberg commented Mar 2, 2022

Oh, the name of that repo might be confusing you @jiegillet sorry. This repo is not actually a fork of exercism/elm-test-runner. It's the Elm part (an elm package: https://package.elm-lang.org/packages/mpizenberg/elm-test-runner/latest/) of mpizenberg/elm-test-rs, my rust test runner, which already has the ability to report tasks when they are numbered. The only thing needed to bring it to exercism/elm-test-runner is to update in it the version of elm-test-rs. Is it clearer?

But all this is unrelated to the code here having an issue with let expressions.

@jiegillet
Copy link
Contributor

Oh, I see, yes, I got confused by the name. So getting the task number is just a matter of updating elm-test-rs. I guess that should be its own issue.

jiegillet added a commit to jiegillet/elm-test-runner that referenced this issue Apr 7, 2022
Solves exercism#30.
The code extractor can now:
- Find test/describe inside of a let declaration
- Find test/describe pretty much anywhere (if, record, tuple...)
- Handle more than one top-level `Test`
- Find tests in arbitrarily nested describe
- Write test name as "describe name 1 > describe name 2 > ... > test name"
ErikSchierboom pushed a commit that referenced this issue Apr 12, 2022
* Clean up elm.json dependencies.

Closes #34.

* Expand code parsing.

Solves #30.
The code extractor can now:
- Find test/describe inside of a let declaration
- Find test/describe pretty much anywhere (if, record, tuple...)
- Handle more than one top-level `Test`
- Find tests in arbitrarily nested describe
- Write test name as "describe name 1 > describe name 2 > ... > test name"

* Minimal changes to capture description hierarchy
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

3 participants