testv8.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. { %VERSION=1.1 }
  2. program testv8;
  3. uses variants,varutils;
  4. Procedure TestConvert(Var V : Variant);
  5. Var
  6. I64 : Int64;
  7. LI : Longint;
  8. SI : Smallint;
  9. HI : Shortint;
  10. Q : QWord;
  11. C : Cardinal;
  12. W : Word;
  13. B : Byte;
  14. R : Real;
  15. D : Double;
  16. E : Extended;
  17. S : Single;
  18. Bo : Boolean;
  19. begin
  20. DumpVariant(TVarData(V));
  21. I64:=V;
  22. Writeln('To Int64 : ',I64);
  23. LI:=V;
  24. Writeln('To Longint : ',LI);
  25. SI:=V;
  26. Writeln('To Smallint : ',SI);
  27. HI:=V;
  28. Writeln('To Shortint : ',HI);
  29. Q:=V;
  30. Writeln('To QWord : ',Q);
  31. C:=V;
  32. Writeln('To Cardinal : ',C);
  33. W:=V;
  34. Writeln('To Word : ',W);
  35. B:=V;
  36. Writeln('To Byte : ',B);
  37. R:=V;
  38. Writeln('To Real : ',R);
  39. D := v;
  40. Writeln('To Double : ',D);
  41. E := v;
  42. Writeln('To Extended : ',E);
  43. S := v;
  44. Writeln('To Single : ',S);
  45. Bo := v;
  46. Writeln('To Boolean : ',Bo);
  47. end;
  48. Procedure TestReal(R : Real);
  49. Var
  50. V : Variant;
  51. begin
  52. V:=R;
  53. TestConvert(V);
  54. V:=-R;
  55. TestConvert(V);
  56. end;
  57. Procedure TestDouble(R : Double);
  58. Var
  59. V : Variant;
  60. begin
  61. V:=R;
  62. TestConvert(V);
  63. V:=-R;
  64. TestConvert(V);
  65. end;
  66. Procedure TestSingle(R : Single);
  67. Var
  68. V : Variant;
  69. begin
  70. V:=R;
  71. TestConvert(V);
  72. V:=-R;
  73. TestConvert(V);
  74. end;
  75. Procedure TestExtended(R : Extended);
  76. Var
  77. V : Variant;
  78. begin
  79. V:=R;
  80. TestConvert(V);
  81. V:=-R;
  82. TestConvert(V);
  83. end;
  84. begin
  85. TestReal(1.0E-1);
  86. TestDouble(2.0E-2);
  87. TestSingle(3.0E-3);
  88. TestExtended(4.0E-4);
  89. TestReal(1.0E1);
  90. TestDouble(2.0E2);
  91. TestSingle(3.0E3);
  92. TestExtended(4.0E4);
  93. TestReal(0.0);
  94. TestDouble(0.0);
  95. TestSingle(0.0);
  96. TestExtended(0.0);
  97. TestReal(1.0E-39);
  98. TestDouble(2.0E-39);
  99. TestSingle(3.0E-39);
  100. TestExtended(4.0E-39);
  101. end.