Ignore:
Timestamp:
Jun 29, 2023, 1:47:58 AM (11 months ago)
Author:
chronos
Message:
  • Fixed: Var function parameters processed correctly for both user defined and internal functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Tests.pas

    r235 r236  
    158158    ExpectedOutput := '-1' + LineEnding + '0' + LineEnding;
    159159  end;
     160  with TTestRun(Result.AddNew('function without result usage', TTestRun)) do begin
     161    Source.Add('function IsZero(A: Integer): Boolean;');
     162    Source.Add('begin');
     163    Source.Add('  Result := A = 0;');
     164    Source.Add('end;');
     165    Source.Add('');
     166    Source.Add('begin');
     167    Source.Add('  IsZero(0);');
     168    Source.Add('end.');
     169    ExpectedOutput := '';
     170  end;
    160171  with TTestRun(Result.AddNew('function var parameter', TTestRun)) do begin
    161172    Source.Add('function Test(var A: Integer): Boolean;');
    162173    Source.Add('begin');
    163174    Source.Add('  A := 10;');
    164     Source.Add('  Result := True;');
     175    Source.Add('  Result := 1 = 1;');
    165176    Source.Add('end;');
    166177    Source.Add('');
    167178    Source.Add('var');
    168179    Source.Add('  B: Integer;');
     180    Source.Add('  C: Boolean;');
    169181    Source.Add('begin');
    170182    Source.Add('  B := 1;');
    171     Source.Add('  Test(B);');
     183    Source.Add('  C := Test(B);');
    172184    Source.Add('  WriteLn(IntToStr(B));');
    173185    Source.Add('end.');
    174     ExpectedOutput := '-1' + LineEnding + '0' + LineEnding;
     186    ExpectedOutput := '10' + LineEnding;
    175187  end;
    176188  with TTestRun(Result.AddNew('procedure', TTestRun)) do begin
Note: See TracChangeset for help on using the changeset viewer.