Skip to content

Commit

Permalink
Remove JSON from template, format roc code and config.json, use | to_…
Browse files Browse the repository at this point in the history
…roc, replace -32 with - 'a' + 'A'
  • Loading branch information
ageron committed Aug 27, 2024
1 parent c566050 commit 5f9f276
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 93 deletions.
12 changes: 9 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
"highlightjs_language": "haskell"
},
"files": {
"solution": ["%{pascal_slug}.roc"],
"test": ["%{kebab_slug}-test.roc"],
"example": [".meta/Example.roc"]
"solution": [
"%{pascal_slug}.roc"
],
"test": [
"%{kebab_slug}-test.roc"
],
"example": [
".meta/Example.roc"
]
},
"exercises": {
"practice": [
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ isLetter = \byte ->
capitalize : U8 -> U8
capitalize = \byte ->
if 'a' <= byte && byte <= 'z' then
byte - 32
byte - 'a' + 'A'
else
byte
90 changes: 1 addition & 89 deletions exercises/practice/acronym/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,7 @@ import {{ exercise | to_pascal }} exposing [abbreviate]
{% for case in cases -%}
# {{ case["description"] }}
expect
result = {{ case["property"] | to_camel }} "{{ case["input"]["phrase"] }}"
result = {{ case["property"] | to_camel }} {{ case["input"]["phrase"] | to_roc }}
result == "{{ case["expected"] }}"

{% endfor %}

# acronym/canonical-data.json
{
"exercise": "acronym",
"cases": [
{
"uuid": "1e22cceb-c5e4-4562-9afe-aef07ad1eaf4",
"description": "basic",
"property": "abbreviate",
"input": {
"phrase": "Portable Network Graphics"
},
"expected": "PNG"
},
{
"uuid": "79ae3889-a5c0-4b01-baf0-232d31180c08",
"description": "lowercase words",
"property": "abbreviate",
"input": {
"phrase": "Ruby on Rails"
},
"expected": "ROR"
},
{
"uuid": "ec7000a7-3931-4a17-890e-33ca2073a548",
"description": "punctuation",
"property": "abbreviate",
"input": {
"phrase": "First In, First Out"
},
"expected": "FIFO"
},
{
"uuid": "32dd261c-0c92-469a-9c5c-b192e94a63b0",
"description": "all caps word",
"property": "abbreviate",
"input": {
"phrase": "GNU Image Manipulation Program"
},
"expected": "GIMP"
},
{
"uuid": "ae2ac9fa-a606-4d05-8244-3bcc4659c1d4",
"description": "punctuation without whitespace",
"property": "abbreviate",
"input": {
"phrase": "Complementary metal-oxide semiconductor"
},
"expected": "CMOS"
},
{
"uuid": "0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9",
"description": "very long abbreviation",
"property": "abbreviate",
"input": {
"phrase": "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
},
"expected": "ROTFLSHTMDCOALM"
},
{
"uuid": "6a078f49-c68d-4b7b-89af-33a1a98c28cc",
"description": "consecutive delimiters",
"property": "abbreviate",
"input": {
"phrase": "Something - I made up from thin air"
},
"expected": "SIMUFTA"
},
{
"uuid": "5118b4b1-4572-434c-8d57-5b762e57973e",
"description": "apostrophes",
"property": "abbreviate",
"input": {
"phrase": "Halley's Comet"
},
"expected": "HC"
},
{
"uuid": "adc12eab-ec2d-414f-b48c-66a4fc06cdef",
"description": "underscore emphasis",
"property": "abbreviate",
"input": {
"phrase": "The Road _Not_ Taken"
},
"expected": "TRNT"
}
]
}
1 change: 1 addition & 0 deletions exercises/practice/acronym/acronym-test.roc
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ expect
expect
result = abbreviate "The Road _Not_ Taken"
result == "TRNT"

0 comments on commit 5f9f276

Please sign in to comment.