testdefaultparams.out

来自「格式化源码的最新板」· OUT 代码 · 共 92 行

OUT
92
字号
unit TestDefaultParams;

{ AFS 17 October 2000
 This unit compiles but is not semantically meaningfull
 it is test cases for the code formatting utility

 This code tests default parameters }

interface

function Def1(const piVal: integer = 42): boolean;
function Def2(bv: boolean = False; const piVal: integer = 42): boolean;
function Def3(bv: boolean = False; const piAverryLongValVal: integer = 42;
  const short: integer = 42): boolean;

type
  THasDefs = class(TObject)
  public
    procedure Fred(const pi: integer = 3; px: double = 34.4);
      virtual;
    procedure Jim(const pi: integer = 3; px: double = 34.4);
      overload;
    procedure Jim(pb: boolean = False);
      overload;

    procedure Bob(const pi: integer = 3; px: double = 34.4); overload;
    procedure Bob(const pbLongVariableName: pointer = nil;
      const pi: integer = 3; px: double = 34.4); overload;
  end;

implementation

procedure THasDefs.Bob(const pi: integer; px: double);
begin
  if pi > 3 then
  begin
    px := pi;
  end;

end;

procedure THasDefs.Bob(const pbLongVariableName: pointer; const pi: integer;
  px: double);
begin

end;

procedure THasDefs.Fred(const pi: integer = 3; px: double = 34.4);
begin
  if pi > 3 then
  begin
    px := pi;
  end;
end;

function Def1(const piVal: integer = 42): boolean;
begin
  Result := (piVal = 42);
end;

function Def2(bv: boolean = False; const piVal: integer = 42): boolean;
begin
  if bv then
    Result := Def1(piVal)
  else
  begin
    Result := Def1;
  end;
end;

function Def3(bv: boolean = False; const piAverryLongValVal: integer = 42;
  const short: integer = 42): boolean;
begin
  Def2(bv);
end;

procedure THasDefs.Jim(const pi: integer; px: double);
begin
  if pi > 3 then
  begin
    px := pi;
  end;
end;

procedure THasDefs.Jim(pb: boolean);
begin
  if pb then
    Jim(pb);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?