} ;
! TODO: take this out eventually
: math-throw-1
+ {
+ recip log2
+ asec asech acot acoth acosec acosech acos acosh asin asinh atan atanh
+ } ;
+
+: integer>x-throw
+ {
+ recip log2
+ asec asech acot acoth acosec acosech acos acosh asin asinh atan atanh
+ } ;
+: ratio>x-throw
+ {
+ recip
+ asec asech acot acoth acosec acosech acos acosh asin asinh atan atanh
+ } ;
+: float>x-throw
+ {
+ recip
+ asec asech acot acoth acosec acosech acos acosh asin asinh atan atanh
+ } ;
+: complex>x-throw
{
recip
asec asech acot acoth acosec acosech acos acosh asin asinh atan atanh
} ;
-
-
: math-2 ( -- seq )
{ * + - /f max min polar> bitand bitor bitxor align shift } ;
: math-throw-2 ( -- seq ) { / /i ^ mod rem } ;
>r 100 200 300 400 r> compile-1 4array
= [ "problem found! (compile-check*)" throw ] unless ;
+: interp-compile-check-catch ( quot -- )
+ dup .
+ [ last set ] keep
+ [ catch [ "caught: " write dup print-error ] when* ] keep
+ [ compile-1 ] catch [ nip "caught: " write dup print-error ] when*
+ = [ "problem in math" throw ] unless ;
+
+
+
+: test-integer>x-throws ( -- )
+ [
+ random-integer , integer>x-throw nth-rand ,
+ ] [ ] make interp-compile-check-catch ;
+: test-ratio>x-throws ( -- )
+ [
+ random-ratio , ratio>x-throw nth-rand ,
+ ] [ ] make interp-compile-check-catch ;
+: test-float>x-throws ( -- )
+ [
+ random-float , float>x-throw nth-rand ,
+ ] [ ] make interp-compile-check-catch ;
+: test-complex>x-throws ( -- )
+ [
+ random-complex , complex>x-throw nth-rand ,
+ ] [ ] make interp-compile-check-catch ;
+
+: test-2integer>x-throws ( -- )
+ [
+ random-integer , random-integer , math-throw-2 nth-rand ,
+ ] [ ] make interp-compile-check-catch ;
+
! 1-arg tests
: test-integer>x ( -- )
random-integer integer>x nth-rand f cons cons interp-compile-check ;