grain icon indicating copy to clipboard operation
grain copied to clipboard

[Stdlib] Assertion library

Open phated opened this issue 3 years ago • 8 comments

We've gotten far by just using the assert method in Pervasives for our tests, but I think we could take it to the next level by adding an assert module to our stdlib.

What are some of your favorite assertion libraries to use as a reference?

phated avatar Oct 15 '20 00:10 phated

All of the rspec-style assertion libraries have really grown on me. rspec, jest, mocha, the like.

I know @peblair was interested in having some sort of testing support built into the language like Pyret has: https://www.pyret.org/docs/latest/testing.html

But I'd honestly be perfectly happy with some sort of rspec style framework!

ospencer avatar Oct 15 '20 00:10 ospencer

But I guess you're asking a lot more about just assertions and not really a full testing framework. I've liked expect style libraries, but I'm not sure how well that'd work in Grain.

ospencer avatar Oct 15 '20 00:10 ospencer

I'd love to have a full-blown testing framework in the stdlib! I was thinking that might require macros to make a top-tier one, though. What do you think?

phated avatar Oct 15 '20 00:10 phated

I wasn't really thinking about expect necessarily. Maybe something like https://nodejs.org/api/assert.html or tape's assert (which I think was just a wrapper around node's assert).

phated avatar Oct 15 '20 00:10 phated

I was trying to avoid dropping the M-word on this thread, but yeah I agree 🙂

Yeah, we could totally get a basic version of Node's assert done pretty quick. I suppose ours would be a lot smaller.

ospencer avatar Oct 15 '20 00:10 ospencer

Yep! I was really just hoping for an inverted operator so we don't have to do assert !Something because I really don't like how that reads 🤣

phated avatar Oct 15 '20 00:10 phated

Dang, it'd be really nice to have optional arguments here for messages.

ospencer avatar Oct 15 '20 00:10 ospencer

Oooooh, yeah 💯

phated avatar Oct 15 '20 00:10 phated