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

Add tests for exercises #79

Open
milesfrain opened this issue Apr 13, 2020 · 9 comments
Open

Add tests for exercises #79

milesfrain opened this issue Apr 13, 2020 · 9 comments
Assignees

Comments

@milesfrain
Copy link
Member

milesfrain commented Apr 13, 2020

PRs for adding tests:

Open:

Complete:

Skipping:

Contributing:
We could use help with adding tests for the other chapters, so please feel free to assign yourself to any of the open PRs.

@oldfartdeveloper
Copy link

oldfartdeveloper commented Apr 14, 2020

@milesfrain, I would be honored to go through through your tests on chapter 6 in #78.

I'll also be glad to write some tests for the preceding chapters. And the subsequent ones as well.

I've always found tests to be one of the best ways to wrap your head around a problem. I agree with you that tests "would also be a great help in improving book quality for upcoming readers".

Thanks for thinking of me.

@milesfrain
Copy link
Member Author

@p2327 Also offered to help with test writing. Let's make sure we organize who's working on which chapters so we don't duplicate efforts.

@oldfartdeveloper
Copy link

@milesfrain @p2327 Sounds good. I'm currently attempting to verify your test suite at each increment of the exercises in Ch. 6.

@oldfartdeveloper
Copy link

@milesfrain I'd like to tackle generating test suite for Ch. 4.

@p2327
Copy link

p2327 commented Apr 25, 2020

@oldfartdeveloper I just started chapter 6 so happy for you to work on it instead if you are already started! I'll share my repo anyway be good to check my work with yours im quite a newbie :)

@milesfrain happy to take on other chapters as needed?

@oldfartdeveloper
Copy link

@p2327 Interestingly, I decided to pause my study of the book after finishing chapter 6 to divert to contribute tests for chapter 3 because I am so convinced that @milesfrain's efforts on adding the regression tests is such a great idea for readers like you and me.

@milesfrain has already completed implementing the tests for his solutions for chapter 6, and his they were invaluable in helping me to process the material in the chapter.

At this point in time, I'm ready to start studying chapter 7.

In terms of adding tests for solutions, chapters 3, 4, and 6 are complete.

So, would you like to take a stab at supplying the tests for your solutions for chapter 5? You've just finished studying the chapter, and so you're in a perfect position to cement your hard-won knowledge by adding the tests, and you have testing examples for 3 chapters now.

This would free me up to tackle studying chapter 7, and I would now proceed by doing "test-first" development for the examples. When I'm finished, there would be tests and solutions for chapter 7.

I have solutions for all but one of the chapter 5 examples that I'd be glad to share if you wanted to compare approaches; I've discovered that there are frequently many ways to solve them.

I'm a newbie also, for me acquiring Purescript is not easy at all. But writing tests has made it easier.

So I'd like it if you took on implementing the tests for chapter 5; you're in a perfect position to do so.. Concurrently I'll implement the tests for chapter 7 as I study it.

Sound like a plan?

@milesfrain
Copy link
Member Author

I updated the original post with links to tasks for adding tests for to each chapter.
I think the easiest workflow is to just post in that chapter's issue to claim it (instead of my previously suggested workflow of creating a new issue).

@othelarian
Copy link

I detected multiple issues with the tests of ch12:

  • edge case with the https://reqres.in if the user are behind a http-only proxy
  • On Windows, the countCharacters test ended with Right 42 instead of Right 41, due to "\r\n" git auto conversion
  • On Windows (again), the EOENT: no such file or directory error can go with absolute path in some case, but the assert check on relative path

Do I open a global issue for the three, or one for each?

For people with this issues, here some ways to work around:

  • For the edge case about proxy, install http-server globally (npm i -g http-server), launch with http-server -p 42524 in the test/data dir, and replace the url here (line 142) with http://localhost:42524/user.txt
  • for the Right 41, change 41 to 42
  • for EOENT error, two ideas:
    • reuse what you learn to use Path.resolve to switch to absolute path, and concatenate the path you expected, tricky, but rewarding and interesting as we're here to learn ;-)
    • when you run the test with the solution (ie without any modification of the test/Main.purs file), the failed tests will show the expected returns for each EOENT, copy-paste everywhere it's necessary

@milesfrain
Copy link
Member Author

Do I open a global issue for the three, or one for each?

Thanks for the report @othelarian. Up to you on whether you want to create just a single issue or multiple issues. You can also just jump straight to submitting a PR with a potential fix (even if there's more work to be done), and we can discuss it further in the PR comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants