This is a maintenance fork
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
3.7 KiB

  1. #include "third_party/chibicc/test/test.h"
  2. float g40 = 1.5;
  3. double g41 = 0.0 ? 55 : (0, 1 + 1 * 5.0 / 2 * (double)2 * (int)2.0);
  4. int main(int argc, char *argv[]) {
  5. ASSERT(10, ({
  6. enum { ten = 1 + 2 + 3 + 4 };
  7. ten;
  8. }));
  9. ASSERT(1, ({
  10. int i = 0;
  11. switch (3) {
  12. case 5 - 2 + 0 * 3:
  13. i++;
  14. }
  15. i;
  16. }));
  17. ASSERT(8, ({
  18. int x[1 + 1];
  19. sizeof(x);
  20. }));
  21. ASSERT(6, ({
  22. char x[8 - 2];
  23. sizeof(x);
  24. }));
  25. ASSERT(6, ({
  26. char x[2 * 3];
  27. sizeof(x);
  28. }));
  29. ASSERT(3, ({
  30. char x[12 / 4];
  31. sizeof(x);
  32. }));
  33. ASSERT(2, ({
  34. char x[12 % 10];
  35. sizeof(x);
  36. }));
  37. ASSERT(0b100, ({
  38. char x[0b110 & 0b101];
  39. sizeof(x);
  40. }));
  41. ASSERT(0b111, ({
  42. char x[0b110 | 0b101];
  43. sizeof(x);
  44. }));
  45. ASSERT(0b110, ({
  46. char x[0b111 ^ 0b001];
  47. sizeof(x);
  48. }));
  49. ASSERT(4, ({
  50. char x[1 << 2];
  51. sizeof(x);
  52. }));
  53. ASSERT(2, ({
  54. char x[4 >> 1];
  55. sizeof(x);
  56. }));
  57. ASSERT(2, ({
  58. char x[(1 == 1) + 1];
  59. sizeof(x);
  60. }));
  61. ASSERT(1, ({
  62. char x[(1 != 1) + 1];
  63. sizeof(x);
  64. }));
  65. ASSERT(1, ({
  66. char x[(1 < 1) + 1];
  67. sizeof(x);
  68. }));
  69. ASSERT(2, ({
  70. char x[(1 <= 1) + 1];
  71. sizeof(x);
  72. }));
  73. ASSERT(2, ({
  74. char x[1 ? 2 : 3];
  75. sizeof(x);
  76. }));
  77. ASSERT(3, ({
  78. char x[0 ? 2 : 3];
  79. sizeof(x);
  80. }));
  81. ASSERT(3, ({
  82. char x[(1, 3)];
  83. sizeof(x);
  84. }));
  85. ASSERT(2, ({
  86. char x[!0 + 1];
  87. sizeof(x);
  88. }));
  89. ASSERT(1, ({
  90. char x[!1 + 1];
  91. sizeof(x);
  92. }));
  93. ASSERT(2, ({
  94. char x[~-3];
  95. sizeof(x);
  96. }));
  97. ASSERT(2, ({
  98. char x[(5 || 6) + 1];
  99. sizeof(x);
  100. }));
  101. ASSERT(1, ({
  102. char x[(0 || 0) + 1];
  103. sizeof(x);
  104. }));
  105. ASSERT(2, ({
  106. char x[(1 && 1) + 1];
  107. sizeof(x);
  108. }));
  109. ASSERT(1, ({
  110. char x[(1 && 0) + 1];
  111. sizeof(x);
  112. }));
  113. ASSERT(3, ({
  114. char x[(int)3];
  115. sizeof(x);
  116. }));
  117. ASSERT(15, ({
  118. char x[(char)0xffffff0f];
  119. sizeof(x);
  120. }));
  121. ASSERT(0x10f, ({
  122. char x[(short)0xffff010f];
  123. sizeof(x);
  124. }));
  125. ASSERT(4, ({
  126. char x[(int)0xfffffffffff + 5];
  127. sizeof(x);
  128. }));
  129. ASSERT(8, ({
  130. char x[(int *)0 + 2];
  131. sizeof(x);
  132. }));
  133. ASSERT(12, ({
  134. char x[(int *)16 - 1];
  135. sizeof(x);
  136. }));
  137. ASSERT(3, ({
  138. char x[(int *)16 - (int *)4];
  139. sizeof(x);
  140. }));
  141. ASSERT(4, ({
  142. char x[(-1 >> 31) + 5];
  143. sizeof(x);
  144. }));
  145. ASSERT(255, ({
  146. char x[(unsigned char)0xffffffff];
  147. sizeof(x);
  148. }));
  149. ASSERT(0x800f, ({
  150. char x[(unsigned short)0xffff800f];
  151. sizeof(x);
  152. }));
  153. ASSERT(1, ({
  154. char x[(unsigned int)0xfffffffffff >> 31];
  155. sizeof(x);
  156. }));
  157. ASSERT(1, ({
  158. char x[(long)-1 / ((long)1 << 62) + 1];
  159. sizeof(x);
  160. }));
  161. ASSERT(4, ({
  162. char x[(unsigned long)-1 / ((long)1 << 62) + 1];
  163. sizeof(x);
  164. }));
  165. ASSERT(1, ({
  166. char x[(unsigned)1 < -1];
  167. sizeof(x);
  168. }));
  169. ASSERT(1, ({
  170. char x[(unsigned)1 <= -1];
  171. sizeof(x);
  172. }));
  173. ASSERT(1, g40 == 1.5);
  174. ASSERT(1, g41 == 11);
  175. }