test.pas 3.7 KB

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