Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hargonix/nest-unit
https://github.com/hargonix/nest-unit
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hargonix/nest-unit
- Owner: hargoniX
- License: other
- Created: 2023-08-26T13:13:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-17T16:29:03.000Z (about 1 year ago)
- Last Synced: 2024-10-13T13:28:13.302Z (3 months ago)
- Language: Lean
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `nest-unit`
An `IsTest` implementation for [`nest-core`](https://github.com/hargonix/nest-core).The main contribution of this implementation consists of three things:
1. The `IsTest UnitTest` instance which allows us to write assertion based unit tests.
2. The `assert` function. This is the main entry points for users of the library.
It checks whether `t` holds and fails the test if it doesn't.
3. The `Assertable` type class, it allows you to provide a way to test whether
a property holds. If it doesn't use `assertFailure msg` to indicate failure.
For examples on implementations we refer to the rather minimal implementation of
`nest-unit` itself.Here is a full example on the usage of `assert` and the library in general:
```lean
import NestCore
import NestUnitopen Nest.Core
open Nest.Unitgroup "Self Tests"
group "Basic"
test "succeeds on true" : UnitTest := do
assert true
test "fails on false (expected to fail)" : UnitTest := do
assert false
group "Instances"
test "positive eq" : UnitTest := do
assert <| "hello" = "hello"
test "negative eq (expected to fail)" : UnitTest := do
assert <| "hello" = "world"def main : IO UInt32 := Nest.Core.defaultMain tests
```