Skip to content

Commit

Permalink
Expand test for c99-complex.c
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz committed Jan 15, 2020
1 parent 9a62a24 commit f6cce92
Showing 1 changed file with 213 additions and 4 deletions.
217 changes: 213 additions & 4 deletions test/small1/c99-complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@
#include <tgmath.h>
#include "testharness.h"

void forlong() {
long double complex z1 = 1.0il + 1;
printf("I * I = %.1Lf%+.1Lfi\n", creal(z1), cimag(z1));

long double complex z2 = pow(_Complex_I, 2); // imaginary unit squared
printf("pow(I, 2) = %.1Lf%+.1Lfi\n", creal(z2), cimag(z2));

double long PI = acos(-1);
double long complex z3 = exp(I * PI); // Euler's formula
printf("exp(I*PI) = %.1Lf%+.1Lfi\n", creal(z3), cimag(z3));

double long complex z4 = 1+2*I, z5 = 1-2*I; // conjugates
printf("(1+2i)*(1-2i) = %.Lf%+.Lfi\n", creal(z4*z5), cimag(z4*z5));
}

int main(void)
{
double complex z1 = 1.0iF + 0.5; // imaginary unit squared
printf("I * I = %.1f%+.1fi\n", creal(z1), cimag(z1));
double complex x1 = 1.0iF + 0.5;

double d = creal(z1);
double d = creal(x1);

if(d != 0.5)
E(1);

double complex z2 = pow(I, 2); // imaginary unit squared
double complex z1 = 1.0iF + 1;
printf("I * I = %.1f%+.1fi\n", creal(z1), cimag(z1));

double complex z2 = pow(_Complex_I, 2); // imaginary unit squared
printf("pow(I, 2) = %.1f%+.1fi\n", creal(z2), cimag(z2));

double PI = acos(-1);
Expand All @@ -22,4 +39,196 @@ int main(void)

double complex z4 = 1+2*I, z5 = 1-2*I; // conjugates
printf("(1+2i)*(1-2i) = %.1f%+.1fi\n", creal(z4*z5), cimag(z4*z5));

forlong();
return 0;
}

void parsedebug() {
__real__ (1.0iF);
__real__ (2);
0 + __real__(2);
__real__(2) + 0;
(sizeof (__real__ (1.0iF) + __real__ (2)) > sizeof (double) && __builtin_classify_type (__real__ (1.0iF) + __real__ (2)) == 8);


(__extension__ ((sizeof (__real__ (1.0iF) + __real__ (2)) > sizeof (double) && __builtin_classify_type (__real__ (

1.0iF

) + __real__ (

2

)) == 8) ? ((__builtin_classify_type ((

1.0iF
) + (

2

)) != 9) ? (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(

1.0iF

))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) powl (
1.0iF
,
2
) : (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
1.0iF
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) cpowl (
1.0iF
,
2
)) : (sizeof (+__real__ (
1.0iF
)) == sizeof (double) || sizeof (+__real__ (
2
)) == sizeof (double) || __builtin_classify_type (__real__ (
1.0iF
)) != 8 || __builtin_classify_type (__real__ (
2
)) != 8) ? ((__builtin_classify_type ((
1.0iF
) + (
2
)) != 9) ? (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
1.0iF
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) pow (
1.0iF
,
2
) : (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
1.0iF
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) cpow (
1.0iF
,
2
)) : ((__builtin_classify_type ((
1.0iF
) + (
2
)) != 9) ? (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
1.0iF
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) powf (
1.0iF
,
2
) : (__typeof ((__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
1.0iF
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
1.0iF
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
1.0iF
))) 0)) == 1))))) 0)) 0))) 0 + (__typeof__ (*(0 ? (__typeof__ (0 ? (__typeof__ ((__typeof__ (+(
2
))) 0) *) 0 : (void *) (!((__builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 8))))) 0 : (__typeof__ (0 ? (__typeof__ (0 ? (double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 1))))) 0 : (__typeof__ (0 ? (_Complex double *) 0 : (void *) (!((__builtin_classify_type ((__typeof__ (+(
2
))) 0) == 9 && __builtin_classify_type (__real__ ((__typeof__ (+(
2
))) 0)) == 1))))) 0)) 0))) 0)) cpowf (
1.0iF
,
2
))))
;
}

0 comments on commit f6cce92

Please sign in to comment.