unisonweb / base

Unison base libraries

Home Page:https://share.unison-lang.org/@unison/base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WIP: proposed tweaks to testing API

pchiusano opened this issue · comments

Currently chicken scratch, but @SystemFw was noting some awkwardness with collecting up multiple assertions without failing fast, in a single run. We could do something like this, which also lets us label test results:

unique ability Test where
  pass : Text -> a -> ()
  fail : Text -> a -> ()
  -- this can also be used to implement 
  --   ensurePending msg payload b = if b then unexpectedPass ("pending test succeeded: " ++ msg) payload else ()
  unexpectedPass : Text -> a -> ()

-- this collects up any failures into an exception, failing fast if any fail, and discarding `pass`
Test.scope : '{g, Test} a ->{Exception,g} a

ensure/ensureEqual could have two variants now - one which is in `Exception` which fails fast and another which is in `Test` which doesn't fail fast

-- this handles `Test` and fails if `Test` produces any failures, but it also prints all the successes
verify : '{Test, Each, Random, Exception, g} a ->{g} [Result]

And then delete Gen and the other olding testing functions, so base has a canonical way of doing testing.

This Test ability I think will clean up the cloud client tests, which jump through a bunch of hoops to get additional information about failures / sucesses (it uses Exists)