Skip to content

Commit

Permalink
Add uuid field to all test cases (exercism#1676)
Browse files Browse the repository at this point in the history
* Add uuid field to documentation

* Update canonical schema

* Add uuid field to test cases

* Update canonical-schema.json

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

* Update comments in README

* Remove version check

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
  • Loading branch information
ErikSchierboom and SaschaMann committed Oct 1, 2020
1 parent 3f1d2a2 commit cea02af
Show file tree
Hide file tree
Showing 119 changed files with 1,710 additions and 70 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ cache: yarn

script:
- bin/check_required_files_present
- sh bin/check_versions
- bin/check_optional
- yarn test
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ is easier to understand with an example:
]
, "cases":
[ { "comments":
[ " A test case must have a 'description' and a 'property'. "
, " Anything else is optional. "
[ " A test case must have 'uuid', 'description', 'property', "
, " 'input' and 'expected' properties. The rest is optional. "
, " "
, " The 'property' is a string in lowerCamelCase identifying "
, " the type of test, but most of the times it is just the "
Expand All @@ -64,14 +64,16 @@ is easier to understand with an example:
, " most of them also have an 'expected' one, defining the "
, " value a test should return. "
]
, "uuid" : "31e9db74-86b9-4b14-a320-9ea910337289"
, "description": "Foo'ing a word returns it reversed"
, "property" : "foo"
, "input" : {
"word" : "lion"
}
, "expected" : "noil"
}
, { "description": "Bar'ing a name returns its parts combined"
, { "uuid" : "09113ce5-b008-45d0-98af-c0378b64966b"
, "description": "Bar'ing a name returns its parts combined"
, "property" : "bar"
, "input" : {
"firstName" : "Alan",
Expand All @@ -85,14 +87,16 @@ is easier to understand with an example:
]
, "description": "Abnormal inputs: numbers"
, "cases":
[ { "description": "Foo'ing a number returns nothing"
[ { "uuid" : "f22d7a03-e752-4f14-9231-4eae9f128cef"
, "description": "Foo'ing a number returns nothing"
, "property" : "foo"
, "input" : {
"word" : "42"
}
, "expected" : null
}
, { "description": "Foo'ing a very big number returns nothing"
, { "uuid" : "8790a635-e8a8-4343-a29f-7da2929b9378"
, "description": "Foo'ing a very big number returns nothing"
, "optional" : "big-ints"
, "comments" : [ "Making this test case pass requires using BigInts." ]
, "property" : "foo"
Expand All @@ -101,7 +105,8 @@ is easier to understand with an example:
}
, "expected" : null
}
, { "description": "Bar'ing a name with numbers gives an error"
, { "uuid" : "c7b6f24a-553f-475a-8a40-dba854fe1bff"
, "description": "Bar'ing a name with numbers gives an error"
, "property" : "bar"
, "input" : {
"firstName" : "HAL",
Expand All @@ -128,6 +133,7 @@ There are also some conventions that must be followed:
- The string should explain why the error would occur.
- A particular track's implementation of the exercise **need not** necessarily check that the error includes that exact string as the cause, depending on what is idiomatic in the language (it may not be idiomatic to check strings for error messages).
- Test cases that only some tracks should implement, for example because it would unnecessarily increase the complexity of the exercise in some but not all languages, mark it with an `optional`-key. Multiple cases related to the same reason for optionality should have the same key. The decision that a test case is optional will often be made in the PR discussion, so don't worry about it too much while creating a PR.
- Each test case must have a unique UUID specified in its `"uuid"` key. A UUID can be randomly generated using the [UUID Generator](https://www.uuidgenerator.net/version4).

The `canonical.json` file can be validated against its schema prior to commiting using https://www.jsonschemavalidator.net/ with...
```
Expand Down
32 changes: 0 additions & 32 deletions bin/check_versions

This file was deleted.

11 changes: 9 additions & 2 deletions canonical-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@
"labeledTest":
{ "description": "A single test with a description"
, "type" : "object"
, "required" : ["description", "property", "input", "expected"]
, "required" : ["uuid", "description", "property", "input", "expected"]
, "properties" :
{ "description": { "$ref": "#/definitions/description" }
{ "uuid" : { "$ref": "#/definitions/uuid" }
, "description": { "$ref": "#/definitions/description" }
, "optional" : { "$ref": "#/definitions/optional" }
, "comments" : { "$ref": "#/definitions/comments" }
, "property" : { "$ref": "#/definitions/property" }
Expand Down Expand Up @@ -113,6 +114,12 @@
, "type" : "string"
},

"uuid":
{ "description": "A universally unique identifier in the v4 format"
, "type" : "string"
, "pattern" : "^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$"
},

"optional":
{ "description": "An identifier for similar optional test cases (kebab-case)"
, "type" : "string"
Expand Down
9 changes: 9 additions & 0 deletions exercises/acronym/canonical-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"description": "Abbreviate a phrase",
"cases": [
{
"uuid": "1e22cceb-c5e4-4562-9afe-aef07ad1eaf4",
"description": "basic",
"property": "abbreviate",
"input": {
Expand All @@ -14,6 +15,7 @@
"expected": "PNG"
},
{
"uuid": "79ae3889-a5c0-4b01-baf0-232d31180c08",
"description": "lowercase words",
"property": "abbreviate",
"input": {
Expand All @@ -22,6 +24,7 @@
"expected": "ROR"
},
{
"uuid": "ec7000a7-3931-4a17-890e-33ca2073a548",
"description": "punctuation",
"property": "abbreviate",
"input": {
Expand All @@ -30,6 +33,7 @@
"expected": "FIFO"
},
{
"uuid": "32dd261c-0c92-469a-9c5c-b192e94a63b0",
"description": "all caps word",
"property": "abbreviate",
"input": {
Expand All @@ -38,6 +42,7 @@
"expected": "GIMP"
},
{
"uuid": "ae2ac9fa-a606-4d05-8244-3bcc4659c1d4",
"description": "punctuation without whitespace",
"property": "abbreviate",
"input": {
Expand All @@ -46,6 +51,7 @@
"expected": "CMOS"
},
{
"uuid": "0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9",
"description": "very long abbreviation",
"property": "abbreviate",
"input": {
Expand All @@ -54,6 +60,7 @@
"expected": "ROTFLSHTMDCOALM"
},
{
"uuid": "6a078f49-c68d-4b7b-89af-33a1a98c28cc",
"description": "consecutive delimiters",
"property": "abbreviate",
"input": {
Expand All @@ -62,6 +69,7 @@
"expected": "SIMUFTA"
},
{
"uuid": "5118b4b1-4572-434c-8d57-5b762e57973e",
"description": "apostrophes",
"property": "abbreviate",
"input": {
Expand All @@ -70,6 +78,7 @@
"expected": "HC"
},
{
"uuid": "adc12eab-ec2d-414f-b48c-66a4fc06cdef",
"description": "underscore emphasis",
"property": "abbreviate",
"input": {
Expand Down
16 changes: 16 additions & 0 deletions exercises/affine-cipher/canonical-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"comments": [ "Test encoding from English to ciphertext with keys" ],
"cases": [
{
"uuid": "2ee1d9af-1c43-416c-b41b-cefd7d4d2b2a",
"description": "encode yes",
"property": "encode",
"input": {
Expand All @@ -24,6 +25,7 @@
"expected": "xbt"
},
{
"uuid": "785bade9-e98b-4d4f-a5b0-087ba3d7de4b",
"description": "encode no",
"property": "encode",
"input": {
Expand All @@ -36,6 +38,7 @@
"expected": "fu"
},
{
"uuid": "2854851c-48fb-40d8-9bf6-8f192ed25054",
"description": "encode OMG",
"property": "encode",
"input": {
Expand All @@ -48,6 +51,7 @@
"expected": "lvz"
},
{
"uuid": "bc0c1244-b544-49dd-9777-13a770be1bad",
"description": "encode O M G",
"property": "encode",
"input": {
Expand All @@ -60,6 +64,7 @@
"expected": "hjp"
},
{
"uuid": "381a1a20-b74a-46ce-9277-3778625c9e27",
"description": "encode mindblowingly",
"property": "encode",
"input": {
Expand All @@ -72,6 +77,7 @@
"expected": "rzcwa gnxzc dgt"
},
{
"uuid": "6686f4e2-753b-47d4-9715-876fdc59029d",
"description": "encode numbers",
"property": "encode",
"input": {
Expand All @@ -84,6 +90,7 @@
"expected": "jqgjc rw123 jqgjc rw"
},
{
"uuid": "ae23d5bd-30a8-44b6-afbe-23c8c0c7faa3",
"description": "encode deep thought",
"property": "encode",
"input": {
Expand All @@ -96,6 +103,7 @@
"expected": "iynia fdqfb ifje"
},
{
"uuid": "c93a8a4d-426c-42ef-9610-76ded6f7ef57",
"description": "encode all the letters",
"property": "encode",
"input": {
Expand All @@ -108,6 +116,7 @@
"expected": "swxtj npvyk lruol iejdc blaxk swxmh qzglf"
},
{
"uuid": "0673638a-4375-40bd-871c-fb6a2c28effb",
"description": "encode with a not coprime to m",
"property": "encode",
"input": {
Expand All @@ -126,6 +135,7 @@
"comments": [ "Test decoding from ciphertext to English with keys" ],
"cases": [
{
"uuid": "3f0ac7e2-ec0e-4a79-949e-95e414953438",
"description": "decode exercism",
"property": "decode",
"input": {
Expand All @@ -138,6 +148,7 @@
"expected": "exercism"
},
{
"uuid": "241ee64d-5a47-4092-a5d7-7939d259e077",
"description": "decode a sentence",
"property": "decode",
"input": {
Expand All @@ -150,6 +161,7 @@
"expected": "anobstacleisoftenasteppingstone"
},
{
"uuid": "33fb16a1-765a-496f-907f-12e644837f5e",
"description": "decode numbers",
"property": "decode",
"input": {
Expand All @@ -162,6 +174,7 @@
"expected": "testing123testing"
},
{
"uuid": "20bc9dce-c5ec-4db6-a3f1-845c776bcbf7",
"description": "decode all the letters",
"property": "decode",
"input": {
Expand All @@ -174,6 +187,7 @@
"expected": "thequickbrownfoxjumpsoverthelazydog"
},
{
"uuid": "623e78c0-922d-49c5-8702-227a3e8eaf81",
"description": "decode with no spaces in input",
"property": "decode",
"input": {
Expand All @@ -186,6 +200,7 @@
"expected": "thequickbrownfoxjumpsoverthelazydog"
},
{
"uuid": "58fd5c2a-1fd9-4563-a80a-71cff200f26f",
"description": "decode with too many spaces",
"property": "decode",
"input": {
Expand All @@ -198,6 +213,7 @@
"expected": "jollygreengiant"
},
{
"uuid": "b004626f-c186-4af9-a3f4-58f74cdb86d5",
"description": "decode with a not coprime to m",
"property": "decode",
"input": {
Expand Down

0 comments on commit cea02af

Please sign in to comment.