Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: wrong comparator in assert and maybe asserts #11

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

heueristik
Copy link
Contributor

@heueristik heueristik commented Aug 27, 2024

This PR

  • fixes assertGreater which was checking >= and not >.
  • refactors the maybe asserts
  • improves/corrects the messages being displayed

@heueristik heueristik force-pushed the feature/asserts-and-expects branch from 048a6af to 8e22938 Compare August 27, 2024 14:55
@heueristik heueristik requested a review from paulcadman August 27, 2024 14:59
@heueristik heueristik changed the title fix: wrong comparator in assert WIP fix: wrong comparator in assert Aug 27, 2024
@heueristik heueristik changed the title WIP fix: wrong comparator in assert fix: wrong comparator in assert Aug 27, 2024
@heueristik heueristik changed the title fix: wrong comparator in assert refactor: wrong comparator in assert and maybe asserts Aug 27, 2024
Comment on lines +88 to +92
expectJust {A} {{Show A}} (expected : A) (actual : Maybe A) : Assertion :=
assertJust (mkExpectMsg "nothing" " to be " ("just " ++str Show.show expected)) actual;

expectNothing {A} {{Show A}} (actual : Maybe A) : Assertion :=
assertNothing λ {x := mkExpectMsg ("just " ++str Show.show x) " to be " "nothing"} actual;
Copy link
Contributor Author

@heueristik heueristik Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  ; testCase "headMay [] is nothing" (expectNothing (headMay {Nat} [1]))
  ; testCase "headMay [1] is just 1" (expectJust 1 (headMay []))

now result in the following fail messages:

headMay [1] is just 1           FAIL: Expected "nothing" to be "just 1"
headMay [] is nothing           FAIL: Expected "just 1" to be "nothing"

Do you think this is good @paulcadman?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me !

@paulcadman paulcadman merged commit 0c974d5 into main Aug 27, 2024
1 check passed
@paulcadman paulcadman deleted the feature/asserts-and-expects branch August 27, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants