Skip to content

Commit

Permalink
Shorter error tag: OnlyPositiveIntegersAreAllowed (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ageron authored Aug 29, 2024
1 parent 2c474b8 commit f034540
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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 ClassificationIsOnlyPossibleForPositiveIntegers
Err OnlyPositiveIntegersAreAllowed
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_pascal }}
result == Err OnlyPositiveIntegersAreAllowed
{%- else %}
result == Ok {{ case["expected"] | to_pascal }}
{%- endif %}
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/perfect-numbers/perfect-numbers-test.roc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ expect
# Zero is rejected (as it is not a positive integer)
expect
result = classify 0
result == Err ClassificationIsOnlyPossibleForPositiveIntegers
result == Err OnlyPositiveIntegersAreAllowed

# Negative integer is rejected (as it is not a positive integer)
expect
result = classify -1
result == Err ClassificationIsOnlyPossibleForPositiveIntegers
result == Err OnlyPositiveIntegersAreAllowed

0 comments on commit f034540

Please sign in to comment.