From 9e82d5ee56d258d33f59eb6fdcc363d8c0c47b4c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 10 Apr 2025 03:41:28 +0300 Subject: testsuite: check whether comparisons for equality really work with the `a-b"=` idiom * There might theoretically be problems with the uncommon one's complement or magnitude representation of negative integers, but it's practically impossible to meet those in the wild. * Still, we do some checks now, so we will at least notice any exotic architectures. * Also, documented the `a^#b"=` idiom for checking for equality. It's longer to type, but faster and will also work for floats. For floats it will be the only permissible idiom for checking for bitwise equality as `a-b` can be 0 even if a!=b (if the difference is very small). Changing the `-` semantics is out of the question. --- tests/testsuite.at | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/testsuite.at') diff --git a/tests/testsuite.at b/tests/testsuite.at index d8d88e1..3a33838 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -126,6 +126,17 @@ AT_CHECK([$SCITECO -e "$MAXINT64\\ J::@S/$MAXINT64/\"F(0/0)'"], 0, ignore, ignor AT_CHECK([$SCITECO -e "$MININT64\\ J::@S/$MININT64/\"F(0/0)'"], 0, ignore, ignore) AT_CLEANUP +# This should always work, at least on systems with a two's complement +# representation of negative integers. +# We will probably never meet anything else, but at least we check. +AT_SETUP([Integer comparisons]) +AT_CHECK([$SCITECO -e "($MAXINT32)-($MAXINT32)\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "($MININT32)-($MININT32)\"N(0/0)'"], 0, ignore, ignore) +AT_SKIP_IF([test $TECO_INTEGER -lt 64]) +AT_CHECK([$SCITECO -e "($MAXINT64)-($MAXINT64)\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "($MININT64)-($MININT64)\"N(0/0)'"], 0, ignore, ignore) +AT_CLEANUP + AT_SETUP([Convert between line and glyph positions]) AT_CHECK([$SCITECO -e "@I/1^J2^J3/J 2^QC :^Q-3\"N(0/0)'"], 0, ignore, ignore) AT_CLEANUP -- cgit v1.2.3