mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Allow people to override the descriptions
For equal and not_equal specifically.
This commit is contained in:
parent
38fc521e3e
commit
924dcb40ff
@ -55,12 +55,13 @@ assert t.ok{
|
|||||||
|
|
||||||
### equal assertion
|
### 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
|
* `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.
|
* `right` which is required is the right hand side expression to compare.
|
||||||
|
* `desc` which is an optional description to output for your test. This defaults to
|
||||||
This module will create a description for you from the compared values.
|
a description created from the compared values.
|
||||||
|
|
||||||
```
|
```
|
||||||
let t = import "std/testing.ucg".asserts{};
|
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
|
* `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.
|
* `right` which is required is the right hand side expression to compare.
|
||||||
|
* `desc` which is an optional description to output for your test. This defaults to
|
||||||
This module will create a description for you from the compared values.
|
a description created from the compared values.
|
||||||
|
|
||||||
```
|
```
|
||||||
let t = import "std/testing.ucg".asserts{};
|
let t = import "std/testing.ucg".asserts{};
|
||||||
|
@ -42,10 +42,13 @@ let asserts = module{
|
|||||||
left=NULL,
|
left=NULL,
|
||||||
// right value for deep equal comparison.
|
// right value for deep equal comparison.
|
||||||
right=NULL,
|
right=NULL,
|
||||||
|
desc=NULL,
|
||||||
} => {
|
} => {
|
||||||
let ok = mod.left == mod.right;
|
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.
|
// Asserts that two values are not equal. Does deep equal comparisons.
|
||||||
@ -54,9 +57,12 @@ let asserts = module{
|
|||||||
left=NULL,
|
left=NULL,
|
||||||
// right value for deep equal comparison.
|
// right value for deep equal comparison.
|
||||||
right=NULL,
|
right=NULL,
|
||||||
|
desc=NULL,
|
||||||
} => {
|
} => {
|
||||||
let ok = mod.left != mod.right;
|
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,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user