diff --git a/CHANGES.rst b/CHANGES.rst index 9c2a59f91..c233ec27a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -47,7 +47,8 @@ Bugs * ``Switch[]`` involving ``Infinity`` Issue #956 * ``Outer[]`` on ``SparseArray`` Issue #939 * ``ArrayQ[]`` detects ``SparseArray`` PR #947 - +* Numeric comparisons against expressions involving ``String``s (Issue #797). + Package updates +++++++++++++++ diff --git a/mathics/eval/testing_expressions.py b/mathics/eval/testing_expressions.py index 503e20a60..c37bb0f6e 100644 --- a/mathics/eval/testing_expressions.py +++ b/mathics/eval/testing_expressions.py @@ -20,7 +20,11 @@ def do_cmp(x1, x2) -> Optional[int]: return None s1 = x1.to_sympy() + if s1 is None: + return None s2 = x2.to_sympy() + if s2 is None: + return None # Use internal comparisons only for Real which is uses # WL's interpretation of equal (which allows for slop diff --git a/test/builtin/test_comparison.py b/test/builtin/test_comparison.py index 386b3123d..a2fc847c6 100644 --- a/test/builtin/test_comparison.py +++ b/test/builtin/test_comparison.py @@ -78,6 +78,14 @@ ("g[a]3', "Wo[x] > 3", "isue #797"), + ('Wo["x"]<3', "Wo[x] < 3", "isue #797"), + ('Wo["x"]==3', "Wo[x] == 3", "isue #797"), + ('3>Wo["x"]', "3 > Wo[x]", "isue #797"), + ('30', "Wo[f[x], 2] > 0", "isue #797"), + # # chained compare ("a != a != b", "False", "Strange MMA behavior"), ("a != b != a", "a != b != a", "incomparable values should be unchanged"),