⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testlayoutbare.out

📁 格式化源码的最新板
💻 OUT
字号:
unit TestLayoutBare;

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

 a 'bare' block is one that does not have begin..end around it
 This unit tests layout for statments with bare blocks

 IMHO doing things this way in real code is not cool, 
 use begin-end blocks to make things clear
}

interface

implementation

{ block layout }

function NastyElse(var foo, bar: boolean): integer;
begin
  if Foo then
    Result := -1
  else;
end;

function NastyElse2(var foo, bar: boolean): integer;
begin
  if Foo then
    if bar then
      Result := -1
    else
  else
    Result := 2;
end;


{ these lttle tests have one statement block per procedure
  and omit the semicolon after the final statement, which is legal but ugly }
procedure LittleTest1;
var
  iA, iB: integer;
  liLoop: integer;
begin
  if iA > 5 then
    for liLoop := 1 to 10 do
      iA := iA + Random(2)
  else
    while IA < 50 do
      iA := iA + Random(5);
end;

procedure LittleTest2;
var
  iA, iB: integer;
  bA:     boolean;
begin
  if iA > 20 then
    bA := False
  else if IB > 6 then
    BA := True
  else
    BA := False;
end;


procedure LittleTest3;
var
  iA, iB: integer;
  liLoop: integer;
begin
  if IB < 15 then
    while iA < 10 do
      for liLoop := 0 to 3 do
      begin
        iA := iA + Random(10);
      end;

end;


procedure LittleTest4;
var
  iA: integer;
begin
  repeat
    iA := iA + Random(10)
  until IA > 100;
end;

procedure IfElseTest;
var
  iA, IB: integer;
  BA:     boolean;
begin

  if iA > 20 then
    bA := False
  else if IB > 6 then
    BA := True
  else if IA < 6 then
    BA := False;

  if iA > 20 then
    if IB > 5 then
      bA := False
    else if IB > 6 then
      BA := True
    else
      BA := False;

end;

procedure LittleTest5_1;
var
  iA, iB: integer;
  bA:     boolean;
begin
  if iA > 5 then
    if iA > 20 then
      BA := True
    else
      BA := False;
end;


procedure LittleTest5_2;
var
  iA, iB: integer;
  bA:     boolean;
begin
  if iA > 5 then
    if iA > 20 then
      BA := True
    else
      BA := False
  else
    ba := True;
end;

procedure LittleTest5_3;
var
  iA, iB: integer;
  bA:     boolean;
begin
  if iA > 20 then
    if IB > 6 then
      BA := True
    else
      BA := False
  else
    ba := True;
end;


procedure LittleTest6;
var
  iA, iB: integer;
  bA:     boolean;
begin
  if iA > 5 then
    if iA > 20 then
      if IB > 6 then
        BA := True
      else
        BA := False
    else
      ba := True
  else
    ba := False;
end;


procedure Mixem;
var
  iA, IB: integer;
begin
  iA := Random(10);
  iB := Random(10);

  { alternate blocked and naked }
  if IA > 3 then
    if IA > 4 then
    begin
      ib := 10;
    end;

  if IA > 4 then
  begin
    if IA > 5 then
      if IA > 6 then
      begin
        if IA > 7 then
          if IA > 8 then
          begin
            if IA > 9 then
              ib := 10;
          end;
      end;
  end;

  if IA > 3 then
    if IA > 4 then
    begin
      if IA > 5 then
        if IA > 6 then
        begin
          if IA > 7 then
            if IA > 8 then
            begin
              if IA > 9 then
                ib := 10;
            end;
        end;
    end;

end;

procedure LayoutBare;
var
  iA, IB: integer;
  bA:     boolean;
  liLoop, liLoop2: integer;
begin
  iA := Random(10);
  iB := Random(10);

  if iA > 5 then
    bA := True
  else
    bA := False;

  for liLoop := 0 to 10 do
    iA := iA + Random(10);

  for liLoop := 0 to 10 do
    if iB < 15 then
      iA := iA - Random(10);

  if iB < 15 then
    while iA < 10 do
      iA := iA + Random(10);

  for liLoop := 0 to 3 do
    for liLoop2 := 0 to 3 do
      iA := iA - Random(10);

  if IB < 15 then
    while iA < 10 do
      for liLoop := 0 to 3 do
      begin
        iA := iA + Random(10);
      end;

  if iA > 20 then
    if IB > 5 then
      bA := False
    else
    if IB > 6 then
      BA := True
    else
      BA := False;

  repeat
    iA := iA + Random(10)
  until IA > 100;

end;

end.

⌨️ 快捷键说明

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