purescript / purescript-assert Goto Github PK
View Code? Open in Web Editor NEWBasic assertions library for low level testing
License: BSD 3-Clause "New" or "Revised" License
Basic assertions library for low level testing
License: BSD 3-Clause "New" or "Revised" License
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 }
Another thing that bothers me a little is that the full error message in assertEqual
gets evaluated even if it is not needed. show
can be quite expensive for large inputs.
Possible fix is to delay the first argument of assert'
(some renaming should also be done to avoid breaking the API)
foreign import assert'
:: (Unit -> String)
-> Boolean
-> Effect Unit
Should I make a PR for this issue, or is it too insignificant to care about?
Since we have assert'
that throws with a user-supplied message, why not having these? That's what the user might expect.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.