-
-
Notifications
You must be signed in to change notification settings - Fork 45
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 variable-length-quantity exercise #427
Conversation
I’ve never done this particular exercise so I’ll defer to @fapdash, but would hexadecimal literals be more appropriate here for the tests? |
OK, it looks like racket does not do this, they just use the integer tests. Python does use hex though.
As the instructions show examples in hex, it probably makes more sense to use hex. |
Example solution using hex.
|
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.
Besides the removal error stub I think we can merge like that.
The error message doesn't change if we change the code to use hex representation, it gets parsed to integer either way. The error message already displays the hex and the integer representation:
Test largest-triple-byte condition:
(ert-test-failed
((should
(equal
(encode ...)
'(255 255 122)))
:form
(equal
(255 255 127)
(255 255 122))
:value nil :explanation
(list-elt 2
(different-atoms
(127 "#x7f" "?\177")
(122 "#x7a" "?z")))))
@kmarker1101 I also never implemented this exercise before so I'd leave it up to you, if you think the student benefits from looking at the test code and seeing hex numbers then do the change, otherwise we keep the test code as it is right now.
|
||
|
||
(define-error 'incomplete | ||
(error "Delete this S-Expression and write your own 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.
If you want the students to provide a specific error message then you can test for it with the following pattern:
emacs-lisp/exercises/practice/affine-cipher/affine-cipher-test.el
Lines 59 to 65 in 8c5e45e
(ert-deftest encode-with-a-not-coprime-to-m () | |
(let ((error-data | |
(should-error | |
(encode "This is a test." '(("a" . 6) ("b" . 17)))))) | |
(should | |
(string= | |
"a and m must be coprime." (error-message-string error-data))))) |
But I don't think it's necessary to expect a specific error message. In the past we didn't define-error
in the stub file so just delete Line 8-9.
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 I will change to use hex, mainly because the instructions examples use hex. Thanks
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.
Testing for specific errors started in #400 where it made sense to distinguish between the two errors. We did the same on Racket for that exercise even though generally we avoid testing for specific errors there because students often raise a contract violation (more idiomatic) than an error.
Here, there’s only one error so yeah we don’t need that specificity.
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 kind of like testing for a specific error type, imo it's a good habit to get into to signal specific errors instead of the generic error type. My comment referred to testing for a specific error message.
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.
should be good now I think
@BNAndras should be ready |
exercises/practice/variable-length-quantity/variable-length-quantity-test.el
Show resolved
Hide resolved
If you take a look at those two literals, I'd appreciate it. Otherwise, it looks good to me. |
I went with a difficulty of 6. In Racket it is an 8 which seems a little high. It is a 4 in python.