test.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. {$mode objfpc}
  2. {$R-}
  3. {$H-}
  4. program TestProgram;
  5. uses
  6. {$ifdef go32v2}
  7. dpmiexcp,
  8. {$endif}
  9. test1, Test2;
  10. const A = 1234;
  11. C = #1#2#3#4;
  12. ConstBool1 = true;
  13. ConstBool2 = boolean(5);
  14. ConstChar = 'A';
  15. ConstSet = ['A'..'Z'];
  16. ConstSet2 = [15..254];
  17. ConstFloat = 3.1415;
  18. {$i empty.inc}
  19. type
  20. PObj = ^TObj;
  21. TObj = object
  22. constructor Init;
  23. function Func: boolean;
  24. procedure Proc; virtual;
  25. destructor Done; virtual;
  26. private
  27. Z: integer;
  28. end;
  29. TObj2 = object(TObj)
  30. procedure Proc; virtual;
  31. end;
  32. TObj3 = object(TObj)
  33. end;
  34. TObj32 = object(TObj3)
  35. end;
  36. TObj4 = object(TObj)
  37. end;
  38. TClass = class
  39. name : string;
  40. constructor Create;
  41. end;
  42. TClass2 = class(TClass)
  43. X : longint;
  44. constructor Create;
  45. end;
  46. EnumTyp = (enum1,enum2,enum3);
  47. ArrayTyp = array[1..10] of EnumTyp;
  48. ProcTyp = function(A: word; var B: longint; const C: EnumTyp): real;
  49. SetTyp = set of EnumTyp;
  50. const
  51. ConstOrd = enum1;
  52. var Hello : word;
  53. X: PRecord;
  54. Bool: boolean;
  55. T : TRecord;
  56. Str20 : string[20];
  57. Str255: string;
  58. ArrayW: array[2..45] of word;
  59. ArrayVar: ArrayTyp;
  60. EnumVar: (enumElem1,enumElem2,enumElem3);
  61. EnumVar2: EnumTyp;
  62. FileVar: file;
  63. FileVarR: file of TRecord;
  64. FileVarW: file of word;
  65. ProcVar: procedure;
  66. ProcVarD: function(X: real): boolean;
  67. ProcVarI: ProcTyp;
  68. SetVarD: set of AnsiChar;
  69. SetVarI: SetTyp;
  70. Float1: real;
  71. Float2: double;
  72. Float3: comp;
  73. Float4: extended;
  74. Pointer1: pointer;
  75. Pointer2: PObj;
  76. ClassVar1: TClass;
  77. ClassVar2: TClass2;
  78. Obj1: TObj;
  79. Obj2: TObj2;
  80. CharArray : Array[1..2000] of AnsiChar;
  81. ExtendedArray : Array[1..2000] of extended;
  82. ExtendedPackedArray : packed Array[1..2000] of extended;
  83. SingleArrayArray : Array[1..10,1..10] of single;
  84. constructor TObj.Init;
  85. begin
  86. Z:=1;
  87. end;
  88. function TObj.Func: boolean;
  89. begin
  90. Func:=true;
  91. end;
  92. procedure TObj.Proc;
  93. begin
  94. if Func=false then Halt;
  95. end;
  96. destructor TObj.Done;
  97. begin
  98. end;
  99. procedure TObj2.Proc;
  100. begin
  101. Z:=4;
  102. end;
  103. constructor TClass.Create;
  104. begin
  105. Name:='TClass instance';
  106. end;
  107. constructor TClass2.Create;
  108. begin
  109. Name:='TClass2 instance';
  110. X:=7;
  111. end;
  112. function Func1(x,z : word; var y : boolean; const r: TRecord): shortint;
  113. var loc : string;
  114. procedure test_local(c,f : longint);
  115. var
  116. int_loc : longint;
  117. begin
  118. Writeln('dummy for browser');
  119. end;
  120. procedure indirect_call;
  121. var
  122. loc : longint;
  123. begin
  124. loc:=1;
  125. test_local(5,7);
  126. end;
  127. begin
  128. loc:='This is a string';
  129. if Hello=0 then X:=0 else X:=1;
  130. test_local(0,2);
  131. indirect_call;
  132. Func1:=X;
  133. end;
  134. var i,j : longint;
  135. Length : longint;
  136. BEGIN
  137. {$ifdef m68k}
  138. asm
  139. beq @L13
  140. bhi @L13
  141. blo @L13
  142. dbeq d0,@L13
  143. dbcs d0,@L13
  144. // dblo d0,@L13
  145. @L13:
  146. end;
  147. {$endif}
  148. for i:=low(ExtendedArray) to high(ExtendedArray) do
  149. ExtendedArray[i]:=i;
  150. for i:=low(ExtendedPackedArray) to high(ExtendedPackedArray) do
  151. ExtendedPackedArray[i]:=i;
  152. for i:=1 to 10 do
  153. for j:=1 to 10 do
  154. SingleArrayArray[i,j]:=i*j;
  155. ClassVar1:=TClass2.create;
  156. Obj1.Init;
  157. pointer2:=@Obj1;
  158. Writeln('Obj1.Z=',Obj1.Z);
  159. Obj1.done;
  160. X:=nil;
  161. // fg
  162. for i:=1 to 2000 do
  163. CharArray[i]:=chr(32+(i mod (255-32)));
  164. writeln('Hello world!');
  165. Writeln('ParamCount = ',ParamCount);
  166. For i:=0 to paramcount do
  167. writeln('Paramstr(',i,') = '+Paramstr(i));
  168. writeln(IsOdd(3));
  169. writeln(Func1(5,5,Bool,T));
  170. new(X);
  171. new(X^.next);
  172. X^.next^.next:=X;
  173. dispose(X);
  174. { for i:=1 to 99 do
  175. Writeln('Line ',i); }
  176. if (TestOne<>1) or (TestOne(5)<>5) or (TestOne('6')<>6) then
  177. begin
  178. Writeln('Error while testing TestOne function overloads');
  179. RunError(200);
  180. end;
  181. Halt(4);
  182. END.