-
-
Notifications
You must be signed in to change notification settings - Fork 556
simple-cipher: Add canonical-data.json #1241
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
ErikSchierboom
merged 5 commits into
exercism:master
from
gustavosobral:canonical-data/simple-cipher
Jun 4, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6158197
Add simple-cipher canonical-data
gustavosobral 289dab2
Fix schema validation adding missing properties
gustavosobral 92cc456
Review
gustavosobral 80d76a2
Add comments to the exercise definition
gustavosobral 9cb43e5
Grammar comment fix
gustavosobral File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"exercise": "simple-cipher", | ||
"version": "1.0.0", | ||
"comments": | ||
["Some of the strings used in this file are symbolic and do not represent their literal value. They are:", | ||
"cipher.key - Represents the Cipher key", | ||
"cipher.encode - Represents the output of the Cipher encode method", | ||
"new - Represents the Cipher initialization"], | ||
"cases": [ | ||
{ | ||
"description": "Random key cipher", | ||
"cases": [ | ||
{ | ||
"description": "Can encode", | ||
"property": "encode", | ||
"input": { | ||
"plaintext": "aaaaaaaaaa" | ||
}, | ||
"expected": "cipher.key" | ||
}, | ||
{ | ||
"description": "Can decode", | ||
"property": "decode", | ||
"input": { | ||
"ciphertext": "cipher.key" | ||
}, | ||
"expected": "aaaaaaaaaa" | ||
}, | ||
{ | ||
"description": "Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method", | ||
"property": "decode", | ||
"input": { | ||
"plaintext": "abcdefghij", | ||
"ciphertext": "cipher.encode" | ||
}, | ||
"expected": "abcdefghij" | ||
}, | ||
{ | ||
"description": "Key is made only of lowercase letters", | ||
"property": "key", | ||
"input": {}, | ||
"expected": { | ||
"match": "^[a-z]+$" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Substitution cipher", | ||
"cases": [ | ||
{ | ||
"description": "Can encode", | ||
"property": "encode", | ||
"input": { | ||
"key": "abcdefghij", | ||
"plaintext": "aaaaaaaaaa" | ||
}, | ||
"expected": "abcdefghij" | ||
}, | ||
{ | ||
"description": "Can decode", | ||
"property": "decode", | ||
"input": { | ||
"key": "abcdefghij", | ||
"ciphertext": "abcdefghij" | ||
}, | ||
"expected": "aaaaaaaaaa" | ||
}, | ||
{ | ||
"description": "Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method", | ||
"property": "decode", | ||
"input": { | ||
"key": "abcdefghij", | ||
"plaintext": "abcdefghij", | ||
"ciphertext": "cipher.encode" | ||
}, | ||
"expected": "abcdefghij" | ||
}, | ||
{ | ||
"description": "Can double shift encode", | ||
"property": "encode", | ||
"input": { | ||
"key": "iamapandabear", | ||
"plaintext": "iamapandabear" | ||
}, | ||
"expected": "qayaeaagaciai" | ||
}, | ||
{ | ||
"description": "Can wrap on encode", | ||
"property": "encode", | ||
"input": { | ||
"key": "abcdefghij", | ||
"plaintext": "zzzzzzzzzz" | ||
}, | ||
"expected": "zabcdefghi" | ||
}, | ||
{ | ||
"description": "Can wrap on decode", | ||
"property": "decode", | ||
"input": { | ||
"key": "abcdefghij", | ||
"ciphertext": "zabcdefghi" | ||
}, | ||
"expected": "zzzzzzzzzz" | ||
}, | ||
{ | ||
"description": "Can handle messages longer than the key", | ||
"property": "encode", | ||
"input": { | ||
"key": "abc", | ||
"plaintext": "iamapandabear" | ||
}, | ||
"expected": "iboaqcnecbfcr" | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Incorrect key cipher", | ||
"cases": [ | ||
{ | ||
"description": "Throws an error with an all uppercase key", | ||
"property": "new", | ||
"input": { | ||
"key": "ABCDEF" | ||
}, | ||
"expected": { "error": "Bad key" } | ||
}, | ||
{ | ||
"description": "Throws an error with a numeric key", | ||
"property": "new", | ||
"input": { | ||
"key": "12345" | ||
}, | ||
"expected": { "error": "Bad key" } | ||
}, | ||
{ | ||
"description": "Throws an error with empty key", | ||
"property": "new", | ||
"input": { | ||
"key": "" | ||
}, | ||
"expected": { "error": "Bad key" } | ||
} | ||
] | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is interesting because we are to understand that this is not the literal string
"cipher.key"
but instead the key of the cipher, whatever that may be.This therefore falls under one of the categories of #1225 .
This suggests some possible courses of action:
expected
of everyencode
input.ciphertext
of everydecode
cipher.
are symbolic instead of literal strings.I will not yet express an preference ordering between these options
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.
As a sort of combination of the above, what about the following:
Where
{symbol}
is to be interpolated with local variables before matching is applied.On the surface, this approach seems to simply add complication to the current syntax. However, if this is to act as a precedent for future situations, the interpolation approach allows multiple variable values to be used.
Examples of such use:
"^{name.first} {name.last}$"
"^{a + b / c}$"
However, if my fellow maintainers think this is too complicated, my vote would be option 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.
This one is very specific to the canonical-data specification/syntax. I believe you guys know way more than me about where we are and where we should go. I'm completely open to suggestions.