diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-02-06 16:45:04 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-02-06 16:45:04 +0300 |
commit | 21c5be3706f70d573f8d0195760846fce46f6807 (patch) | |
tree | 9240d238d5b183bdaf57ecad69c10595736690e0 /tests/testsuite.at | |
parent | 37eef3cf0ab0b0ed3dabc1c96515f4e30011f9db (diff) | |
download | sciteco-21c5be3706f70d573f8d0195760846fce46f6807.tar.gz |
fixed the power (^*) operator: did not handle corner cases and was inefficient
* in fact, with a negative exponent the previous naive implementation would even hang indefinitely!
* Now uses the squaring algorithm.
This is slightly longer but significantly more efficient.
* added test cases
Diffstat (limited to 'tests/testsuite.at')
-rw-r--r-- | tests/testsuite.at | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/testsuite.at b/tests/testsuite.at index 80e111c..3a8bed8 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -27,6 +27,15 @@ AT_CHECK([$SCITECO -e "2%a,%a - 3\"N(0/0)'"], 0, ignore, ignore) AT_CHECK([$SCITECO -e "(1,) \"~|(0/0)'"], 0, ignore, ignore) AT_CLEANUP +AT_SETUP([Exponentiation]) +AT_CHECK([$SCITECO -e "-1^*0 - (-1)\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "-1^*-5 - (-1)\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "0^*-5="], 1, ignore, ignore) +AT_CHECK([$SCITECO -e "0^*0 - 1\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "1^*-5 - 1\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO -e "2^*-5 - 0\"N(0/0)'"], 0, ignore, ignore) +AT_CLEANUP + AT_SETUP([Missing left operand]) AT_CHECK([$SCITECO -e '+23='], 1, ignore, ignore) AT_CLEANUP |