math.floats.env: Make sure answers are array. So much metapgramming in these unit tests.
parent
a35d43303c
commit
9bbba4dca8
|
@ -16,37 +16,37 @@ set-default-fp-env
|
||||||
: test-fp-exception-compiled ( exception inputs quot -- quot' )
|
: test-fp-exception-compiled ( exception inputs quot -- quot' )
|
||||||
'[ _ @ [ _ collect-fp-exceptions ] compile-call nip member? ] ;
|
'[ _ @ [ _ collect-fp-exceptions ] compile-call nip member? ] ;
|
||||||
|
|
||||||
[ t ] +fp-zero-divide+ [ 1.0 0.0 ] [ /f ] test-fp-exception unit-test
|
{ t } +fp-zero-divide+ [ 1.0 0.0 ] [ /f ] test-fp-exception unit-test
|
||||||
[ t ] +fp-inexact+ [ 1.0 3.0 ] [ /f ] test-fp-exception unit-test
|
{ t } +fp-inexact+ [ 1.0 3.0 ] [ /f ] test-fp-exception unit-test
|
||||||
[ t ] +fp-overflow+ [ 1.0e250 1.0e100 ] [ * ] test-fp-exception unit-test
|
{ t } +fp-overflow+ [ 1.0e250 1.0e100 ] [ * ] test-fp-exception unit-test
|
||||||
[ t ] +fp-underflow+ [ 1.0e-250 1.0e-100 ] [ * ] test-fp-exception unit-test
|
{ t } +fp-underflow+ [ 1.0e-250 1.0e-100 ] [ * ] test-fp-exception unit-test
|
||||||
[ t ] +fp-overflow+ [ 2.0 100,000.0 ] [ fpow ] test-fp-exception unit-test
|
{ t } +fp-overflow+ [ 2.0 100,000.0 ] [ fpow ] test-fp-exception unit-test
|
||||||
[ t ] +fp-invalid-operation+ [ 0.0 0.0 ] [ /f ] test-fp-exception unit-test
|
{ t } +fp-invalid-operation+ [ 0.0 0.0 ] [ /f ] test-fp-exception unit-test
|
||||||
[ t ] +fp-invalid-operation+ [ -1.0 ] [ fsqrt ] test-fp-exception unit-test
|
{ t } +fp-invalid-operation+ [ -1.0 ] [ fsqrt ] test-fp-exception unit-test
|
||||||
|
|
||||||
[ t ] +fp-zero-divide+ [ 1.0 0.0 ] [ /f ] test-fp-exception-compiled unit-test
|
{ t } +fp-zero-divide+ [ 1.0 0.0 ] [ /f ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-inexact+ [ 1.0 3.0 ] [ /f ] test-fp-exception-compiled unit-test
|
{ t } +fp-inexact+ [ 1.0 3.0 ] [ /f ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-overflow+ [ 1.0e250 1.0e100 ] [ * ] test-fp-exception-compiled unit-test
|
{ t } +fp-overflow+ [ 1.0e250 1.0e100 ] [ * ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-underflow+ [ 1.0e-250 1.0e-100 ] [ * ] test-fp-exception-compiled unit-test
|
{ t } +fp-underflow+ [ 1.0e-250 1.0e-100 ] [ * ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-overflow+ [ 2.0 100,000.0 ] [ fpow ] test-fp-exception-compiled unit-test
|
{ t } +fp-overflow+ [ 2.0 100,000.0 ] [ fpow ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-invalid-operation+ [ 2.0 0/0. 1.0e-9 ] [ ~ ] test-fp-exception-compiled unit-test
|
{ t } +fp-invalid-operation+ [ 2.0 0/0. 1.0e-9 ] [ ~ ] test-fp-exception-compiled unit-test
|
||||||
|
|
||||||
! No underflow on Linux with this test, just inexact. Reported as an Ubuntu bug:
|
! No underflow on Linux with this test, just inexact. Reported as an Ubuntu bug:
|
||||||
! https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/429113
|
! https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/429113
|
||||||
os linux? cpu x86.64? and [
|
os linux? cpu x86.64? and [
|
||||||
[ t ] +fp-underflow+ [ 2.0 -100,000.0 ] [ fpow ] test-fp-exception unit-test
|
{ t } +fp-underflow+ [ 2.0 -100,000.0 ] [ fpow ] test-fp-exception unit-test
|
||||||
[ t ] +fp-underflow+ [ 2.0 -100,000.0 ] [ fpow ] test-fp-exception-compiled unit-test
|
{ t } +fp-underflow+ [ 2.0 -100,000.0 ] [ fpow ] test-fp-exception-compiled unit-test
|
||||||
] unless
|
] unless
|
||||||
|
|
||||||
[ t ] +fp-invalid-operation+ [ 0.0 0.0 ] [ /f ] test-fp-exception-compiled unit-test
|
{ t } +fp-invalid-operation+ [ 0.0 0.0 ] [ /f ] test-fp-exception-compiled unit-test
|
||||||
[ t ] +fp-invalid-operation+ [ -1.0 ] [ fsqrt ] test-fp-exception-compiled unit-test
|
{ t } +fp-invalid-operation+ [ -1.0 ] [ fsqrt ] test-fp-exception-compiled unit-test
|
||||||
|
|
||||||
[
|
{
|
||||||
0x3fd5,5555,5555,5555
|
0x3fd5,5555,5555,5555
|
||||||
0x3fc9,9999,9999,999a
|
0x3fc9,9999,9999,999a
|
||||||
0xbfc9,9999,9999,999a
|
0xbfc9,9999,9999,999a
|
||||||
0xbfd5,5555,5555,5555
|
0xbfd5,5555,5555,5555
|
||||||
] [
|
} [
|
||||||
+round-nearest+ [
|
+round-nearest+ [
|
||||||
1.0 3.0 /f double>bits
|
1.0 3.0 /f double>bits
|
||||||
1.0 5.0 /f double>bits
|
1.0 5.0 /f double>bits
|
||||||
|
@ -55,12 +55,12 @@ os linux? cpu x86.64? and [
|
||||||
] with-rounding-mode
|
] with-rounding-mode
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
{
|
||||||
0x3fd5,5555,5555,5555
|
0x3fd5,5555,5555,5555
|
||||||
0x3fc9,9999,9999,9999
|
0x3fc9,9999,9999,9999
|
||||||
0xbfc9,9999,9999,999a
|
0xbfc9,9999,9999,999a
|
||||||
0xbfd5,5555,5555,5556
|
0xbfd5,5555,5555,5556
|
||||||
] [
|
} [
|
||||||
+round-down+ [
|
+round-down+ [
|
||||||
1.0 3.0 /f double>bits
|
1.0 3.0 /f double>bits
|
||||||
1.0 5.0 /f double>bits
|
1.0 5.0 /f double>bits
|
||||||
|
@ -69,12 +69,12 @@ os linux? cpu x86.64? and [
|
||||||
] with-rounding-mode
|
] with-rounding-mode
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
{
|
||||||
0x3fd5,5555,5555,5556
|
0x3fd5,5555,5555,5556
|
||||||
0x3fc9,9999,9999,999a
|
0x3fc9,9999,9999,999a
|
||||||
0xbfc9,9999,9999,9999
|
0xbfc9,9999,9999,9999
|
||||||
0xbfd5,5555,5555,5555
|
0xbfd5,5555,5555,5555
|
||||||
] [
|
} [
|
||||||
+round-up+ [
|
+round-up+ [
|
||||||
1.0 3.0 /f double>bits
|
1.0 3.0 /f double>bits
|
||||||
1.0 5.0 /f double>bits
|
1.0 5.0 /f double>bits
|
||||||
|
@ -83,12 +83,12 @@ os linux? cpu x86.64? and [
|
||||||
] with-rounding-mode
|
] with-rounding-mode
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
{
|
||||||
0x3fd5,5555,5555,5555
|
0x3fd5,5555,5555,5555
|
||||||
0x3fc9,9999,9999,9999
|
0x3fc9,9999,9999,9999
|
||||||
0xbfc9,9999,9999,9999
|
0xbfc9,9999,9999,9999
|
||||||
0xbfd5,5555,5555,5555
|
0xbfd5,5555,5555,5555
|
||||||
] [
|
} [
|
||||||
+round-zero+ [
|
+round-zero+ [
|
||||||
1.0 3.0 /f double>bits
|
1.0 3.0 /f double>bits
|
||||||
1.0 5.0 /f double>bits
|
1.0 5.0 /f double>bits
|
||||||
|
@ -98,12 +98,12 @@ os linux? cpu x86.64? and [
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
! ensure rounding mode is restored to +round-nearest+
|
! ensure rounding mode is restored to +round-nearest+
|
||||||
[
|
{
|
||||||
0x3fd5,5555,5555,5555
|
0x3fd5,5555,5555,5555
|
||||||
0x3fc9,9999,9999,999a
|
0x3fc9,9999,9999,999a
|
||||||
0xbfc9,9999,9999,999a
|
0xbfc9,9999,9999,999a
|
||||||
0xbfd5,5555,5555,5555
|
0xbfd5,5555,5555,5555
|
||||||
] [
|
} [
|
||||||
1.0 3.0 /f double>bits
|
1.0 3.0 /f double>bits
|
||||||
1.0 5.0 /f double>bits
|
1.0 5.0 /f double>bits
|
||||||
-1.0 5.0 /f double>bits
|
-1.0 5.0 /f double>bits
|
||||||
|
@ -181,14 +181,14 @@ os linux? cpu x86.64? and [
|
||||||
] when
|
] when
|
||||||
|
|
||||||
! Ensure traps get cleared
|
! Ensure traps get cleared
|
||||||
[ 1/0. ] [ 1.0 0.0 /f ] unit-test
|
{ 1/0. } [ 1.0 0.0 /f ] unit-test
|
||||||
|
|
||||||
! Ensure state is back to normal
|
! Ensure state is back to normal
|
||||||
[ +round-nearest+ ] [ rounding-mode ] unit-test
|
{ +round-nearest+ } [ rounding-mode ] unit-test
|
||||||
[ +denormal-keep+ ] [ denormal-mode ] unit-test
|
{ +denormal-keep+ } [ denormal-mode ] unit-test
|
||||||
[ { } ] [ fp-traps ] unit-test
|
{ { } } [ fp-traps ] unit-test
|
||||||
|
|
||||||
[ ] [
|
{ } [
|
||||||
all-fp-exceptions [ compact-gc ] with-fp-traps
|
all-fp-exceptions [ compact-gc ] with-fp-traps
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue