FEATURE: Allow people to override the descriptions

For equal and not_equal specifically.
This commit is contained in:
Jeremy Wall 2019-01-13 22:06:38 -06:00
parent 38fc521e3e
commit 924dcb40ff
2 changed files with 14 additions and 7 deletions

View File

@ -55,12 +55,13 @@ assert t.ok{
### equal assertion
The `equal` assertion module tests that two items are equal. It has two parameters.
The `equal` assertion module tests that two items are equal. It has three
parameters.
* `left` which is required and is the left hand side expression to compare
* `right` which is required is the right hand side expression to compare.
This module will create a description for you from the compared values.
* `desc` which is an optional description to output for your test. This defaults to
a description created from the compared values.
```
let t = import "std/testing.ucg".asserts{};
@ -78,8 +79,8 @@ parameters.
* `left` which is required and is the left hand side expression to compare
* `right` which is required is the right hand side expression to compare.
This module will create a description for you from the compared values.
* `desc` which is an optional description to output for your test. This defaults to
a description created from the compared values.
```
let t = import "std/testing.ucg".asserts{};

View File

@ -42,10 +42,13 @@ let asserts = module{
left=NULL,
// right value for deep equal comparison.
right=NULL,
desc=NULL,
} => {
let ok = mod.left == mod.right;
let desc = "@ == @" % (mod.left, mod.right);
let desc = select (mod.desc == NULL), "@ == @" % (mod.left, mod.right), {
false = mod.desc,
};
};
// Asserts that two values are not equal. Does deep equal comparisons.
@ -54,9 +57,12 @@ let asserts = module{
left=NULL,
// right value for deep equal comparison.
right=NULL,
desc=NULL,
} => {
let ok = mod.left != mod.right;
let desc = "@ != @" % (mod.left, mod.right);
let desc = select (mod.desc == NULL), "@ != @" % (mod.left, mod.right), {
false = mod.desc,
};
};
};