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

Tests fail for robot-simulator #29

Closed
jiegillet opened this issue Feb 18, 2022 · 6 comments · Fixed by exercism/elm#463
Closed

Tests fail for robot-simulator #29

jiegillet opened this issue Feb 18, 2022 · 6 comments · Fixed by exercism/elm#463

Comments

@jiegillet
Copy link
Contributor

I was trying to solve robot-simulator, but the tests keep failing like so

Screen Shot 2022-02-18 at 15 28 42

For the solution

turnRight : Robot -> Robot
turnRight robot = robot

turnLeft : Robot -> Robot
turnLeft robot = robot

advance : Robot -> Robot
advance robot = robot

simulate : String -> Robot -> Robot
simulate directions robot = robot

Or any code that compiles. When the code doesn't compile, the test runners shows the compiler errors like usual.

@mpizenberg
Copy link
Member

Alright so I've run locally the test runner on this and it appears the issue comes from the fact that the automatic extractor of test code does not work with this tests/Tests.elm file. When adding some additional logging in the tests runner and displaying the code extracted I get the following:

Extracted test code:
[]
End of extracted test code

@ceddlyburge Could you have a look at this. My intuition is that either the test file does not follow a structure that your extractor can extract, or there is a bug somewhere.

Thanks for the report @jiegillet !

@ceddlyburge
Copy link
Contributor

I'll take a look ...

@jiegillet
Copy link
Contributor Author

jiegillet commented Feb 18, 2022

I've also looked at things (and managed to run the tests in docker, yay!) and I think I've identified the issue. Your intuition was correct.

The tests for robot-simulator look like this:

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
             ]   
            ) 
        , ...

The test extractor cannot deal with the let statement describe "init" (let ... in [...]). I've confirmed that in a unit test.

Solution 1: patch the test extractor so that it copy pastes the let block inside each of the tests.
Solution 2: change the tests from robot-simulator .

I need to amend my initial comment:

Or any code that compiles.

Obviously the code I was trying to run had some errors, the example code passes all the tests, doesn't ask for the test snippets and all is fine.
This behavior is tricky to check in a CI, because you would need for each exercise a solution that compiles but fails some (all?) the tests. The Debug.todo fails in a different way.
Maybe one could run the test extractor on all the test files and check that the number of snippets is equal to the number of test " strings in the files, or something like that.

@jiegillet
Copy link
Contributor Author

Maybe one could run the test extractor on all the test files and check that the number of snippets is equal to the number of test " strings in the files, or something like that.

I threw a quick script together to do that locally, it seems that all other exercises are OK.

@ceddlyburge
Copy link
Contributor

I've created a new issue for the test runner to handle let expressions, and I think the quickest thing to fix the robot simulator now is to refactor them to avoid the let expression, so I'll do that ...

@mpizenberg
Copy link
Member

@ceddlyburge if you could also mention the test limitation in the guideline https://github.com/exercism/elm/blob/main/docs/contributing-concept.md would be awesome.

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

Successfully merging a pull request may close this issue.

3 participants