Use do_run_from_file() for test_i64_double
This commit is contained in:
Родитель
fe2422bc85
Коммит
5a1d1b688b
|
@ -0,0 +1,38 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef long long int64;
|
||||
#define JSDOUBLE_HI32_SIGNBIT 0x80000000
|
||||
|
||||
bool JSDOUBLE_IS_NEGZERO(double d)
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
unsigned int lo, hi;
|
||||
} s;
|
||||
double d;
|
||||
} x;
|
||||
if (d != 0)
|
||||
return false;
|
||||
x.d = d;
|
||||
return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0;
|
||||
}
|
||||
|
||||
bool JSINT64_IS_NEGZERO(int64 l)
|
||||
{
|
||||
union {
|
||||
int64 i;
|
||||
double d;
|
||||
} x;
|
||||
if (l != 0)
|
||||
return false;
|
||||
x.i = l;
|
||||
return x.d == -0;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
printf("*%d,%d,%d,%d*\n", JSDOUBLE_IS_NEGZERO(0), JSDOUBLE_IS_NEGZERO(-0), JSDOUBLE_IS_NEGZERO(-1), JSDOUBLE_IS_NEGZERO(+1));
|
||||
printf("*%d,%d,%d,%d*\n", JSINT64_IS_NEGZERO(0), JSINT64_IS_NEGZERO(-0), JSINT64_IS_NEGZERO(-1), JSINT64_IS_NEGZERO(+1));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*0,0,0,0*
|
||||
*1,1,0,0*
|
|
@ -285,50 +285,13 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
|
|||
|
||||
self.do_run_from_file(src, output)
|
||||
|
||||
|
||||
def test_i64_double(self):
|
||||
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
|
||||
|
||||
test_path = path_from_root('tests', 'core', 'test_i64_double')
|
||||
src, output = (test_path + s for s in ('.in', '.out'))
|
||||
|
||||
src = r'''
|
||||
#include <stdio.h>
|
||||
|
||||
typedef long long int64;
|
||||
#define JSDOUBLE_HI32_SIGNBIT 0x80000000
|
||||
|
||||
bool JSDOUBLE_IS_NEGZERO(double d)
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
unsigned int lo, hi;
|
||||
} s;
|
||||
double d;
|
||||
} x;
|
||||
if (d != 0)
|
||||
return false;
|
||||
x.d = d;
|
||||
return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0;
|
||||
}
|
||||
|
||||
bool JSINT64_IS_NEGZERO(int64 l)
|
||||
{
|
||||
union {
|
||||
int64 i;
|
||||
double d;
|
||||
} x;
|
||||
if (l != 0)
|
||||
return false;
|
||||
x.i = l;
|
||||
return x.d == -0;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
printf("*%d,%d,%d,%d*\n", JSDOUBLE_IS_NEGZERO(0), JSDOUBLE_IS_NEGZERO(-0), JSDOUBLE_IS_NEGZERO(-1), JSDOUBLE_IS_NEGZERO(+1));
|
||||
printf("*%d,%d,%d,%d*\n", JSINT64_IS_NEGZERO(0), JSINT64_IS_NEGZERO(-0), JSINT64_IS_NEGZERO(-1), JSINT64_IS_NEGZERO(+1));
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
self.do_run(src, '*0,0,0,0*\n*1,1,0,0*\n') # same as gcc
|
||||
self.do_run_from_file(src, output)
|
||||
|
||||
def test_i64_umul(self):
|
||||
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
|
||||
|
|
Загрузка…
Ссылка в новой задаче