From 477a0920bc59c9714f2eef6e8a9a96a7aa7788c5 Mon Sep 17 00:00:00 2001 From: Richard Milewski Date: Wed, 19 Apr 2023 17:34:33 -0700 Subject: [PATCH] epsilon issues. --- comparisons.scad | 2 +- utility.scad | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/comparisons.scad b/comparisons.scad index 8ecc382b..1687f127 100644 --- a/comparisons.scad +++ b/comparisons.scad @@ -23,7 +23,7 @@ // Arguments: // a = First value. // b = Second value. -// eps = The maximum allowed difference between `a` and `b` that will return true. +// eps = The maximum allowed difference between `a` and `b` that will return true. Defaults to 1e-9. // Example: // test1 = approx(-0.3333333333,-1/3); // Returns: true // test2 = approx(0.3333333333,1/3); // Returns: true diff --git a/utility.scad b/utility.scad index 8668c547..07be7859 100644 --- a/utility.scad +++ b/utility.scad @@ -883,15 +883,17 @@ function _valstr(x) = // Module: assert_approx() -// Synopsis: Assert that a value is expected. +// Synopsis: Assert that a value is approximately what was expected. // Topics: Error Checking, Debugging // See Also: no_children(), no_function(), no_module(), assert_equal() // Usage: // assert_approx(got, expected, [info]); // Description: -// Tests if the value gotten is what was expected. If not, then +// Tests if the value gotten is what was expected, plus or minus 1e-9. If not, then // the expected and received values are printed to the console and // an assertion is thrown to stop execution. +// +// Returns false if both 'got' and 'expected' are 'nan'. // Arguments: // got = The value actually received. // expected = The value that was expected. @@ -924,6 +926,8 @@ module assert_approx(got, expected, info) { // Description: // Tests if the value gotten is what was expected. If not, then the expected and received values // are printed to the console and an assertion is thrown to stop execution. +// +// Returns true if both 'got' and 'expected' are 'nan'. // Arguments: // got = The value actually received. // expected = The value that was expected.