tcalext.pp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. { %KNOWNRUNERROR=2,i386 long double array problem }
  2. {****************************************************************}
  3. { CODE GENERATOR TEST PROGRAM }
  4. {****************************************************************}
  5. { NODE TESTED : secondcalln() }
  6. {****************************************************************}
  7. { PRE-REQUISITES: secondload() }
  8. { secondassign() }
  9. { secondcalln() }
  10. { secondadd() }
  11. { secondtypeconv() }
  12. {****************************************************************}
  13. { DEFINES: }
  14. {****************************************************************}
  15. { REMARKS: This tests a subset of the secondcalln() , it }
  16. { verifies the usage of external cdecl }
  17. { modules compiled with C compilers. }
  18. {****************************************************************}
  19. {$ifndef USE_PASCAL_OBJECT}
  20. {$MODE OBJFPC}
  21. {$STATIC ON}
  22. {$R+}
  23. uses strings;
  24. {$L ctest.o}
  25. {$endif USE_PASCAL_OBJECT}
  26. { Use C alignment of records }
  27. {$PACKRECORDS C}
  28. const
  29. RESULT_U8BIT = $55;
  30. RESULT_U16BIT = $500F;
  31. RESULT_U32BIT = $500F0000;
  32. RESULT_U64BIT = $1BCDABCD;
  33. RESULT_S16BIT = -12;
  34. RESULT_S32BIT = -120;
  35. RESULT_S64BIT = -12000;
  36. RESULT_FLOAT = 14.54;
  37. RESULT_DOUBLE = 15.54;
  38. RESULT_LONGDOUBLE = 16.54;
  39. RESULT_PCHAR = 'Hello world';
  40. type
  41. _1byte_ = record
  42. u8 : byte;
  43. end;
  44. _3byte_ = record
  45. u8 : byte;
  46. u16 : word;
  47. end;
  48. _3byte_s = record
  49. u16 : word;
  50. w8 : byte;
  51. end;
  52. _5byte_ = record
  53. u8 : byte;
  54. u32 : cardinal;
  55. end;
  56. _7byte_ = record
  57. u8: byte;
  58. s64: int64;
  59. u16: word;
  60. end;
  61. byte_array = array [0..1] of byte;
  62. word_array = array [0..1] of word;
  63. cardinal_array = array [0..1] of cardinal;
  64. qword_array = array [0..1] of qword;
  65. smallint_array = array [0..1] of smallint;
  66. longint_array = array [0..1] of longint;
  67. int64_array = array [0..1] of int64;
  68. single_array = array [0..1] of single;
  69. double_array = array [0..1] of double;
  70. extended_array = array [0..1] of extended;
  71. { simple parameter passing }
  72. procedure test_param_u8(x: byte); cdecl; external;
  73. procedure test_param_u16(x : word); cdecl; external;
  74. procedure test_param_u32(x: cardinal); cdecl; external;
  75. procedure test_param_u64(x: qword); cdecl; external;
  76. procedure test_param_s16(x : smallint); cdecl; external;
  77. procedure test_param_s32(x: longint); cdecl; external;
  78. procedure test_param_s64(x: int64); cdecl; external;
  79. procedure test_param_float(x : single); cdecl; external;
  80. procedure test_param_double(x: double); cdecl; external;
  81. procedure test_param_longdouble(x: extended); cdecl; external;
  82. procedure test_param_var_u8(var x: byte); cdecl; external;
  83. { array parameter passing }
  84. procedure test_array_param_u8(x: byte_array); cdecl; external;
  85. procedure test_array_param_u16(x : word_array); cdecl; external;
  86. procedure test_array_param_u32(x: cardinal_array); cdecl; external;
  87. procedure test_array_param_u64(x: qword_array); cdecl; external;
  88. procedure test_array_param_s16(x :smallint_array); cdecl; external;
  89. procedure test_array_param_s32(x: longint_array); cdecl; external;
  90. procedure test_array_param_s64(x: int64_array); cdecl; external;
  91. procedure test_array_param_float(x : single_array); cdecl; external;
  92. procedure test_array_param_double(x: double_array); cdecl; external;
  93. procedure test_array_param_longdouble(x: extended_array); cdecl; external;
  94. { mixed parameter passing }
  95. procedure test_param_mixed_u16(z: byte; x : word; y :byte); cdecl; external;
  96. procedure test_param_mixed_u32(z: byte; x: cardinal; y: byte); cdecl; external;
  97. procedure test_param_mixed_s64(z: byte; x: int64; y: byte); cdecl; external;
  98. procedure test_param_mixed_float(x: single; y: byte); cdecl; external;
  99. procedure test_param_mixed_double(x: double; y: byte); cdecl; external;
  100. procedure test_param_mixed_long_double(x: extended; y: byte); cdecl; external;
  101. procedure test_param_mixed_var_u8(var x: byte;y:byte); cdecl; external;
  102. { structure parameter testing }
  103. procedure test_param_struct_tiny(buffer : _1BYTE_); cdecl; external;
  104. procedure test_param_struct_small(buffer : _3BYTE_); cdecl; external;
  105. procedure test_param_struct_small_s(buffer : _3BYTE_S); cdecl; external;
  106. procedure test_param_struct_medium(buffer : _5BYTE_); cdecl; external;
  107. procedure test_param_struct_large(buffer : _7BYTE_); cdecl; external;
  108. { mixed with structure parameter testing }
  109. procedure test_param_mixed_struct_tiny(buffer : _1BYTE_; y :byte); cdecl; external;
  110. procedure test_param_mixed_struct_small(buffer : _3BYTE_; y :byte); cdecl; external;
  111. procedure test_param_mixed_struct_small_s(buffer : _3BYTE_S; y :byte); cdecl; external;
  112. procedure test_param_mixed_struct_medium(buffer : _5BYTE_; y :byte); cdecl; external;
  113. procedure test_param_mixed_struct_large(buffer : _7BYTE_; y :byte); cdecl; external;
  114. { function result value testing }
  115. function test_function_u8: byte; cdecl; external;
  116. function test_function_u16: word; cdecl; external;
  117. function test_function_u32: cardinal; cdecl; external;
  118. function test_function_u64: qword; cdecl; external;
  119. function test_function_s16: smallint; cdecl; external;
  120. function test_function_s32: longint; cdecl; external;
  121. function test_function_s64: int64; cdecl; external;
  122. function test_function_pchar: pchar; cdecl; external;
  123. function test_function_float : single; cdecl; external;
  124. function test_function_double : double; cdecl; external;
  125. function test_function_longdouble: extended; cdecl; external;
  126. function test_function_tiny_struct : _1byte_; cdecl; external;
  127. function test_function_small_struct : _3byte_; cdecl; external;
  128. function test_function_small_struct_s : _3byte_s; cdecl; external;
  129. function test_function_medium_struct : _5byte_; cdecl; external;
  130. function test_function_struct : _7byte_; cdecl; external;
  131. var
  132. global_u8bit : byte; cvar; external;
  133. global_u16bit : word; cvar; external;
  134. global_u32bit : cardinal; cvar;external;
  135. global_u64bit : qword; cvar; external;
  136. global_s16bit : smallint; cvar; external;
  137. global_s32bit : longint; cvar;external;
  138. global_s64bit : int64; cvar; external;
  139. global_float : single; cvar;external;
  140. global_double : double; cvar;external;
  141. global_long_double : extended; cvar; external;
  142. value_u8bit : byte;
  143. value_s16bit : smallint;
  144. value_s32bit : longint;
  145. value_s64bit : int64;
  146. value_u16bit : word;
  147. value_u32bit : cardinal;
  148. value_u64bit : qword;
  149. value_float : single;
  150. value_double : double;
  151. value_long_double : extended;
  152. array_u8bit : array [0..1] of byte;
  153. array_s16bit : array [0..1] of smallint;
  154. array_s32bit : array [0..1] of longint;
  155. array_s64bit : array [0..1] of int64;
  156. array_u16bit : array [0..1] of word;
  157. array_u32bit : array [0..1] of cardinal;
  158. array_u64bit : array [0..1] of qword;
  159. array_float : array [0..1] of single;
  160. array_double : array [0..1] of double;
  161. array_long_double : array [0..1] of extended;
  162. procedure clear_globals;
  163. begin
  164. global_u8bit := 0;
  165. global_u16bit := 0;
  166. global_u32bit := 0;
  167. global_u64bit := 0;
  168. global_s16bit := 0;
  169. global_s32bit := 0;
  170. global_s64bit := 0;
  171. global_float := 0.0;
  172. global_double := 0.0;
  173. global_long_double := 0.0;
  174. end;
  175. procedure clear_values;
  176. begin
  177. value_u8bit := 0;
  178. value_u16bit := 0;
  179. value_u32bit := 0;
  180. value_u64bit := 0;
  181. value_s16bit := 0;
  182. value_s32bit := 0;
  183. value_s64bit := 0;
  184. value_float := 0.0;
  185. value_double := 0.0;
  186. value_long_double := 0.0;
  187. end;
  188. const
  189. has_errors : boolean = false;
  190. known_bug_about_extended_array_present : boolean = false;
  191. procedure fail;
  192. begin
  193. WriteLn('Failed!');
  194. has_errors:=true;
  195. end;
  196. var failed : boolean;
  197. tinystruct : _1BYTE_;
  198. smallstruct : _3BYTE_;
  199. smallstruct_s : _3BYTE_S;
  200. mediumstruct : _5BYTE_;
  201. bigstruct : _7BYTE_;
  202. pc: pchar;
  203. begin
  204. Write('External simple parameter testing...');
  205. failed := false;
  206. clear_values;
  207. clear_globals;
  208. value_u8bit := RESULT_U8BIT;
  209. test_param_u8(value_u8bit);
  210. if global_u8bit <> RESULT_U8BIT then
  211. failed := true;
  212. clear_values;
  213. clear_globals;
  214. value_u16bit := RESULT_U16BIT;
  215. test_param_u16(value_u16bit);
  216. if global_u16bit <> RESULT_U16BIT then
  217. failed := true;
  218. clear_values;
  219. clear_globals;
  220. value_u32bit := RESULT_U32BIT;
  221. test_param_u32(value_u32bit);
  222. if global_u32bit <> RESULT_U32BIT then
  223. failed := true;
  224. clear_values;
  225. clear_globals;
  226. value_u64bit := RESULT_U64BIT;
  227. test_param_u64(value_u64bit);
  228. if global_u64bit <> RESULT_U64BIT then
  229. failed := true;
  230. clear_values;
  231. clear_globals;
  232. value_s16bit := RESULT_S16BIT;
  233. test_param_s16(value_s16bit);
  234. if global_s16bit <> RESULT_S16BIT then
  235. failed := true;
  236. clear_values;
  237. clear_globals;
  238. value_s32bit := RESULT_S32BIT;
  239. test_param_s32(value_s32bit);
  240. if global_s32bit <> RESULT_S32BIT then
  241. failed := true;
  242. clear_values;
  243. clear_globals;
  244. value_s64bit := RESULT_S64BIT;
  245. test_param_s64(value_s64bit);
  246. if global_s64bit <> RESULT_S64BIT then
  247. failed := true;
  248. clear_values;
  249. clear_globals;
  250. value_float := RESULT_FLOAT;
  251. test_param_float(value_float);
  252. if trunc(global_float) <> trunc(RESULT_FLOAT) then
  253. failed := true;
  254. clear_values;
  255. clear_globals;
  256. value_double := RESULT_DOUBLE;
  257. test_param_double(value_double);
  258. if trunc(global_double) <> trunc(RESULT_DOUBLE) then
  259. failed := true;
  260. clear_values;
  261. clear_globals;
  262. value_long_double := RESULT_LONGDOUBLE;
  263. test_param_longdouble(value_long_double);
  264. if trunc(global_long_double) <> trunc(RESULT_LONGDOUBLE) then
  265. failed := true;
  266. { var parameter testing }
  267. clear_values;
  268. clear_globals;
  269. test_param_var_u8(value_u8bit);
  270. if value_u8bit <> RESULT_U8BIT then
  271. failed := true;
  272. If failed then
  273. fail
  274. else
  275. WriteLn('Passed!');
  276. Write('External array parameter testing...');
  277. failed := false;
  278. clear_values;
  279. clear_globals;
  280. array_u8bit[1] := RESULT_U8BIT;
  281. test_array_param_u8(array_u8bit);
  282. if global_u8bit <> RESULT_U8BIT then
  283. failed := true;
  284. clear_values;
  285. clear_globals;
  286. array_u16bit[1] := RESULT_U16BIT;
  287. test_array_param_u16(array_u16bit);
  288. if global_u16bit <> RESULT_U16BIT then
  289. failed := true;
  290. clear_values;
  291. clear_globals;
  292. array_u32bit[1] := RESULT_U32BIT;
  293. test_array_param_u32(array_u32bit);
  294. if global_u32bit <> RESULT_U32BIT then
  295. failed := true;
  296. clear_values;
  297. clear_globals;
  298. array_u64bit[1] := RESULT_U64BIT;
  299. test_array_param_u64(array_u64bit);
  300. if global_u64bit <> RESULT_U64BIT then
  301. failed := true;
  302. clear_values;
  303. clear_globals;
  304. array_s16bit[1] := RESULT_S16BIT;
  305. test_array_param_s16(array_s16bit);
  306. if global_s16bit <> RESULT_S16BIT then
  307. failed := true;
  308. clear_values;
  309. clear_globals;
  310. array_s32bit[1] := RESULT_S32BIT;
  311. test_array_param_s32(array_s32bit);
  312. if global_s32bit <> RESULT_S32BIT then
  313. failed := true;
  314. clear_values;
  315. clear_globals;
  316. array_s64bit[1] := RESULT_S64BIT;
  317. test_array_param_s64(array_s64bit);
  318. if global_s64bit <> RESULT_S64BIT then
  319. failed := true;
  320. clear_values;
  321. clear_globals;
  322. array_float[1] := RESULT_FLOAT;
  323. test_array_param_float(array_float);
  324. if trunc(global_float) <> trunc(RESULT_FLOAT) then
  325. failed := true;
  326. clear_values;
  327. clear_globals;
  328. array_double[1] := RESULT_DOUBLE;
  329. test_array_param_double(array_double);
  330. if trunc(global_double) <> trunc(RESULT_DOUBLE) then
  331. failed := true;
  332. clear_values;
  333. clear_globals;
  334. array_long_double[1] := RESULT_LONGDOUBLE;
  335. test_array_param_longdouble(array_long_double);
  336. if trunc(global_long_double) <> trunc(RESULT_LONGDOUBLE) then
  337. begin
  338. if sizeof(global_long_double)=10 then
  339. begin
  340. known_bug_about_extended_array_present:=true;
  341. end
  342. else
  343. failed := true;
  344. end;
  345. If failed then
  346. fail
  347. else
  348. WriteLn('Passed!');
  349. Write('External mixed parameter testing...');
  350. failed := false;
  351. clear_values;
  352. clear_globals;
  353. test_param_mixed_var_u8(value_u8bit,RESULT_U8BIT);
  354. if value_u8bit <> RESULT_U8BIT then
  355. failed := true;
  356. if global_u8bit <> RESULT_U8BIT then
  357. failed := true;
  358. clear_values;
  359. clear_globals;
  360. value_u8bit := RESULT_U8BIT;
  361. value_u16bit := RESULT_U16BIT;
  362. test_param_mixed_u16(value_u8bit, value_u16bit, value_u8bit);
  363. if global_u16bit <> RESULT_U16BIT then
  364. failed := true;
  365. if global_u8bit <> RESULT_U8BIT then
  366. failed := true;
  367. clear_values;
  368. clear_globals;
  369. value_u8bit := RESULT_U8BIT;
  370. value_u32bit := RESULT_U32BIT;
  371. test_param_mixed_u32(value_u8bit, value_u32bit, value_u8bit);
  372. if global_u32bit <> RESULT_U32BIT then
  373. failed := true;
  374. if global_u8bit <> RESULT_U8BIT then
  375. failed := true;
  376. clear_values;
  377. clear_globals;
  378. value_u8bit := RESULT_U8BIT;
  379. value_s64bit := RESULT_S64BIT;
  380. test_param_mixed_s64(value_u8bit, value_s64bit, value_u8bit);
  381. if global_s64bit <> RESULT_S64BIT then
  382. failed := true;
  383. if global_u8bit <> RESULT_U8BIT then
  384. failed := true;
  385. clear_values;
  386. clear_globals;
  387. value_u8bit := RESULT_U8BIT;
  388. value_float := RESULT_FLOAT;
  389. test_param_mixed_float(value_float, value_u8bit);
  390. if global_float <> value_float then
  391. failed := true;
  392. if global_u8bit <> RESULT_U8BIT then
  393. failed := true;
  394. If failed then
  395. fail
  396. else
  397. WriteLn('Passed!');
  398. Write('External mixed parameter testing with floating values...');
  399. clear_values;
  400. clear_globals;
  401. value_u8bit := RESULT_U8BIT;
  402. value_double := RESULT_DOUBLE;
  403. test_param_mixed_double(value_double, value_u8bit);
  404. if global_double <> value_double then
  405. failed := true;
  406. if global_u8bit <> RESULT_U8BIT then
  407. failed := true;
  408. clear_values;
  409. clear_globals;
  410. value_u8bit := RESULT_U8BIT;
  411. value_long_double := RESULT_LONGDOUBLE;
  412. test_param_mixed_long_double(value_long_double, value_u8bit);
  413. if global_long_double <> value_long_double then
  414. failed := true;
  415. if global_u8bit <> RESULT_U8BIT then
  416. failed := true;
  417. If failed then
  418. fail
  419. else
  420. WriteLn('Passed!');
  421. Write('External struct parameter testing...');
  422. failed := false;
  423. clear_values;
  424. clear_globals;
  425. tinystruct.u8 := RESULT_U8BIT;
  426. test_param_struct_tiny(tinystruct);
  427. if global_u8bit <> RESULT_U8BIT then
  428. failed := true;
  429. clear_values;
  430. clear_globals;
  431. smallstruct.u8 := RESULT_U8BIT;
  432. smallstruct.u16 := RESULT_u16BIT;
  433. test_param_struct_small(smallstruct);
  434. if global_u16bit <> RESULT_U16BIT then
  435. failed := true;
  436. if global_u8bit <> RESULT_U8BIT then
  437. failed := true;
  438. clear_values;
  439. clear_globals;
  440. smallstruct_s.u16 := RESULT_U16BIT;
  441. smallstruct_s.w8 := RESULT_U8BIT;
  442. test_param_struct_small_s(smallstruct_s);
  443. if global_u16bit <> RESULT_U16BIT then
  444. failed := true;
  445. if global_u8bit <> RESULT_U8BIT then
  446. failed := true;
  447. clear_values;
  448. clear_globals;
  449. mediumstruct.u8 := RESULT_U8BIT;
  450. mediumstruct.u32 := RESULT_U32BIT;
  451. test_param_struct_medium(mediumstruct);
  452. if global_u32bit <> RESULT_U32BIT then
  453. failed := true;
  454. if global_u8bit <> RESULT_U8BIT then
  455. failed := true;
  456. clear_values;
  457. clear_globals;
  458. bigstruct.u8 := RESULT_U8BIT;
  459. bigstruct.u16 := RESULT_U16BIT;
  460. bigstruct.s64 := RESULT_S64BIT;
  461. test_param_struct_large(bigstruct);
  462. if global_s64bit <> RESULT_S64BIT then
  463. failed := true;
  464. if global_u16bit <> RESULT_U16BIT then
  465. failed := true;
  466. if global_u8bit <> RESULT_U8BIT then
  467. failed := true;
  468. If failed then
  469. fail
  470. else
  471. WriteLn('Passed!');
  472. Write('External mixed struct/byte parameter testing...');
  473. failed := false;
  474. clear_values;
  475. clear_globals;
  476. test_param_mixed_struct_tiny(tinystruct,RESULT_U8BIT);
  477. if global_u8bit <> RESULT_U8BIT then
  478. failed := true;
  479. clear_values;
  480. clear_globals;
  481. smallstruct.u16 := RESULT_u16BIT;
  482. test_param_mixed_struct_small(smallstruct,RESULT_U8BIT);
  483. if global_u16bit <> RESULT_U16BIT then
  484. failed := true;
  485. if global_u8bit <> RESULT_U8BIT then
  486. failed := true;
  487. clear_values;
  488. clear_globals;
  489. smallstruct_s.u16 := RESULT_U16BIT;
  490. test_param_mixed_struct_small_s(smallstruct_s,RESULT_U8BIT);
  491. if global_u16bit <> RESULT_U16BIT then
  492. failed := true;
  493. if global_u8bit <> RESULT_U8BIT then
  494. failed := true;
  495. clear_values;
  496. clear_globals;
  497. mediumstruct.u32 := RESULT_U32BIT;
  498. test_param_mixed_struct_medium(mediumstruct,RESULT_U8BIT);
  499. if global_u32bit <> RESULT_U32BIT then
  500. failed := true;
  501. if global_u8bit <> RESULT_U8BIT then
  502. failed := true;
  503. clear_values;
  504. clear_globals;
  505. bigstruct.u16 := RESULT_U16BIT;
  506. bigstruct.s64 := RESULT_S64BIT;
  507. test_param_mixed_struct_large(bigstruct,RESULT_U8BIT);
  508. if global_s64bit <> RESULT_S64BIT then
  509. failed := true;
  510. if global_u16bit <> RESULT_U16BIT then
  511. failed := true;
  512. if global_u8bit <> RESULT_U8BIT then
  513. failed := true;
  514. If failed then
  515. fail
  516. else
  517. WriteLn('Passed!');
  518. Write('Integer function result testing...');
  519. failed := false;
  520. clear_values;
  521. clear_globals;
  522. value_u8bit := test_function_u8;
  523. if value_u8bit <> RESULT_U8BIT then
  524. failed := true;
  525. clear_values;
  526. clear_globals;
  527. value_u16bit := test_function_u16;
  528. if value_u16bit <> RESULT_U16BIT then
  529. failed := true;
  530. clear_values;
  531. clear_globals;
  532. value_u32bit := test_function_u32;
  533. if value_u32bit <> RESULT_U32BIT then
  534. failed := true;
  535. clear_values;
  536. clear_globals;
  537. value_u64bit := test_function_u64;
  538. if value_u64bit <> RESULT_U64BIT then
  539. failed := true;
  540. clear_values;
  541. clear_globals;
  542. value_s16bit := test_function_s16;
  543. if value_s16bit <> RESULT_S16BIT then
  544. failed := true;
  545. clear_values;
  546. clear_globals;
  547. value_s32bit := test_function_s32;
  548. if value_s32bit <> RESULT_S32BIT then
  549. failed := true;
  550. clear_values;
  551. clear_globals;
  552. value_s64bit := test_function_s64;
  553. if value_s64bit <> RESULT_S64BIT then
  554. failed := true;
  555. clear_values;
  556. clear_globals;
  557. If failed then
  558. fail
  559. else
  560. WriteLn('Passed!');
  561. Write('pchar function result testing...');
  562. failed := false;
  563. { verify if the contents both strings are equal }
  564. pc := test_function_pchar;
  565. if strcomp(pc, RESULT_PCHAR) <> 0 then
  566. failed := true;
  567. clear_values;
  568. clear_globals;
  569. If failed then
  570. fail
  571. else
  572. WriteLn('Passed!');
  573. Write('Real function result testing...');
  574. failed := false;
  575. value_float := test_function_float;
  576. if trunc(value_float) <> trunc(RESULT_FLOAT) then
  577. failed := true;
  578. clear_values;
  579. clear_globals;
  580. value_double := test_function_double;
  581. if trunc(value_double) <> trunc(RESULT_DOUBLE) then
  582. failed := true;
  583. clear_values;
  584. clear_globals;
  585. value_long_double := test_function_longdouble;
  586. if trunc(value_long_double) <> trunc(RESULT_LONGDOUBLE) then
  587. failed := true;
  588. clear_values;
  589. clear_globals;
  590. If failed then
  591. fail
  592. else
  593. WriteLn('Passed!');
  594. Write('Function result testing for struct...');
  595. tinystruct := test_function_tiny_struct;
  596. if tinystruct.u8 <> RESULT_U8BIT then
  597. failed := true;
  598. smallstruct := test_function_small_struct;
  599. if smallstruct.u8 <> RESULT_U8BIT then
  600. failed := true;
  601. if smallstruct.u16 <> RESULT_U16BIT then
  602. failed := true;
  603. smallstruct_s := test_function_small_struct_s;
  604. if smallstruct_s.u16 <> RESULT_U16BIT then
  605. failed := true;
  606. if smallstruct_s.w8 <> RESULT_U8BIT then
  607. failed := true;
  608. mediumstruct := test_function_medium_struct;
  609. if mediumstruct.u8 <> RESULT_U8BIT then
  610. failed := true;
  611. if mediumstruct.u32 <> RESULT_U32BIT then
  612. failed := true;
  613. bigstruct := test_function_struct;
  614. if bigstruct.u8 <> RESULT_U8BIT then
  615. failed := true;
  616. if bigstruct.s64 <> RESULT_S64BIT then
  617. failed := true;
  618. if bigstruct.u16 <> RESULT_U16BIT then
  619. failed := true;
  620. If failed then
  621. fail
  622. else
  623. WriteLn('Passed!');
  624. if known_bug_about_extended_array_present then
  625. begin
  626. writeln('extended size is incompatible with C');
  627. writeln('this will lead to failures if long doubles');
  628. writeln('are used as arrays of members of packed structures');
  629. { if no other error,
  630. then notify that we konw about this problem }
  631. if not has_errors then
  632. halt(2);
  633. end;
  634. if has_errors then
  635. Halt(1);
  636. end.
  637. {
  638. $Log$
  639. Revision 1.9 2002-11-18 16:48:00 pierre
  640. + use KNOWNRUNERROR for i386 long double problem
  641. Revision 1.8 2002/11/18 00:42:16 pierre
  642. + records with really 3 byte size tests added
  643. Revision 1.7 2002/11/17 21:46:17 peter
  644. * fixed
  645. Revision 1.6 2002/11/04 15:17:45 pierre
  646. * compatibility with C checks improved
  647. Revision 1.5 2002/09/07 15:40:51 peter
  648. * old logs removed and tabs fixed
  649. Revision 1.4 2002/08/25 19:28:07 peter
  650. * fixed long double typo that was using double instead of extended
  651. Revision 1.3 2002/05/04 16:56:54 carl
  652. + var parameter testing
  653. + function result testing
  654. + floating point testing
  655. Revision 1.2 2002/04/22 19:09:28 carl
  656. + added structure testing
  657. Revision 1.1 2002/04/13 21:03:43 carl
  658. + C module testing (unfinished)
  659. }