tcalext.pp 20 KB

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