Skip to content

Commit

Permalink
all the fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-4 committed Jan 4, 2025
1 parent 20ed5c4 commit 2ee265c
Show file tree
Hide file tree
Showing 214 changed files with 1,375 additions and 1,147 deletions.
6 changes: 3 additions & 3 deletions bin/add-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ cat << END_TESTER > "exercises/practice/${slug}/.meta/template.j2"
{{ macros.canonical_ref() }}
{{ macros.header() }}
import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_camel }}]
import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }}]
{% for case in cases -%}
# {{ case["description"] }}
expect
result = {{ case["property"] | to_camel }} {{ case["input"]["myArg"] | to_roc }}
result = {{ case["property"] | to_snake }} {{ case["input"]["myArg"] | to_roc }}
result == {{ case["expected"] | to_roc }}
{% endfor %}
Expand All @@ -79,7 +79,7 @@ $(curl --silent "https://raw.githubusercontent.com/exercism/problem-specificatio
END_TESTER

slug_pascal=$(cd bin && python -c "from generate_tests import to_pascal; print(to_pascal('${slug}'))")
slug_camel=$(cd bin && python -c "from generate_tests import to_camel; print(to_camel('${slug}'))")
slug_camel=$(cd bin && python -c "from generate_tests import to_snake; print(to_snake('${slug}'))")

cat << END_TEST > "exercises/practice/${slug}/${slug}-test.roc"
# This file will be generated automatically
Expand Down
5 changes: 2 additions & 3 deletions bin/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
logger = logging.getLogger("generator")
logger.setLevel(logging.WARN)


def replace_all(string: str, chars: Union[str, List[str]], rep: str) -> str:
"""
Replace any char in chars with rep, reduce runs and strip terminal ends.
Expand Down Expand Up @@ -170,9 +169,9 @@ def to_roc_tuple(values: Any):
def to_roc_record(obj: Dict[str, Any]):
items = []
for key, value in obj.items():
camel_key = to_camel(key)
snake_key = to_snake(key)
roc_value = to_roc(value)
items.append(f"{camel_key}: {roc_value}")
items.append(f"{snake_key}: {roc_value}")

return "{ " + ", ".join(items) + " }"

Expand Down
6 changes: 4 additions & 2 deletions config/generator_macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

{% macro header(imports=[], ignore=[]) -%}

app [main] {
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br"
{%- if imports -%}
{%- for name in imports -%},
Expand All @@ -34,8 +34,10 @@ app [main] {
{%- endif %}
}

import pf.Stdout

main! = \_args ->
Ok {}
Stdout.line! ""

{%- endmacro %}

4 changes: 2 additions & 2 deletions exercises/practice/accumulate/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ macros.canonical_ref() }}
{{ macros.header() }}

import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_camel }}]
import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }}]

{% set accumulators = {
"(x) => x * x": "\\x ->\n x * x",
Expand All @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_camel }
{% for case in cases -%}
# {{ case["description"] }}
expect
result = {{ case["property"] | to_camel }} {{ case["input"]["list"] | to_roc }} {{ accumulators[case["input"]["accumulator"]] }}
result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} {{ accumulators[case["input"]["accumulator"]] }}
result == {{ case["expected"] | to_roc }}

{% endfor %}
Expand Down
6 changes: 4 additions & 2 deletions exercises/practice/accumulate/accumulate-test.roc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/accumulate/canonical-data.json
# File last updated on 2024-09-15
# File last updated on 2025-01-04
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br",
}

import pf.Stdout

main! = \_args ->
Ok {}
Stdout.line! ""

import Accumulate exposing [accumulate]

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [abbreviate]
{% for case in cases -%}
# {{ case["description"] }}
expect
result = {{ case["property"] | to_camel }} {{ case["input"]["phrase"] | to_roc }}
result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }}
result == {{ case["expected"] | to_roc }}

{% endfor %}
8 changes: 5 additions & 3 deletions exercises/practice/acronym/acronym-test.roc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/acronym/canonical-data.json
# File last updated on 2024-08-27
app [main] {
# File last updated on 2025-01-04
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br",
}

import pf.Stdout

main! = \_args ->
Ok {}
Stdout.line! ""

import Acronym exposing [abbreviate]

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/affine-cipher/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [encode, decode]
expect
phrase = {{ case["input"]["phrase"] | to_roc }}
key = {a: {{ case["input"]["key"]["a"] }}, b: {{ case["input"]["key"]["b"] }}}
result = {{ case["property"] | to_camel }} phrase key
result = {{ case["property"] | to_snake }} phrase key
{%- if case["expected"]["error"] %}
result |> Result.isErr
{%- else %}
Expand Down
8 changes: 5 additions & 3 deletions exercises/practice/affine-cipher/affine-cipher-test.roc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/affine-cipher/canonical-data.json
# File last updated on 2024-10-23
app [main] {
# File last updated on 2025-01-04
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br",
}

import pf.Stdout

main! = \_args ->
Ok {}
Stdout.line! ""

import AffineCipher exposing [encode, decode]

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/all-your-base/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{{ macros.canonical_ref() }}
{{ macros.header() }}

import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_camel }}]
import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }}]

{% for case in cases -%}
# {{ case["description"] }}
expect
result = {{ case["property"] | to_camel }} { input_base: {{ case["input"]["input_base"] | to_roc }}, output_base: {{ case["input"]["output_base"] | to_roc }}, digits: {{ case["input"]["digits"] | to_roc }} }
result = {{ case["property"] | to_snake }} { input_base: {{ case["input"]["inputBase"] | to_roc }}, output_base: {{ case["input"]["outputBase"] | to_roc }}, digits: {{ case["input"]["digits"] | to_roc }} }
{%- if case["expected"]["error"] %}
result |> Result.isErr
{%- else %}
result == Ok {{ case["expected"] }}
{%- endif %}

{% endfor %}
{% endfor %}
9 changes: 6 additions & 3 deletions exercises/practice/all-your-base/all-your-base-test.roc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/all-your-base/canonical-data.json
# File last updated on 2024-09-03
app [main] {
# File last updated on 2025-01-04
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br",
}

import pf.Stdout

main! = \_args ->
Ok {}
Stdout.line! ""

import AllYourBase exposing [rebase]

Expand Down Expand Up @@ -94,3 +96,4 @@ expect
expect
result = rebase { input_base: 10, output_base: 0, digits: [7] }
result |> Result.isErr

4 changes: 2 additions & 2 deletions exercises/practice/allergies/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [allergic_to, set]
{% for case in outerCase["cases"] %}
# {{ outerCase["description"] }} {{ case["description"] | default('') }}
expect
{%- if case["property"] == "allergic_to" %}
{%- if case["property"] == "allergicTo" %}
result = allergic_to {{ case["input"]["item"] | to_pascal }} {{ case["input"]["score"] | to_roc }}
result == {{ case["expected"] | to_roc }}
{%- else %}
Expand All @@ -17,4 +17,4 @@ expect
{%- endif %}

{% endfor %}
{% endfor %}
{% endfor %}
Loading

0 comments on commit 2ee265c

Please sign in to comment.