Skip to content

Can we make assertion output more readable? #5

@joneshf

Description

@joneshf

Some libraries outside of core use this library as their way of testing. The problem is that the output is pretty hard to understand. How would we feel about adding a few small helpers to make the output better?

assertEqual  forall a eff. Eq a => Show a => { expected :: a, actual :: a } -> Eff (assert :: ASSERT | eff) Unit
assertEqual {actual, expected} = do
  unless result $ log message
  assert' message result
  where
  message = "Expected: " <> show expected <> "\nActual:   " <> show actual
  result = actual == expected

assertTrue :: forall eff. Boolean -> Eff (assert :: ASSERT | eff) Unit
assertTrue actual = assertEqual { actual, expected: true }

assertFalse :: forall eff. Boolean -> Eff (assert :: ASSERT | eff) Unit
assertFalse actual = assertEqual { actual, expected: false }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions