test.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. constructor TObj.Init;
  77. begin
  78. Z:=1;
  79. end;
  80. function TObj.Func: boolean;
  81. begin
  82. Func:=true;
  83. end;
  84. procedure TObj.Proc;
  85. begin
  86. if Func=false then Halt;
  87. end;
  88. destructor TObj.Done;
  89. begin
  90. end;
  91. procedure TObj2.Proc;
  92. begin
  93. Z:=4;
  94. end;
  95. constructor TClass.Create;
  96. begin
  97. end;
  98. function Func1(x,z : word; var y : boolean; const r: TRecord): shortint;
  99. var loc : string;
  100. procedure test_local(c,f : longint);
  101. var
  102. int_loc : longint;
  103. begin
  104. Writeln('dummy for browser');
  105. end;
  106. procedure indirect_call;
  107. var
  108. loc : longint;
  109. begin
  110. loc:=1;
  111. test_local(5,7);
  112. end;
  113. begin
  114. loc:='This is a string';
  115. if Hello=0 then X:=0 else X:=1;
  116. test_local(0,2);
  117. indirect_call;
  118. Func1:=X;
  119. end;
  120. var i : longint;
  121. BEGIN
  122. X:=nil;
  123. writeln('Hello world!');
  124. Writeln('ParamCount = ',ParamCount);
  125. For i:=0 to paramcount do
  126. writeln('Paramstr(',i,') = '+Paramstr(i));
  127. writeln(IsOdd(3));
  128. writeln(Func1(5,5,Bool,T));
  129. new(X);
  130. new(X^.next);
  131. X^.next^.next:=X;
  132. dispose(X);
  133. { for i:=1 to 99 do
  134. Writeln('Line ',i); }
  135. Halt(4);
  136. END.