tcalext.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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;
  23. {$L ctest.o}
  24. {$endif USE_PASCAL_OBJECT}
  25. { Use C alignment of records }
  26. {$PACKRECORDS C}
  27. const
  28. RESULT_U8BIT = $55;
  29. RESULT_U16BIT = $500F;
  30. RESULT_U32BIT = $500F0000;
  31. RESULT_U64BIT = $1BCDABCD;
  32. RESULT_S16BIT = -12;
  33. RESULT_S32BIT = -120;
  34. RESULT_S64BIT = -12000;
  35. RESULT_FLOAT = 14.54;
  36. RESULT_DOUBLE = 15.54;
  37. RESULT_LONGDOUBLE = 16.54;
  38. RESULT_PCHAR = 'Hello world';
  39. type
  40. _1byte_ = record
  41. u8 : byte;
  42. end;
  43. _3byte_ = record
  44. u8 : byte;
  45. u16 : word;
  46. end;
  47. _3byte_s = record
  48. u16 : word;
  49. w8 : byte;
  50. end;
  51. _5byte_ = record
  52. u8 : byte;
  53. u32 : cardinal;
  54. end;
  55. _7byte_ = record
  56. u8: byte;
  57. s64: int64;
  58. u16: word;
  59. end;
  60. byte_array = array [0..1] of byte;
  61. word_array = array [0..1] of word;
  62. cardinal_array = array [0..1] of cardinal;
  63. qword_array = array [0..1] of qword;
  64. smallint_array = array [0..1] of smallint;
  65. longint_array = array [0..1] of longint;
  66. int64_array = array [0..1] of int64;
  67. single_array = array [0..1] of single;
  68. double_array = array [0..1] of double;
  69. extended_array = array [0..1] of extended;
  70. { simple parameter passing }
  71. procedure test_param_u8(x: byte); cdecl; external;
  72. procedure test_param_u16(x : word); cdecl; external;
  73. procedure test_param_u32(x: cardinal); cdecl; external;
  74. procedure test_param_u64(x: qword); cdecl; external;
  75. procedure test_param_s16(x : smallint); cdecl; external;
  76. procedure test_param_s32(x: longint); cdecl; external;
  77. procedure test_param_s64(x: int64); cdecl; external;
  78. procedure test_param_float(x : single); cdecl; external;
  79. procedure test_param_double(x: double); cdecl; external;
  80. procedure test_param_longdouble(x: extended); cdecl; external;
  81. procedure test_param_var_u8(var x: byte); cdecl; external;
  82. { array parameter passing }
  83. procedure test_array_param_u8(x: byte_array); cdecl; external;
  84. procedure test_array_param_u16(x : word_array); cdecl; external;
  85. procedure test_array_param_u32(x: cardinal_array); cdecl; external;
  86. procedure test_array_param_u64(x: qword_array); cdecl; external;
  87. procedure test_array_param_s16(x :smallint_array); cdecl; external;
  88. procedure test_array_param_s32(x: longint_array); cdecl; external;
  89. procedure test_array_param_s64(x: int64_array); cdecl; external;
  90. procedure test_array_param_float(x : single_array); cdecl; external;
  91. procedure test_array_param_double(x: double_array); cdecl; external;
  92. procedure test_array_param_longdouble(x: extended_array); cdecl; external;
  93. { mixed parameter passing }
  94. procedure test_param_mixed_u16(z: byte; x : word; y :byte); cdecl; external;
  95. procedure test_param_mixed_u32(z: byte; x: cardinal; y: byte); cdecl; external;
  96. procedure test_param_mixed_s64(z: byte; x: int64; y: byte); cdecl; external;
  97. procedure test_param_mixed_float(x: single; y: byte); cdecl; external;
  98. procedure test_param_mixed_double(x: double; y: byte); cdecl; external;
  99. procedure test_param_mixed_long_double(x: extended; y: byte); cdecl; external;
  100. procedure test_param_mixed_var_u8(var x: byte;y:byte); cdecl; external;
  101. { structure parameter testing }
  102. procedure test_param_struct_tiny(buffer : _1BYTE_); cdecl; external;
  103. procedure test_param_struct_small(buffer : _3BYTE_); cdecl; external;
  104. procedure test_param_struct_small_s(buffer : _3BYTE_S); cdecl; external;
  105. procedure test_param_struct_medium(buffer : _5BYTE_); cdecl; external;
  106. procedure test_param_struct_large(buffer : _7BYTE_); cdecl; external;
  107. { mixed with structure parameter testing }
  108. procedure test_param_mixed_struct_tiny(buffer : _1BYTE_; y :byte); cdecl; external;
  109. procedure test_param_mixed_struct_small(buffer : _3BYTE_; y :byte); cdecl; external;
  110. procedure test_param_mixed_struct_small_s(buffer : _3BYTE_S; y :byte); cdecl; external;
  111. procedure test_param_mixed_struct_medium(buffer : _5BYTE_; y :byte); cdecl; external;
  112. procedure test_param_mixed_struct_large(buffer : _7BYTE_; y :byte); cdecl; external;
  113. { function result value testing }
  114. function test_function_u8: byte; cdecl; external;
  115. function test_function_u16: word; cdecl; external;
  116. function test_function_u32: cardinal; cdecl; external;
  117. function test_function_u64: qword; cdecl; external;
  118. function test_function_s16: smallint; cdecl; external;
  119. function test_function_s32: longint; cdecl; external;
  120. function test_function_s64: int64; cdecl; external;
  121. function test_function_pchar: pchar; cdecl; external;
  122. function test_function_float : single; cdecl; external;
  123. function test_function_double : double; cdecl; external;
  124. function test_function_longdouble: extended; cdecl; external;
  125. function test_function_tiny_struct : _1byte_; cdecl; external;
  126. function test_function_small_struct : _3byte_; cdecl; external;
  127. function test_function_small_struct_s : _3byte_s; cdecl; external;
  128. function test_function_medium_struct : _5byte_; cdecl; external;
  129. function test_function_struct : _7byte_; cdecl; external;
  130. var
  131. global_u8bit : byte; cvar; external;
  132. global_u16bit : word; cvar; external;
  133. global_u32bit : cardinal; cvar;external;
  134. global_u64bit : qword; cvar; external;
  135. global_s16bit : smallint; cvar; external;
  136. global_s32bit : longint; cvar;external;
  137. global_s64bit : int64; cvar; external;
  138. global_float : single; cvar;external;
  139. global_double : double; cvar;external;
  140. global_long_double : extended; cvar; external;
  141. value_u8bit : byte;
  142. value_s16bit : smallint;
  143. value_s32bit : longint;
  144. value_s64bit : int64;
  145. value_u16bit : word;
  146. value_u32bit : cardinal;
  147. value_u64bit : qword;
  148. value_float : single;
  149. value_double : double;
  150. value_long_double : extended;
  151. array_u8bit : array [0..1] of byte;
  152. array_s16bit : array [0..1] of smallint;
  153. array_s32bit : array [0..1] of longint;
  154. array_s64bit : array [0..1] of int64;
  155. array_u16bit : array [0..1] of word;
  156. array_u32bit : array [0..1] of cardinal;
  157. array_u64bit : array [0..1] of qword;
  158. array_float : array [0..1] of single;
  159. array_double : array [0..1] of double;
  160. array_long_double : array [0..1] of extended;
  161. procedure clear_globals;
  162. begin
  163. global_u8bit := 0;
  164. global_u16bit := 0;
  165. global_u32bit := 0;
  166. global_u64bit := 0;
  167. global_s16bit := 0;
  168. global_s32bit := 0;
  169. global_s64bit := 0;
  170. global_float := 0.0;
  171. global_double := 0.0;
  172. global_long_double := 0.0;
  173. end;
  174. procedure clear_values;
  175. begin
  176. value_u8bit := 0;
  177. value_u16bit := 0;
  178. value_u32bit := 0;
  179. value_u64bit := 0;
  180. value_s16bit := 0;
  181. value_s32bit := 0;
  182. value_s64bit := 0;
  183. value_float := 0.0;
  184. value_double := 0.0;
  185. value_long_double := 0.0;
  186. end;
  187. const
  188. has_errors : boolean = false;
  189. procedure fail;
  190. begin
  191. WriteLn('Failed!');
  192. has_errors:=true;
  193. end;
  194. var failed : boolean;
  195. tinystruct : _1BYTE_;
  196. smallstruct : _3BYTE_;
  197. smallstruct_s : _3BYTE_S;
  198. mediumstruct : _5BYTE_;
  199. bigstruct : _7BYTE_;
  200. pc: pchar;
  201. begin
  202. Write('External simple parameter testing...');
  203. failed := false;
  204. clear_values;
  205. clear_globals;
  206. value_u8bit := RESULT_U8BIT;
  207. test_param_u8(value_u8bit);
  208. if global_u8bit <> RESULT_U8BIT then
  209. failed := true;
  210. clear_values;
  211. clear_globals;
  212. value_u16bit := RESULT_U16BIT;
  213. test_param_u16(value_u16bit);
  214. if global_u16bit <> RESULT_U16BIT then
  215. failed := true;
  216. clear_values;
  217. clear_globals;
  218. value_u32bit := RESULT_U32BIT;
  219. test_param_u32(value_u32bit);
  220. if global_u32bit <> RESULT_U32BIT then
  221. failed := true;
  222. clear_values;
  223. clear_globals;
  224. value_u64bit := RESULT_U64BIT;
  225. test_param_u64(value_u64bit);
  226. if global_u64bit <> RESULT_U64BIT then
  227. failed := true;
  228. clear_values;
  229. clear_globals;
  230. value_s16bit := RESULT_S16BIT;
  231. test_param_s16(value_s16bit);
  232. if global_s16bit <> RESULT_S16BIT then
  233. failed := true;
  234. clear_values;
  235. clear_globals;
  236. value_s32bit := RESULT_S32BIT;
  237. test_param_s32(value_s32bit);
  238. if global_s32bit <> RESULT_S32BIT then
  239. failed := true;
  240. clear_values;
  241. clear_globals;
  242. value_s64bit := RESULT_S64BIT;
  243. test_param_s64(value_s64bit);
  244. if global_s64bit <> RESULT_S64BIT then
  245. failed := true;
  246. clear_values;
  247. clear_globals;
  248. value_float := RESULT_FLOAT;
  249. test_param_float(value_float);
  250. if trunc(global_float) <> trunc(RESULT_FLOAT) then
  251. failed := true;
  252. clear_values;
  253. clear_globals;
  254. value_double := RESULT_DOUBLE;
  255. test_param_double(value_double);
  256. if trunc(global_double) <> trunc(RESULT_DOUBLE) then
  257. failed := true;
  258. clear_values;
  259. clear_globals;
  260. value_long_double := RESULT_LONGDOUBLE;
  261. test_param_longdouble(value_long_double);
  262. if trunc(global_long_double) <> trunc(RESULT_LONGDOUBLE) then
  263. failed := true;
  264. { var parameter testing }
  265. clear_values;
  266. clear_globals;
  267. test_param_var_u8(value_u8bit);
  268. if value_u8bit <> RESULT_U8BIT then
  269. failed := true;
  270. If failed then
  271. fail
  272. else
  273. WriteLn('Passed!');
  274. Write('External array parameter testing...');
  275. failed := false;
  276. clear_values;
  277. clear_globals;
  278. array_u8bit[1] := RESULT_U8BIT;
  279. test_array_param_u8(array_u8bit);
  280. if global_u8bit <> RESULT_U8BIT then
  281. failed := true;
  282. clear_values;
  283. clear_globals;
  284. array_u16bit[1] := RESULT_U16BIT;
  285. test_array_param_u16(array_u16bit);
  286. if global_u16bit <> RESULT_U16BIT then
  287. failed := true;
  288. clear_values;
  289. clear_globals;
  290. array_u32bit[1] := RESULT_U32BIT;
  291. test_array_param_u32(array_u32bit);
  292. if global_u32bit <> RESULT_U32BIT then
  293. failed := true;
  294. clear_values;
  295. clear_globals;
  296. array_u64bit[1] := RESULT_U64BIT;
  297. test_array_param_u64(array_u64bit);
  298. if global_u64bit <> RESULT_U64BIT then
  299. failed := true;
  300. clear_values;
  301. clear_globals;
  302. array_s16bit[1] := RESULT_S16BIT;
  303. test_array_param_s16(array_s16bit);
  304. if global_s16bit <> RESULT_S16BIT then
  305. failed := true;
  306. clear_values;
  307. clear_globals;
  308. array_s32bit[1] := RESULT_S32BIT;
  309. test_array_param_s32(array_s32bit);
  310. if global_s32bit <> RESULT_S32BIT then
  311. failed := true;
  312. clear_values;
  313. clear_globals;
  314. array_s64bit[1] := RESULT_S64BIT;
  315. test_array_param_s64(array_s64bit);
  316. if global_s64bit <> RESULT_S64BIT then
  317. failed := true;
  318. clear_values;
  319. clear_globals;
  320. array_float[1] := RESULT_FLOAT;
  321. test_array_param_float(array_float);
  322. if trunc(global_float) <> trunc(RESULT_FLOAT) then
  323. failed := true;
  324. clear_values;
  325. clear_globals;
  326. array_double[1] := RESULT_DOUBLE;
  327. test_array_param_double(array_double);
  328. if trunc(global_double) <> trunc(RESULT_DOUBLE) then
  329. failed := true;
  330. clear_values;
  331. clear_globals;
  332. array_long_double[1] := RESULT_LONGDOUBLE;
  333. test_array_param_longdouble(array_long_double);
  334. if trunc(global_long_double) <> trunc(RESULT_LONGDOUBLE) then
  335. begin
  336. {$ifdef cpui386}
  337. if sizeof(global_long_double)=10 then
  338. begin
  339. { Known issue, ignore tcalext2 contains that test }
  340. end
  341. else
  342. {$endif cpui386}
  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 has_errors then
  625. Halt(1);
  626. end.