diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test index 5b49d0370..ab70a590a 100644 --- a/test-suite/tests/numbers.test +++ b/test-suite/tests/numbers.test @@ -767,6 +767,46 @@ ) +;;; +;;; modulo-expt +;;; + +(with-test-prefix "modulo-expt" + (pass-if (= 1 (modulo-expt 17 23 47))) + + (pass-if (= 1 (modulo-expt 17 -23 47))) + + (pass-if (= 17 (modulo-expt 17 -22 47))) + + (pass-if (= 36 (modulo-expt 17 22 47))) + + (pass-if (= 183658794479969134816674175082294846241553725240 (modulo-expt 111122223333444455556666 111122223333444455556666 1153478690012629968439432872520758982731022934717))) + + (pass-if-exception + "Proper exception with 0 modulus" + (cons 'numerical-overflow "") + (modulo-expt 17 23 0)) + + (pass-if-exception + "Proper exception when result not invertible" + (cons 'numerical-overflow "") + (modulo-expt 10 -1 48)) + + (pass-if-exception + "Proper exception with wrong type argument" + (cons 'wrong-type-arg "") + (modulo-expt "Sam" 23 10)) + + (pass-if-exception + "Proper exception with wrong type argument" + (cons 'wrong-type-arg "") + (modulo-expt 17 9.9 10)) + + (pass-if-exception + "Proper exception with wrong type argument" + (cons 'wrong-type-arg "") + (modulo-expt 17 23 'Ethel))) + ;;; ;;; gcd ;;;