-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
simple-cipher: Add canonical data #966
Conversation
@aos build failed due to:
|
Link to problem description: https://github.com/exercism/problem-specifications/blob/master/exercises/simple-cipher/description.md |
Hi @aos have you had a chance to look into why the json file is not valid? |
Hey @Insti. I looked at it briefly but couldn't understand. Sorry I have been very busy with work. I will look at it more tonight when I get a chance! |
Try pasting the json into a schema checker for some clues: https://jsonschemalint.com/#/version/draft-04/markup/json?gist=ba6a1e74397ade6bdbff65a9df0d9d3f |
Oh... that's handy. I'll look through it in a bit. Thank you! |
@aos Did you find any time to look at the problem? Do you perhaps need any help? |
@ErikSchierboom @Insti Hey finally got around to it. The latest commit fixes the schema validation issue. Let me know what still needs work -- I'll eventually squash these into a single commit |
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 see all of input
, input_plaintext
, input_string
, input_encode
, input_all_caps_string
, input_all_numbers_string
, and possibly others in the cases. I also see output_key
, matches_regex
, output_string
, output_decode
, and output_error
; there are again possibly others that I've missed.
I haven't gone through to check that all items with the same property
have the same inputs and outputs; if they do, that's technically not wrong. Still, it's both better aesthetics and easier to automatically generate tests with if every test case has the same schema:
{
"property": "Some string",
"description": "Text describing what this case is checking",
"input": "any literal",
"expected": {
"value": "success value (any type)"
// or "error": "error type"
// or "matches_regex": "regex"
}
}
In the above example, you can assign whatever attributes you like to the expected
object, as is appropriate for the test case; as long as every test of the same property has the same object attributes, things work out well. Likewise, you can set the input
to whatever you like, as long as the types are consistent within a given property. The key is consistency.
cf. the Readme:
|
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 added some remarks. Don't be daunted, most of it is relatively simple and involves being consistent with other exercises. It might help to look at some other exercises like https://github.com/exercism/problem-specifications/blob/master/exercises/atbash-cipher/canonical-data.json.
Thanks a lot for working on this!
"cases": [ | ||
{ | ||
"description": "Random key cipher", | ||
"property": "random", |
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'm not sure, but I don't think this line actually does anything. The property
key is normally used for specifying which method/property to test. As this is just a container for individual cases, I think it can be removed.
}, | ||
{ | ||
"description": "Incorrect key cipher", | ||
"property": "incorrect", |
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'm not sure, but I don't think this line actually does anything. The property
key is normally used for specifying which method/property to test. As this is just a container for individual cases, I think it can be removed.
}, | ||
{ | ||
"description": "Substitution cipher", | ||
"property": "substitution", |
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'm not sure, but I don't think this line actually does anything. The property
key is normally used for specifying which method/property to test. As this is just a container for individual cases, I think it can be removed.
"description": "It has a key made of letters", | ||
"property": "key", | ||
"input": "any", | ||
"matches_regex": "^[a-z]+$" |
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 are in the process of enforcing lowerCamelCase
keys (see #987), so I would suggest to rename the keys (not only this one) to lowerCamelCase
.
"property": "random", | ||
"cases": [ | ||
{ | ||
"description": "It has a key made of letters", |
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.
Maybe shorten to "Key has only lower-case letters"?
}, | ||
{ | ||
"description": "Substitution cipher", | ||
"property": "substitution", |
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 this be encode
?
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.
Possibly it should be substitution_encode
or substitutionEncode
, if there are other encoding methods with different types of inputs and outputs.
{ | ||
"description": "It throws an error with a numeric key", | ||
"property": "Cipher Key", | ||
"input_all_number_string": "'12345'", |
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.
Rename to input
}, | ||
{ | ||
"description": "It throws an error with a numeric key", | ||
"property": "Cipher Key", |
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 the property should be key
"cases": [ | ||
{ | ||
"description": "It throws an error with an all caps key", | ||
"property": "Cipher Key", |
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 the property should be key
"property": "incorrect", | ||
"cases": [ | ||
{ | ||
"description": "It throws an error with an all caps key", |
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.
Maybe this test should be about testing a string with a single uppercase character, as that is the minimal counter-example.
Are you still working on this @aos ? Do you need any help? |
Hi everyone. My apologies -- I've been very busy at work and have not had the time to work on this. If someone else would like to takeover, I'm more than happy to pass it on. Otherwise, I'll try to make progress on it as I collect some free time. |
@aos That's no problem; take the time you need to. There's no deadline! |
@aos Just a small bump. Are you still interested in working on this? I totally understand if work has prevented you to work on this, but this is just a small, friendly reminder :) |
What should we do with this PR? It has been 29 days since my reminder, and unfortunately there has been no reply. Is someone else perhaps willing to continue working on this PR? |
Would this PR simply be closed and a new one opened? Would it matter if one decided to start over from scratch? I am not putting my hat in the ring at this point, but I have spent about 90 minutes playing around with the JSON and looking at the recommended changes and finding it difficult to make sense of this JSON and have pass linting after making the prescribed changes. |
That may be the best option indeed. |
I'm gonna go ahead and close this PR. If someone wants to continue working on it, that would be great! But please open another PR. |
Closes #586
Hello. I've been working on this one. There are a few places where I wasn't sure what to do, specifically L27, and others where you have to do multiple encode into decodes. Or when adding a new cipher key. Let me know what you think!