struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2516.c
blob9b76ef2ab6775c7a6d34feab247f6b0bcfb34462
1 /** bug-2516.c
2 */
3 #include <testfwk.h>
4 #include <stdlib.h>
5 #include <math.h>
7 #pragma disable_warning 122
9 #if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) // Not enough memory
10 float gfa = 1.0 / 0.0;
11 float gfb = (-1.0) / 0.0;
12 float gfc = 0.0 / 0.0;
13 float gfd = 1.0;
15 static float sfa = 1.0 / 0.0;
16 static float sfb = (-1.0) / 0.0;
17 static float sfc = 0.0 / 0.0;
18 static float sfd = 1.0;
20 static float divTest(float a, float b)
22 return a / b;
24 #endif
26 void
27 testBug (void)
29 #if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) // Not enough memory
30 float lfa = 1.0 / 0.0;
31 float lfb = (-1.0) / 0.0;
32 float lfc = 0.0 / 0.0;
33 float lfd = 1.0;
35 ASSERT (isinf (gfa));
36 ASSERT (isinf (sfa));
37 ASSERT (isinf (lfa));
39 ASSERT (isinf (gfb));
40 ASSERT (isinf (sfb));
41 ASSERT (isinf (lfb));
43 ASSERT (isnan (gfc));
44 ASSERT (isnan (sfc));
45 ASSERT (isnan (lfc));
47 ASSERT (!isnan (gfd));
48 ASSERT (!isnan (sfd));
49 ASSERT (!isnan (lfd));
51 ASSERT (!isinf (gfd));
52 ASSERT (!isinf (sfd));
53 ASSERT (!isinf (lfd));
55 ASSERT (isinf (divTest (1.0, 0.0)));
56 ASSERT (isinf (divTest (-1.0, 0.0)));
57 ASSERT (isnan (divTest (0.0, 0.0)));
59 ASSERT (!isinf (divTest (1.0, 0.5)));
60 ASSERT (!isnan (divTest (1.0, 0.5)));
62 ASSERT (!isnan (divTest (3e38, 2e-38)));
63 ASSERT (isinf (divTest (3e38, 2e-38)));
64 #endif