-
-
Notifications
You must be signed in to change notification settings - Fork 46
Implemented all "Phone Number" problems from the canonical test data. (#465) #472
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
base: main
Are you sure you want to change the base?
Conversation
- Revised the following tests using the canonical test data. cleans-number-test cleans-numbers-with-dots-test valid-when-11-digits-and-first-is-1-test - Revised the following tests specific for "Phone Number" to conform the requirements for phone numbers. area-code-test pprint-test pprint-full-us-phone-number-test
…exercism#465) - The track-specific three problems are still included, but their solutions have been corrected.
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.
For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
|
||
(ert-deftest invalid-when-9-digits () | ||
(should (string= (cadr (should-error (numbers "123456789"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check for a particular error type rather than a specific message. The expected error messages in problem-specs repo tests get updated from time to time. If the updated message still makes sense with our error type, we don't need to update the test cases then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BNAndras Given that the canonical test data contains so many different kinds of errors with distinct error messages, I think that the creator of the problem tries to have students clearly distinguish all types of errors in phone numbers. If it is the case, it is not enough to let students signal a generic error. One way to force them to distinguish all types of errors is to require specific error messages, as I did. Alternatively, we could have students define various errors with pre-specified names in phone-number.el and check if the right one is used in the tests. Is this what you have in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have both type of tests / expected implementations in the track:
- Checking for error message:
emacs-lisp/exercises/practice/perfect-numbers/perfect-numbers-test.el
Lines 46 to 57 in 906e325
;;; Invalid Inputs (ert-deftest zero-is-rejected () (should (equal (should-error (classify 0)) '(error . ("Classification is only possible for natural numbers"))))) (ert-deftest negative-integer-is-rejected () (should (equal (should-error (classify -1)) '(error . ("Classification is only possible for natural numbers"))))) - Checking for error type:
emacs-lisp/exercises/practice/two-bucket/two-bucket-test.el
Lines 54 to 58 in 906e325
(ert-deftest not-possible-to-reach-the-goal () ;; Function under test: measure ;; Input: {"bucketOne":6,"bucketTwo":15,"goal":5,"startBucket":"one"} ;; Expected: {"error":"impossible"} (should-error (measure 6 15 5 'one) :type 'goal-not-possible))
I think both approaches are fine. It's way more common to signal a default error with a custom message in Emacs Lisp than it is to define a custom error type.
Stats from my Emacs configuration with 331 packages installed:
Defining custom error:
~/.emacs.d/elpa$ rg -q --stats define-error | head -n 2 | cut -d\ -f1
54
Signaling custom errors:
$ rg -q --stats "\(signal " | head -n 2 | cut -d\ -f1
253
Signaling default error:
~/.emacs.d/elpa$ rg -q --stats "\(error " | head -n 2 | cut -d\ -f1
2076
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fapdash Thank you veru much for the detailed information. I think that I will go with the custom error signaling approach for the reason I mentioned earlier.
config.json
Outdated
@@ -942,6 +929,14 @@ | |||
"practices": [], | |||
"prerequisites": [], | |||
"difficulty": 2 | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You moved the exercise to the end of the JSON array. This will place it at the bottom of the https://exercism.org/tracks/emacs-lisp/exercises/ page. Was this your intention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the generator use configlet --create? That defaults to a difficulty of 1 if not set and puts the exercise at the end of the practice exercise array. There shouldn't be any changes to the track config for what we want done.
config.json
Outdated
"uuid": "c211045e-da97-479d-9df4-5d812573e2d0", | ||
"practices": [], | ||
"prerequisites": [], | ||
"difficulty": 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you lower the difficulty of the exercise? Maybe the the difficulty with the new tests and requirements might be even higher than 2? You know this the best, since you implemented the new example implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fapdash I myself did not intentionally lower the difficulty. I followed your direction about creation of new tests, and then changed back the uuid per @BNAndras's suggestion. Anyway, I think that the difficulty of the revised problem is not much different from the original one, except that the revised one is now consistent with the problem setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the difficulty from 1 to 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the entry of "Phone Number" to the original position in ./config.json, because I am not sure what is the right order of the exercises.
The difficulty of "phone number" is reverted back to 2.
- The tests expecting errors now check custom errors instead of error messages. - The example test has been modified so that it passes the modified tests.
7460a49
to
4cdb174
Compare
I have revised the phone-number-test.el to include all problems from the canonical test data and correct the three track-specific problems.