diff --git a/docsite/site/content/stdlib/testing.md b/docsite/site/content/stdlib/testing.md index 2b14445..ef60d88 100644 --- a/docsite/site/content/stdlib/testing.md +++ b/docsite/site/content/stdlib/testing.md @@ -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{}; diff --git a/std/testing.ucg b/std/testing.ucg index 122b553..3c69b79 100644 --- a/std/testing.ucg +++ b/std/testing.ucg @@ -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, + }; }; }; \ No newline at end of file