Pas2JS pascal source code
{-------- TEST I ------}
function Hello : String;
begin
Result:='duh';
try
Result:='Hello';
if True then Exit;
finally
Result:=Result+' world';
end;
Result:='Bye bye';
end;
WriteLn(Hello);
function Test(i : Integer) : Boolean;
var
ts : TObject;
begin
Result := False;
ts := TObject.Create;
try
if (i < 10) then Exit;
finally
ts.Free;
end;
Result := True;
end;
//if not Test(10) then WriteLn('Test bugged 10');
if Test(5) then WriteLn('Test bugged 5');
try
WriteLn('Try');
Exit;
finally
WriteLn('Finally');
end;
WriteLn('Bug');
{ <<< CONSOLE OUTPUTS >>>
Hello world
Try
Finally
}
{------ TEST II ------}
function Hello2(doExit : Boolean) : String;
begin
Result:='duh';
try
try
Result:='Hello';
if doExit then Exit;
Result+=' one';
finally
WriteLn('1st finally');
end;
Result+=' two';
finally
WriteLn('2nd finally');
Result+=' world'
end;
Result:='Bye bye';
end;
WriteLn(Hello2(False));
WriteLn(Hello2(True));
{
1st finally
2nd finally
Bye bye
1st finally
2nd finally
Hello world
}