CompileRun('begin if true then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if false then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if not true then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if not false then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if not (true) then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if not (false) then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if (not true) then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if (not false) then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if true and true then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if true and false then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if false and true then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if false and false then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if true or true then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if true or false then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if false or true then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if false or false then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if true xor true then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
CompileRun('begin if true xor false then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if false xor true then ResultB(True) else ResultB(False); end.');
CheckEquals(true,LastResultB,last_script);
CompileRun('begin if false xor false then ResultB(True) else ResultB(False); end.');
CheckEquals(False,LastResultB,last_script);
end;
procedureTCompilerTestSimple.RepeatLoop;
begin
CompileRun('var i: Integer; begin Repeat i := i + 8; until i mod 7 = 6; ResultI(I); end.');
CheckEquals(48,LastResultI,last_script);
end;
procedureTCompilerTestSimple.WhileLoop;
begin
CompileRun('var i, j: Integer; begin while i < 10 do begin j := j + 1; i := j; end; ResultI(i+j); end.');
CheckEquals(20,LastResultI,last_script);
end;
procedureTCompilerTestSimple.CharTest;
begin
CompileRun('var s: string; begin s := ''''+chr(32) + chr(45) + chr(45); ResultS(s); end.');
CheckEquals(#32#45#45,LastResult,last_script);
CompileRun('var s: string; begin s := chr(32) + chr(45) + chr(45); ResultS(s); end.');
CheckEquals(#32#45#45,LastResult,last_script);
end;
procedureTCompilerTestSimple.StringCharTest;
begin
CompileRun('var s: string; begin s:=''123456789''; s[1]:=s[2]; ResultS(s); end.');
CheckEquals('223456789',LastResult,last_script);
end;
procedureTCompilerTestSimple.CastDoubleTest;
begin
CompileRun('function Test(i1, i2: Integer): Double; begin Result := Double(i1) / i2; end; var Res: Double; begin res := Test(10, 2); ResultD(Res); end.');
'procedure Beep(i: Longint); begin if i = 2 then RaiseException(erCustomError, ''currpage <> '+
'wpSelectDir''); if i = 3 then RaiseException(erCustomError, ''not False and False'');end;'+
'Begin backclicked := false; curpage := 0; wpSelectDir := 5; if not BackClicked then Beep(1);'+
'if CurPage = wpSelectDir then Beep(2); if not BackClicked and (CurPage = wpSelectDir) then Beep(3);End.';
procedureTCompilerTestSimple.IfTest2;
begin
CompileRun(IfTest2Script);
CompileRun('Program IFSTest; type TShiftStates = (ssCtrl, ssShift); TShiftState = set of TShiftStates; var shift: TShiftState; Begin if shift = [ssCtrl, ssShift] then End.');