Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zxch3n/moon-expect
https://github.com/zxch3n/moon-expect
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zxch3n/moon-expect
- Owner: zxch3n
- Created: 2024-02-06T14:54:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-18T13:28:15.000Z (about 2 months ago)
- Last Synced: 2024-10-04T16:22:31.515Z (about 1 month ago)
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# expect for MoonBit
`expect` that works like [Jest/Vitest's expect](https://jestjs.io/docs/expect).
You can use it to create various assertions easily.
# Example Usage
```
expect("hello").equal("hello")
expect("hello").not().equal("hello") // abort
expect("hello").equal("hello1") // abort
expect("hello").not().equal("hello1")let a : Option[Int] = Some(1)
let b : Option[Int] = None
expect(a).to_be_some()
expect(b).to_be_none()expect("hello").to_have_length(5)
expect("hello").not().to_have_length(6)expect(1).to_be_less_than(4)
let a : Result[Int, Int] = Ok(1)
let b : Result[Int, Int] = Err(1)
expect(a).to_be_ok()
expect(b).to_be_err()expect(1.0).close_to(1.0, 0.1)
```## Example Error Messages
```
AssertionError: expected 1.0 to be close to 1.2 (±0.1)- Expected:
+ Received:- 1.2
+ 1.0
``````
AssertionError: expected "hello" to equal "hello1"- Expected:
+ Received:- "hello1"
+ "hello"
```