test.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. end;
  40. TClass2 = class(TClass)
  41. end;
  42. EnumTyp = (enum1,enum2,enum3);
  43. ArrayTyp = array[1..10] of EnumTyp;
  44. ProcTyp = function(A: word; var B: longint; const C: EnumTyp): real;
  45. SetTyp = set of EnumTyp;
  46. const
  47. ConstOrd = enum1;
  48. var Hello : word;
  49. X: PRecord;
  50. Bool: boolean;
  51. T : TRecord;
  52. Str20 : string[20];
  53. Str255: string;
  54. ArrayW: array[2..45] of word;
  55. ArrayVar: ArrayTyp;
  56. EnumVar: (enumElem1,enumElem2,enumElem3);
  57. EnumVar2: EnumTyp;
  58. FileVar: file;
  59. FileVarR: file of TRecord;
  60. FileVarW: file of word;
  61. ProcVar: procedure;
  62. ProcVarD: function(X: real): boolean;
  63. ProcVarI: ProcTyp;
  64. SetVarD: set of char;
  65. SetVarI: SetTyp;
  66. Float1: real;
  67. Float2: double;
  68. Float3: comp;
  69. Float4: extended;
  70. Pointer1: pointer;
  71. Pointer2: PObj;
  72. ClassVar1: TClass;
  73. ClassVar2: TClass2;
  74. Obj1: TObj;
  75. Obj2: TObj2;
  76. CharArray : Array[1..2000] of char;
  77. constructor TObj.Init;
  78. begin
  79. Z:=1;
  80. end;
  81. function TObj.Func: boolean;
  82. begin
  83. Func:=true;
  84. end;
  85. procedure TObj.Proc;
  86. begin
  87. if Func=false then Halt;
  88. end;
  89. destructor TObj.Done;
  90. begin
  91. end;
  92. procedure TObj2.Proc;
  93. begin
  94. Z:=4;
  95. end;
  96. constructor TClass.Create;
  97. begin
  98. end;
  99. function Func1(x,z : word; var y : boolean; const r: TRecord): shortint;
  100. var loc : string;
  101. procedure test_local(c,f : longint);
  102. var
  103. int_loc : longint;
  104. begin
  105. Writeln('dummy for browser');
  106. end;
  107. procedure indirect_call;
  108. var
  109. loc : longint;
  110. begin
  111. loc:=1;
  112. test_local(5,7);
  113. end;
  114. begin
  115. loc:='This is a string';
  116. if Hello=0 then X:=0 else X:=1;
  117. test_local(0,2);
  118. indirect_call;
  119. Func1:=X;
  120. end;
  121. var i : longint;
  122. BEGIN
  123. X:=nil;
  124. for i:=1 to 2000 do
  125. CharArray[i]:=chr(32+(i mod (255-32)));
  126. writeln('Hello world!');
  127. Writeln('ParamCount = ',ParamCount);
  128. For i:=0 to paramcount do
  129. writeln('Paramstr(',i,') = '+Paramstr(i));
  130. writeln(IsOdd(3));
  131. writeln(Func1(5,5,Bool,T));
  132. new(X);
  133. new(X^.next);
  134. X^.next^.next:=X;
  135. dispose(X);
  136. { for i:=1 to 99 do
  137. Writeln('Line ',i); }
  138. Halt(4);
  139. END.