Mercurial > projects > dstress
changeset 1602:56d43974b468
Fix broken tests fvbommel pointed out in #2.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 06 Mar 2009 15:48:16 +0100 |
parents | 90bc51a580b7 |
children | 2031b04871b3 |
files | run/creal_13.d run/creal_14.d run/creal_15.d run/o/opDiv_09_A.d run/o/opDiv_09_B.d run/v/volatile_01_A.d run/v/volatile_01_B.d |
diffstat | 7 files changed, 76 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/run/creal_13.d Sun Jan 04 22:42:52 2009 +0100 +++ b/run/creal_13.d Fri Mar 06 15:48:16 2009 +0100 @@ -4,33 +4,30 @@ module dstress.run.creal_13; +bool isIdentical(real x, real y) +{ + long* x64 = cast(long*)&x; + long* y64 = cast(long*)&y; + ushort* x16 = cast(ushort*)&x + 4; + ushort* y16 = cast(ushort*)&y + 4; + return *x64 == *y64 && *x16 == *y16; +} + int main(){ creal a; creal b; - byte* X = cast(byte*)(cast(void*)&a); b = real.init + ireal.init; - byte* Y = cast(byte*)(cast(void*)&b); - - for(size_t i=0; i<a.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(a.re, b.re)); + assert(isIdentical(a.im, b.im)); real c; + real d=a.re; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(c, d)); d=a.im; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } - + assert(isIdentical(c, d)); + return 0; }
--- a/run/creal_14.d Sun Jan 04 22:42:52 2009 +0100 +++ b/run/creal_14.d Fri Mar 06 15:48:16 2009 +0100 @@ -4,33 +4,30 @@ module dstress.run.creal_14; +bool isIdentical(real x, real y) +{ + long* x64 = cast(long*)&x; + long* y64 = cast(long*)&y; + ushort* x16 = cast(ushort*)&x + 4; + ushort* y16 = cast(ushort*)&y + 4; + return *x64 == *y64 && *x16 == *y16; +} + int main(){ creal a = creal.infinity; creal b; - byte* X = cast(byte*)(cast(void*)&a); b = real.infinity + ireal.infinity; - byte* Y = cast(byte*)(cast(void*)&b); - - for(size_t i=0; i<a.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(a.re, b.re)); + assert(isIdentical(a.im, b.im)); real c = real.infinity; + real d=a.re; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(c, d)); d=a.im; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } - + assert(isIdentical(c, d)); + return 0; }
--- a/run/creal_15.d Sun Jan 04 22:42:52 2009 +0100 +++ b/run/creal_15.d Fri Mar 06 15:48:16 2009 +0100 @@ -4,33 +4,30 @@ module dstress.run.creal_15; +bool isIdentical(real x, real y) +{ + long* x64 = cast(long*)&x; + long* y64 = cast(long*)&y; + ushort* x16 = cast(ushort*)&x + 4; + ushort* y16 = cast(ushort*)&y + 4; + return *x64 == *y64 && *x16 == *y16; +} + int main(){ creal a = creal.nan; creal b; - byte* X = cast(byte*)(cast(void*)&a); b = real.nan + ireal.nan; - byte* Y = cast(byte*)(cast(void*)&b); - - for(size_t i=0; i<a.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(a.re, b.re)); + assert(isIdentical(a.im, b.im)); - real c= real.nan; + real c = real.nan; + real d=a.re; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(c, d)); d=a.im; - X = cast(byte*)(cast(void*)&c); - Y = cast(byte*)(cast(void*)&d); - for(size_t i=0; i<c.sizeof; i++){ - assert(X[i]==Y[i]); - } - + assert(isIdentical(c, d)); + return 0; }
--- a/run/o/opDiv_09_A.d Sun Jan 04 22:42:52 2009 +0100 +++ b/run/o/opDiv_09_A.d Fri Mar 06 15:48:16 2009 +0100 @@ -8,6 +8,15 @@ module dstress.run.o.opDiv_09_A; +bool isIdentical(real x, real y) +{ + long* x64 = cast(long*)&x; + long* y64 = cast(long*)&y; + ushort* x16 = cast(ushort*)&x + 4; + ushort* y16 = cast(ushort*)&y + 4; + return *x64 == *y64 && *x16 == *y16; +} + int main(){ real a = -1.0L / 0.0L; @@ -15,14 +24,9 @@ real c = 0.0L; real d; - byte* X = cast(byte*) (cast(void*) &a); + d = b/c; - d = b/c; - byte* Y = cast(byte*) (cast(void*) &d); - - for(int i=0; i<a.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(a, d)); return 0; }
--- a/run/o/opDiv_09_B.d Sun Jan 04 22:42:52 2009 +0100 +++ b/run/o/opDiv_09_B.d Fri Mar 06 15:48:16 2009 +0100 @@ -8,6 +8,15 @@ module dstress.run.o.opDiv_09_B; +bool isIdentical(real x, real y) +{ + long* x64 = cast(long*)&x; + long* y64 = cast(long*)&y; + ushort* x16 = cast(ushort*)&x + 4; + ushort* y16 = cast(ushort*)&y + 4; + return *x64 == *y64 && *x16 == *y16; +} + int main(){ real a = -1.0Li / 0.0Li; @@ -15,14 +24,9 @@ ireal c = 0.0Li; real d; - byte* X = cast(byte*) (cast(void*) &a); + d = b/c; - d = b/c; - byte* Y = cast(byte*) (cast(void*) &d); - - for(int i=0; i<a.sizeof; i++){ - assert(X[i]==Y[i]); - } + assert(isIdentical(a, d)); return 0; }