diff --git a/CHANGELOG.md b/CHANGELOG.md index 8485130..f796be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.3.4 + +* Update to DLang frontend 2.91 +* Using std.math.isClose instead of .approxEquals +* Added .close as alias of .approxEquals + # v0.3.3 * .throw must be @trusted, to allow to catch Errors diff --git a/README.md b/README.md index ef0debe..dee1d57 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,17 @@ assertion. 255.should.equal(10); // Throws an Exception "expected 255 to equal 10" ``` -#### `T approxEqual(U)(U other, U maxRelDiff = 1e-2, U maxAbsDiff = 1e-05, string file = __FILE__, size_t line = __LINE__);` +#### `T approxEqual(U)(U other, U maxRelDiff = CommonDefaultFor!(T,U), U maxAbsDiff = 0.0, string file = __FILE__, size_t line = __LINE__);` -Asserts for aproximated equality of float types. Returns the value wrapped around the -assertion. +Asserts for approximated equality of float types. Returns the value wrapped around the +assertion. See Phobos std.math.isClose(). ```d (1.0f).should.be.approxEqual(1.00000001); -(1.0f).should.not.be.approxEqual(1.001); +(1.0f).should.not.be.approxEqual(1.01); ``` +#### `T close(U)(U other, U maxRelDiff = CommonDefaultFor!(T,U), U maxAbsDiff = 0.0, string file = __FILE__, size_t line = __LINE__);` + +Alias of approxEqual #### `T exist(string file = __FILE__, size_t line = __LINE__);` diff --git a/docs/assets/img/logo-dub.png b/docs/assets/img/logo-dub.png new file mode 100644 index 0000000..4b95461 Binary files /dev/null and b/docs/assets/img/logo-dub.png differ diff --git a/docs/changelog.md b/docs/changelog.md index c9590c5..f9ce724 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,12 @@ layout: default title: Changelog --- +# v0.3.4 + +* Update to DLang frontend 2.91 +* Using std.math.isClose instead of .approxEquals +* Added .close as alias of .approxEquals + # v0.3.3 * .throw must be @trusted, to allow to catch Errors diff --git a/docs/index.md b/docs/index.md index ed85b14..354eede 100644 --- a/docs/index.md +++ b/docs/index.md @@ -62,14 +62,17 @@ assertion. 255.should.equal(10); // Throws an Exception "expected 255 to equal 10" ``` -#### `T approxEqual(U)(U other, U maxRelDiff = 1e-2, U maxAbsDiff = 1e-05, string file = __FILE__, size_t line = __LINE__);` +#### `T approxEqual(U)(U other, U maxRelDiff = CommonDefaultFor!(T,U), U maxAbsDiff = 0.0, string file = __FILE__, size_t line = __LINE__);` -Asserts for aproximated equality of float types. Returns the value wrapped around the -assertion. +Asserts for approximated equality of float types. Returns the value wrapped around the +assertion. See Phobos std.math.isClose(). ```d (1.0f).should.be.approxEqual(1.00000001); -(1.0f).should.not.be.approxEqual(1.001); +(1.0f).should.not.be.approxEqual(1.01); ``` +#### `T close(U)(U other, U maxRelDiff = CommonDefaultFor!(T,U), U maxAbsDiff = 0.0, string file = __FILE__, size_t line = __LINE__);` + +Alias of approxEqual #### `T exist(string file = __FILE__, size_t line = __LINE__);` diff --git a/docs/pijamas.html b/docs/pijamas.html index 99020e2..c5f7161 100644 --- a/docs/pijamas.html +++ b/docs/pijamas.html @@ -755,7 +755,7 @@
- @trusted T
approxEqual
(U = double)(U other
, U maxRelDiff
= 0.01, U maxAbsDiff
= 1e-05, string file
= __FILE__, size_t line
= __LINE__) if (is(T : real) && __traits(isFloating, T) && is(U : real) && __traits(isFloating, U));
+ @trusted T approxEqual
(U = double)(U other
, U maxRelDiff
= CommonDefaultFor!(T, U), U maxAbsDiff
= 0.0, string file
= __FILE__, size_t line
= __LINE__) if (is(T : real) && __traits(isFloating, T) && is(U : real) && __traits(isFloating, U));
+
+ U
+ |
+
+
+
++ Value to compare to compare. + + |
+
+
+ U
+ |
+
+
+
+
+ Maximum allowable relative difference.
+ Setting to 0.0 disables this check. Default depends on the type of
+ |
+
+
+ U
+ |
+
+
+
+
+ Maximum absolute difference. This is mainly usefull
+ for comparing values to zero. Setting to 0.0 disables this check.
+ Defaults to |
+
+
+ string
+ |
+
+
+
++ filename + + |
+
+
+ size_t
+ |
+
+
+
+
+ |
+
@@ -780,7 +863,7 @@
double d = 0.1;
-double d2 = d + 1e-05;
+double d2 = d + 1e-10;
d.should.not.be.equal(d2);
d.should.be.approxEqual(d2);
close
+
+
+ alias
+ close
= approxEqual;
+
+
+ Alias to approxEqual + +
+
+
+
+
+ double d = 0.1;
+double d2 = d + 1e-10;
+d.should.not.be.close(d2);
+d.should.be.close(d2);
+