Skip to content

Ch6 add exercise tests #78

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

Merged
merged 1 commit into from
Apr 22, 2020
Merged

Conversation

milesfrain
Copy link
Member

Solutions here for reference.

No peaking at the solutions before you attempt the exercises!

Comment on lines +11 to +17
logShow $ hash 123
logShow (hash true)
logShow (hash [1, 2, 3])
logShow (hash "testing")
logShow (hash 'a')
logShow ("foo" `hashEqual` "foo")
logShow ("foo" `hashEqual` "bar")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These used to live in test/Main.purs, but relocating them here, since the original location seems best for exercise tests.

@@ -0,0 +1,49 @@
module Test.Solutions where
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying the file for solutions will enable easier comparison of solutions, similar to what's available in exercism.io

Comment on lines +5 to +9
newtype Complex
= Complex
{ real :: Number
, imaginary :: Number
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains code snippets directly from the chapter text for users to complete.

$ Assert.equal "1.0+2.0i"
$ show
$ Complex { real: 1.0, imaginary: 2.0 }
{- Move this block comment starting point to enable more tests
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readers can drag this line down to enable more tests as they tackle each exercise.

@oldfartdeveloper
Copy link

@milesfrain I'm starting my study of chapter 6. I've cloned and checked out your branch; will be testing over the next couple of days.

@milesfrain
Copy link
Member Author

I didn't add any testing instructions to the chapter text, but here's a quick summary of what to do:

Just skip the first "Show Shape" exercise. This makes more sense to run as part of chapter 5 where all the other related code lives.

When you get to the "Show instance for Complex" exercise in the second group, run spago test. It should fail because you haven't completed the exercise yet.

Open test/Solutions.purs and complete the exercise by creating a Show instance for Complex. Then run spago test again and it should pass. The test will be a bit strict about the specific format of how these complex numbers are printed, and you can look at test/Main.purs to figure out the format that will work.

Once that test passes, you can work on the next exercise, and move the block-comment starting point down a few lines in test/Main.purs to include the tests for the next exercise.

@milesfrain
Copy link
Member Author

I thought the repeatAction exercise might be tricky, so added a hint for that in #88.

@oldfartdeveloper
Copy link

oldfartdeveloper commented Apr 17, 2020 via email

@milesfrain
Copy link
Member Author

Now, your instructions above I believe are very helpful. Where are you going to introduce them in the book?

Going to add the more long-winded testing instructions posted in #79 to either chapter 1 or 2 (with examples targeted to those specific chapters). Those chapters also need a bit of rework as described in #93.

Also linking to this PR as a reminder to revisit test group numbering and testing exercises relating to previous chapters: milesfrain#1

@milesfrain milesfrain merged commit aac2e52 into purescript-contrib:master Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants