diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-04-10 03:41:28 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-04-10 03:50:48 +0300 |
commit | 9e82d5ee56d258d33f59eb6fdcc363d8c0c47b4c (patch) | |
tree | a1c75db760bfd57c4051cc54352ed7eb65772fd3 /tests | |
parent | c462509adfd68e8b849b8a6713360fb4f9026578 (diff) | |
download | sciteco-9e82d5ee56d258d33f59eb6fdcc363d8c0c47b4c.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testsuite.at | 11 |
1 files changed, 11 insertions, 0 deletions
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 |