2
0

tcmpnan.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. { Tests unordered comparison results. This is a basic codegeneration test, but it needs
  2. Math unit to silence exceptions. }
  3. uses math;
  4. const
  5. kNan = Sqrt(-1);
  6. kX = 5.8E-7;
  7. var
  8. vNan, vX: real;
  9. code: longint;
  10. b: boolean;
  11. begin
  12. code:=0;
  13. SetExceptionMask( [exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
  14. if kNan = kX then code:=1;
  15. if kNan < kX then code:=code or 2;
  16. if kNan <= kX then code:=code or 4;
  17. if kNan > kX then code:=code or 8;
  18. if kNan >= kX then code:=code or 16;
  19. code:=code or 32;
  20. if kX <> kNan then code:=code and (not 32);
  21. vNan:= kNan;
  22. vX:= kX;
  23. { Test g_flag2reg/ref }
  24. b:=(vNan = vX);
  25. if b then code:=code or 64;
  26. b:=(vNan < vX);
  27. if b then code:=code or 128;
  28. b:=(vNan <= vX);
  29. if b then code:=code or 256;
  30. b:=(vNan > vX);
  31. if b then code:=code or 512;
  32. b:=(vNan >= vX);
  33. if b then code:=code or 1024;
  34. b:=(vNan <> vX);
  35. if (not b) then code:=code or 2048;
  36. { Test a_jmp_flags }
  37. if vNan = vX then
  38. code:=code or 4096;
  39. if vNan < vX then
  40. code:=code or 8192;
  41. if vNan <= vX then
  42. code:=code or 16384;
  43. if vNan > vX then
  44. code:=code or 32768;
  45. if vNan >= vX then
  46. code:=code or 65536;
  47. code:=code or 131072;
  48. if vNan <> vX then
  49. code:=code and (not 131072);
  50. if code=0 then
  51. writeln('ok')
  52. else
  53. writeln('error: ',hexstr(code,8));
  54. Halt(code);
  55. end.