tis.pp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : secondis() }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondcalln() }
  9. { secondinline() }
  10. { secondadd() }
  11. {****************************************************************}
  12. { DEFINES: }
  13. {****************************************************************}
  14. { REMARKS: }
  15. {****************************************************************}
  16. program tis;
  17. {$mode objfpc}
  18. type
  19. {$ifndef fpc}
  20. smallint = integer;
  21. {$endif}
  22. tclass1 = class
  23. end;
  24. tclass2 = class(tclass1)
  25. end;
  26. tclass3 = class
  27. end;
  28. var
  29. myclass1 : tclass1;
  30. myclass2 : tclass2;
  31. myclass3 : tclass3;
  32. class1 : class of tclass1;
  33. procedure fail;
  34. begin
  35. WriteLn('Failure.');
  36. halt(1);
  37. end;
  38. function getclass1 : tclass1;
  39. begin
  40. getclass1:=myclass1;
  41. end;
  42. function getclass2 : tclass2;
  43. begin
  44. getclass2:=myclass2;
  45. end;
  46. function getclass3 : tclass3;
  47. begin
  48. getclass3:=myclass3;
  49. end;
  50. { possible types : left : LOC_REFERENCE, LOC_REGISTER }
  51. { possible types : right : LOC_REFERENCE, LOC_REGISTER }
  52. var
  53. failed : boolean;
  54. myclass4 : class of tclass1;
  55. begin
  56. failed := false;
  57. { create class instance }
  58. myclass1:=tclass1.create;
  59. myclass2:=tclass2.create;
  60. myclass3:=tclass3.create;
  61. {if myclass1 is tclass1 }
  62. Write('Testing left/right : LOC_REGISTER/LOC_REGISTER...');
  63. if not(getclass1 is tclass1) then
  64. failed := true;
  65. if (getclass1 is tclass2) then
  66. failed := true;
  67. if not (getclass2 is tclass2) then
  68. failed := true;
  69. if (getclass1 is tclass2) then
  70. failed := true;
  71. if failed then
  72. Fail
  73. else
  74. WriteLn('Passed!');
  75. failed := false;
  76. Write('Testing left/right : LOC_REFERENCE/LOC_REGISTER...');
  77. if not(myclass1 is tclass1) then
  78. failed := true;
  79. if (myclass1 is tclass2) then
  80. failed := true;
  81. if not (myclass2 is tclass2) then
  82. failed := true;
  83. if (myclass1 is tclass2) then
  84. failed := true;
  85. if failed then
  86. Fail
  87. else
  88. WriteLn('Passed!');
  89. failed := false;
  90. Write('Testing left/right : LOC_REFERENCE/LOC_REFERENCE...');
  91. if (myclass1 is class1) then
  92. failed := true;
  93. if failed then
  94. Fail
  95. else
  96. WriteLn('Passed!');
  97. end.