From d31895098d7e39dd6588652167b6c33b202a0bee Mon Sep 17 00:00:00 2001 From: Duane Nykamp Date: Mon, 25 Oct 2021 16:49:51 -0500 Subject: [PATCH] don't convert booleans in numerical equality --- build/math-expressions.js | 4 ++++ build/math-expressions_umd.js | 4 ++++ lib/expression/equality/numerical.js | 4 ++++ package.json | 2 +- spec/slow_math-expressions.spec.js | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/build/math-expressions.js b/build/math-expressions.js index 7ce0876..5322e3d 100644 --- a/build/math-expressions.js +++ b/build/math-expressions.js @@ -76059,6 +76059,10 @@ const component_equals = function ({ expr, other, randomBindings, var expr_evaluated = expr_f(bindings); var other_evaluated = other_f(bindings); + if (typeof expr_evaluated === "boolean" || typeof other_evaluated === "boolean") { + return { out_of_bounds: true, always_zero: false }; + } + var expr_abs = math$19.abs(expr_evaluated); var other_abs = math$19.abs(other_evaluated); diff --git a/build/math-expressions_umd.js b/build/math-expressions_umd.js index a37413f..28c4ca8 100644 --- a/build/math-expressions_umd.js +++ b/build/math-expressions_umd.js @@ -76065,6 +76065,10 @@ var expr_evaluated = expr_f(bindings); var other_evaluated = other_f(bindings); + if (typeof expr_evaluated === "boolean" || typeof other_evaluated === "boolean") { + return { out_of_bounds: true, always_zero: false }; + } + var expr_abs = math$19.abs(expr_evaluated); var other_abs = math$19.abs(other_evaluated); diff --git a/lib/expression/equality/numerical.js b/lib/expression/equality/numerical.js index c001868..6e520fd 100644 --- a/lib/expression/equality/numerical.js +++ b/lib/expression/equality/numerical.js @@ -379,6 +379,10 @@ const component_equals = function ({ expr, other, randomBindings, var expr_evaluated = expr_f(bindings); var other_evaluated = other_f(bindings); + if (typeof expr_evaluated === "boolean" || typeof other_evaluated === "boolean") { + return { out_of_bounds: true, always_zero: false }; + } + var expr_abs = math.abs(expr_evaluated); var other_abs = math.abs(other_evaluated); diff --git a/package.json b/package.json index 1ab61a9..9dc7886 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "math-expressions", "description": "Perform basic equality testing and symbolic computations on mathematical expressions involving transcendental functions", - "version": "2.0.0-alpha26", + "version": "2.0.0-alpha27", "author": { "name": "Jim Fowler", "email": "kisonecat@gmail.com", diff --git a/spec/slow_math-expressions.spec.js b/spec/slow_math-expressions.spec.js index 67886aa..438afe8 100644 --- a/spec/slow_math-expressions.spec.js +++ b/spec/slow_math-expressions.spec.js @@ -311,6 +311,7 @@ describe("expression", function () { ['5q <= 9z', '-5q <= -9z'], ['5q >= 9z', '-5q >= -9z'], ['10^(-30)', '2*10^(-30)'], + ['0', 't=4'], ]; _.each(nonequivalences, function (nonequiv) {