Skip to content

Commit

Permalink
Replace Err "Foo bar" with Err FooBar (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ageron authored Aug 29, 2024
1 parent 43fabf2 commit 2c474b8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module [steps]

steps = \n ->
if n <= 0 then
Err "Only positive integers are allowed"
Err OnlyPositiveIntegersAreAllowed
else if n == 1 then
Ok 0
else if Num.isEven n then
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {{ exercise | to_pascal }} exposing [steps]
expect
result = {{ case["property"] | to_camel }} {{ case["input"]["number"] }}
{%- if case["expected"]["error"] %}
result == Err {{ case["expected"]["error"] | to_roc }}
result == Err {{ case["expected"]["error"] | to_pascal }}
{%- else %}
result == Ok {{ case["expected"] }}
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/collatz-conjecture/canonical-data.json
# File last updated on 2024-08-27
# File last updated on 2024-08-29
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br",
}
Expand Down Expand Up @@ -35,10 +35,10 @@ expect
# zero is an error
expect
result = steps 0
result == Err "Only positive integers are allowed"
result == Err OnlyPositiveIntegersAreAllowed

# negative value is an error
expect
result = steps -15
result == Err "Only positive integers are allowed"
result == Err OnlyPositiveIntegersAreAllowed

2 changes: 1 addition & 1 deletion exercises/practice/grains/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ grainsOnSquare = \square ->
2 |> Num.powInt (square - 1) |> Ok
# or: 1u64 |> Num.shiftLeftBy (square - 1) |> Ok
else
Err "square must be between 1 and 64"
Err SquareMustBeBetween1And64

totalGrains =
Num.maxU64
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/grains/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ expect
expect
result = grainsOnSquare {{ subcase["input"]["square"] | to_roc }}
{%- if subcase["expected"]["error"] %}
result == Err {{ subcase["expected"]["error"] | to_roc }}
result == Err {{ subcase["expected"]["error"] | to_pascal }}
{%- else %}
result == Ok {{ subcase["expected"] }}
{%- endif %}
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/grains/grains-test.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/grains/canonical-data.json
# File last updated on 2024-08-27
# File last updated on 2024-08-29
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br",
}
Expand Down Expand Up @@ -54,17 +54,17 @@ expect
# square 0 is invalid
expect
result = grainsOnSquare 0
result == Err "square must be between 1 and 64"
result == Err SquareMustBeBetween1And64

# negative square is invalid
expect
result = grainsOnSquare -1
result == Err "square must be between 1 and 64"
result == Err SquareMustBeBetween1And64

# square greater than 64 is invalid
expect
result = grainsOnSquare 65
result == Err "square must be between 1 and 64"
result == Err SquareMustBeBetween1And64

##
## returns the total number of grains on the board
Expand Down
3 changes: 2 additions & 1 deletion exercises/practice/luhn/luhn-test.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/luhn/canonical-data.json
# File last updated on 2024-08-27
# File last updated on 2024-08-29
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br",
}
Expand Down Expand Up @@ -121,3 +121,4 @@ expect
expect
result = valid "59%59"
result == Bool.false

2 changes: 1 addition & 1 deletion exercises/practice/perfect-numbers/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module [classify]

aliquotSum = \number ->
if number <= 0 then
Err "Classification is only possible for positive integers."
Err ClassificationIsOnlyPossibleForPositiveIntegers
else if number == 1 then
Ok 0 # edge case
else
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/perfect-numbers/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [classify]
expect
result = {{ case["property"] | to_camel }} {{ case["input"]["number"] }}
{%- if case["expected"]["error"] %}
result == Err {{ case["expected"]["error"] | to_roc }}
result == Err {{ case["expected"]["error"] | to_pascal }}
{%- else %}
result == Ok {{ case["expected"] | to_pascal }}
{%- endif %}
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/perfect-numbers/perfect-numbers-test.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/perfect-numbers/canonical-data.json
# File last updated on 2024-08-27
# File last updated on 2024-08-29
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br",
}
Expand Down Expand Up @@ -86,10 +86,10 @@ expect
# Zero is rejected (as it is not a positive integer)
expect
result = classify 0
result == Err "Classification is only possible for positive integers."
result == Err ClassificationIsOnlyPossibleForPositiveIntegers

# Negative integer is rejected (as it is not a positive integer)
expect
result = classify -1
result == Err "Classification is only possible for positive integers."
result == Err ClassificationIsOnlyPossibleForPositiveIntegers

0 comments on commit 2c474b8

Please sign in to comment.