test.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {$mode objfpc}
  2. {$R-}
  3. program TestProgram;
  4. uses
  5. {$ifdef go32v2}
  6. dpmiexcp,
  7. {$endif}
  8. test1, Test2;
  9. const A = 1234;
  10. C = #1#2#3#4;
  11. ConstBool1 = true;
  12. ConstBool2 = boolean(5);
  13. ConstChar = 'A';
  14. ConstSet = ['A'..'Z'];
  15. ConstSet2 = [15..254];
  16. ConstFloat = 3.1415;
  17. type
  18. PObj = ^TObj;
  19. TObj = object
  20. constructor Init;
  21. function Func: boolean;
  22. procedure Proc; virtual;
  23. destructor Done; virtual;
  24. private
  25. Z: integer;
  26. end;
  27. TObj2 = object(TObj)
  28. procedure Proc; virtual;
  29. end;
  30. TObj3 = object(TObj)
  31. end;
  32. TObj32 = object(TObj3)
  33. end;
  34. TObj4 = object(TObj)
  35. end;
  36. TClass = class
  37. constructor Create;
  38. end;
  39. TClass2 = class(TClass)
  40. end;
  41. EnumTyp = (enum1,enum2,enum3);
  42. ArrayTyp = array[1..10] of EnumTyp;
  43. ProcTyp = function(A: word; var B: longint; const C: EnumTyp): real;
  44. SetTyp = set of EnumTyp;
  45. const
  46. ConstOrd = enum1;
  47. var Hello : word;
  48. X: PRecord;
  49. Bool: boolean;
  50. T : TRecord;
  51. Str20 : string[20];
  52. Str255: string;
  53. ArrayW: array[2..45] of word;
  54. ArrayVar: ArrayTyp;
  55. EnumVar: (enumElem1,enumElem2,enumElem3);
  56. EnumVar2: EnumTyp;
  57. FileVar: file;
  58. FileVarR: file of TRecord;
  59. FileVarW: file of word;
  60. ProcVar: procedure;
  61. ProcVarD: function(X: real): boolean;
  62. ProcVarI: ProcTyp;
  63. SetVarD: set of char;
  64. SetVarI: SetTyp;
  65. Float1: real;
  66. Float2: double;
  67. Float3: comp;
  68. Float4: extended;
  69. Pointer1: pointer;
  70. Pointer2: PObj;
  71. ClassVar1: TClass;
  72. ClassVar2: TClass2;
  73. Obj1: TObj;
  74. Obj2: TObj2;
  75. constructor TObj.Init;
  76. begin
  77. Z:=1;
  78. end;
  79. function TObj.Func: boolean;
  80. begin
  81. Func:=true;
  82. end;
  83. procedure TObj.Proc;
  84. begin
  85. if Func=false then Halt;
  86. end;
  87. destructor TObj.Done;
  88. begin
  89. end;
  90. procedure TObj2.Proc;
  91. begin
  92. Z:=4;
  93. end;
  94. constructor TClass.Create;
  95. begin
  96. end;
  97. function Func1(x,z : word; var y : boolean; const r: TRecord): shortint;
  98. var loc : string;
  99. procedure test_local(c,f : longint);
  100. var
  101. int_loc : longint;
  102. begin
  103. Writeln('dummy for browser');
  104. end;
  105. procedure indirect_call;
  106. var
  107. loc : longint;
  108. begin
  109. loc:=1;
  110. test_local(5,7);
  111. end;
  112. begin
  113. loc:='This is a string';
  114. if Hello=0 then X:=0 else X:=1;
  115. test_local(0,2);
  116. indirect_call;
  117. Func1:=X;
  118. end;
  119. var i : longint;
  120. BEGIN
  121. X:=nil;
  122. writeln('Hello world!');
  123. Writeln('ParamCount = ',ParamCount);
  124. For i:=0 to paramcount do
  125. writeln('Paramstr(',i,') = '+Paramstr(i));
  126. writeln(IsOdd(3));
  127. writeln(Func1(5,5,Bool,T));
  128. new(X);
  129. X^.next:=X;
  130. dispose(X);
  131. { for i:=1 to 99 do
  132. Writeln('Line ',i); }
  133. Halt(4);
  134. END.