testmvb.out

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

OUT
137
字号
unit TestMVB;

{ AFS 15 June 2000

 This unit does not compile and is not semantically meaningfull
 it is test cases for the code formatting utility

  test some conditions mailed to me by Marcel van Brakel}

interface

uses SysUtils, Windows;

type

  EJclError = class(Exception)
  {$IFNDEF DELPHI5_UP}
  public
    constructor CreateRes(ResStringRec: PResStringRec); overload;
    constructor CreateResFmt(ResStringRec: PResStringRec; const Args: array of const);
    overload;
  {$ENDIF}
  end;

  TFred = class(TObject)
  end;

  TFred2 = class(TObject)
  end;

  TFred3 = class(TObject)
  end;

  PInt64 = ^int64;
  int64  = packed record
    case integer of
      0: (
        LowPart: DWORD;
        HighPart: longint);
  {$IFNDEF BCB3}
      1: (
        QuadPart: LONGLONG);
  {$ENDIF}
  end;

const

  DynExtendedArrayHigh = 214748363;  // 2^31 / SizeOf(Extended)
  DynDoubleArrayHigh   = 536870908;  // 2^31 / SizeOf(Double)
  DynSingleArrayHigh   = 268435448;  // 2^31 / SizeOf(Single)
  {$IFDEF MATH_EXTENDED_PRECISION}
  DynFloatArrayHigh = 214748363;  // 2^31 / SizeOf(Extended)
  {$ENDIF}


procedure I64Assign(var I: int64; Low, High: longint);
procedure I64Copy(var Dest: int64; const Source: int64);
function I64Compare(const I1, I2: int64): integer;


implementation


var
  i:    integer;
  fred: string;


const
  WAN    = 1;
  TWOOOO = 2;
  F      = 12;


constructor EJclError.CreateResFmt(ResStringRec: PResStringRec;
  const Args: array of const);
begin
  CreateFmt(LoadResString(ResStringRec), Args);
end;

constructor EJclWin32Error.CreateRes(Ident: integer);
begin
  FLastError    := GetLastError;
  FLastErrorMsg := SysErrorMessage(FLastError);
  inherited CreateFmt(LoadStr(Ident) + #13 + 'Win32: %s (%u)',
    [FLastErrorMsg, FLastError]);
end;

constructor EJclWin32Error.CreateFmt(const Msg: string; const Args: array of const);
begin
  FLastError    := GetLastError;
  FLastErrorMsg := SysErrorMessage(FLastError);
  inherited CreateFmt(Msg + #13 + Format('Win32: %s (%u)',
    [FLastErrorMsg, FLastError]), Args);
end;

procedure DynArrayInitialize(var A; ElementSize, InitialLength: longint);
var
  P:    Pointer;
  Size: longint;
begin
  if (ElementSize < 1) or (ElementSize > 8) then
    raise Exception.Create('');
  if InitialLength < 0 then
    InitialLength := 0;
  Size := DynArrayRecSize + (InitialLength * ElementSize);
  P := AllocMem(Size);
  with TDynArrayRec(P^) do
  begin
    AllocSize := Size;
    Length    := InitialLength;
    ElemSize  := ElementSize;
  end;
  Pointer(A) := Pointer(longint(P) + DynArrayRecSize);
end;

procedure TestMisc;
var
  p: pointer;
  s: string;
begin
  s := '';
  p := nil;

  s := '';
  p := nil;

  s := '';
  p := nil;

end;


initialization
  InitSysInfo;
end.

⌨️ 快捷键说明

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