taoc5.pp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. { %cpu=i386 }
  2. { This test expects values on the stack, which is i386 only }
  3. { fifth simple array of const test }
  4. {$mode objfpc}
  5. program test_cdecl_array_of_const;
  6. var
  7. l : double;
  8. const
  9. has_errors : boolean = false;
  10. procedure test_one_double(args : array of const);cdecl;
  11. type
  12. pdouble = ^double;
  13. var
  14. p : pdouble;
  15. begin
  16. p:=pdouble(@args);
  17. l:=p^;
  18. end;
  19. procedure test_two_doubles(args : array of const);cdecl;
  20. var
  21. p : pdouble;
  22. begin
  23. p:=pdouble(@args);
  24. inc(pointer(p),sizeof(double));
  25. l:=p^;
  26. end;
  27. begin
  28. l:=4.0;
  29. test_one_double([double(3.45)]);
  30. if abs(l-3.45)>0.01 then
  31. has_errors:=true;
  32. l:=4.0;
  33. test_one_double([double(3.45),double(2.45)]);
  34. if abs(l-3.45)>0.01 then
  35. has_errors:=true;
  36. l:=4;
  37. test_one_double([double(3.45),double(24.25),double(678.8)]);
  38. if abs(l-3.45)>0.01 then
  39. has_errors:=true;
  40. l:=4;
  41. test_two_doubles([double(3.45),double(4.56)]);
  42. if abs(l-4.56)>0.01 then
  43. has_errors:=true;
  44. if has_errors then
  45. begin
  46. Writeln('cdecl array of const problem');
  47. halt(1);
  48. end;
  49. end.