tautom.pp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. {%OPT=-glh}
  2. program tautom;
  3. type wstr_varnt_record=record
  4. s:widestring;
  5. v:variant;
  6. end;
  7. wstr_varnt_object=object
  8. s:wstr_varnt_record;
  9. end;
  10. wstr_array1=array[0..99] of wstr_varnt_record;
  11. wstr_array2=array[0..99] of wstr_varnt_object;
  12. procedure do_test;
  13. var a,b:wstr_array1;
  14. c,d:wstr_array2;
  15. i:0..99;
  16. begin
  17. for i:=low(a) to high(a) do
  18. begin
  19. a[i].s:='Ninja';
  20. a[i].v:='Samurai';
  21. end;
  22. b:=a;
  23. for i:=low(a) to high(a) do
  24. begin
  25. if a[i].s<>'Ninja' then
  26. halt(255);
  27. if b[i].s<>'Ninja' then
  28. halt(255);
  29. if a[i].v<>'Samurai' then
  30. halt(255);
  31. if b[i].v<>'Samurai' then
  32. halt(255);
  33. end;
  34. for i:=0 to 99 do
  35. begin
  36. c[i].s.s:=a[i].s;
  37. c[i].s.v:=a[i].v;
  38. end;
  39. d:=c;
  40. for i:=low(d) to high(d) do
  41. begin
  42. if c[i].s.s<>'Ninja' then
  43. halt(255);
  44. if d[i].s.s<>'Ninja' then
  45. halt(255);
  46. if c[i].s.v<>'Samurai' then
  47. halt(255);
  48. if d[i].s.v<>'Samurai' then
  49. halt(255);
  50. end;
  51. end;
  52. var before,after:sizeuint;
  53. begin
  54. with getfpcheapstatus do
  55. before:=currheapused;
  56. writeln('Used heap before ',before);
  57. do_test;
  58. with getfpcheapstatus do
  59. after:=currheapused;
  60. writeln('Used heap after ',after);
  61. if before<>after then
  62. exitcode:=255;
  63. end.