123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- { Program to test Code generator secondadd() }
- { with int64 values }
- { FUNCTIONAL PRE-REQUISITES: }
- { - assignments function correctly. }
- { - if statements function correctly. }
- { - subroutine calls function correctly. }
- procedure fail;
- begin
- WriteLn('Failed!');
- halt(1);
- end;
- procedure int64TestAdd;
- var
- i: int64;
- j: int64;
- result : boolean;
- begin
- Write('int64 + int64 test...');
- result := true;
- i:=0;
- j:=0;
- i := i + -10000;
- if i <> -10000 then
- result := false;
- j := 32767;
- i := i + j;
- if i <> 22767 then
- result := false;
- i := i + j + 50000;
- if i <> 105534 then
- result := false;
- i:=0;
- j:=10000;
- i:= i + j + j + i + j;
- if i <> 30000 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestSub;
- var
- i, j, k : int64;
- result : boolean;
- begin
- Write('int64 - int64 test...');
- result := true;
- i:=100000;
- j:=54;
- k:=56;
- i:= i - 100;
- if i <> 99900 then
- result := false;
- i := i - j - k - 100;
- if i <> 99690 then
- result := false;
- i:=100;
- j:=1000;
- k:=100;
- i:= j - i - k;
- if i <> 800 then
- result := false;
- j := 900 - i;
- if (j <> 100) then
- result := false;
- i := 1000000000;
- k := i;
- i := i * 10;
- j := 1000000000 - i;
- k := k - i;
- if j <> k then
- result := false;
- if j <> (1000000000-(int64(1000000000) * 10)) then
- result := false;
- j := (int64(1) shl 33);
- i := (int64(1) shl 34) - j;
- if (i <> (int64(1) shl 33)) then
- result := false;
- i := 1 - j;
- if (i <> (1-(int64(1) shl 33))) then
- result := false;
- i := 100000;
- i := i - 90000;
- if (i <> 10000) then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestMul;
- var
- i : int64;
- j : int64;
- k: int64;
- result: boolean;
- begin
- Write('int64 * int64 test...');
- result := true;
- i:=0;
- j:=0;
- i:=i * 32;
- if i <> 0 then
- result := false;
- i:=10;
- i:=i * -16;
- if i <> -160 then
- result := false;
- j:=10000;
- i:=-10000;
- i:=i * j;
- if i <> -100000000 then
- result := false;
- i:=1;
- j:=10;
- k:=16;
- i := i * j * k;
- if i <> 160 then
- result := false;
- i := 1;
- j := 10;
- k := 16;
- i := i * 10 * j * i * j * 16 * k;
- if i <> 256000 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestXor;
- var
- i, j : int64;
- result : boolean;
- begin
- Write('int64 XOR int64 test...');
- result := true;
- i := 0;
- j := 0;
- i := i xor $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i xor j;
- if i <> $10000001 then
- result := false;
- i := 0;
- j := $55555555;
- i := i xor j xor $AAAAAAAA;
- if i <> $FFFFFFFF then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestOr;
- var
- i,j : int64;
- result : boolean;
- Begin
- Write('int64 OR int64 test...');
- result := true;
- i := 0;
- j := 0;
- i := i or $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i or j;
- if i <> $10000001 then
- result := false;
- i := 0;
- j := $55555555;
- i := i or j or $AAAAAAAA;
- if i <> $FFFFFFFF then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestAnd;
- var
- i,j : int64;
- result : boolean;
- Begin
- Write('int64 AND int64 test...');
- result := true;
- i := $1000001;
- j := 0;
- i := i and $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i and j;
- if i <> 0 then
- result := false;
- i := $FFFFFFFF;
- j := $55555555;
- i := i and j;
- if i <> $55555555 then
- result := false;
- i := $FFFFFFFF;
- i := i and $AAAAAAAA;
- if i <> $AAAAAAAA then
- result := false;
- i := 0;
- j := $55555555;
- i := i and j and $AAAAAAAA;
- if i <> 0 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestEqual;
- var
- i,j : int64;
- result : boolean;
- Begin
- Write('int64 = int64 test...');
- result := true;
- i := $1000001;
- j := 0;
- if i = 0 then
- result := false;
- if i = j then
- result := false;
- if j = i then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestNotEqual;
- var
- i,j : int64;
- result : boolean;
- Begin
- Write('int64 <> int64 test...');
- result := true;
- i := $1000001;
- j := $1000001;
- if i <> $1000001 then
- result := false;
- if i <> j then
- result := false;
- if j <> i then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure int64TestLE;
- var
- i, j: int64;
- result : boolean;
- begin
- Write('int64 <= int64 test...');
- result := true;
- i := -1;
- j := -2;
- if i <= j then
- result := false;
- i := -2;
- j := $FFFF;
- if i >= j then
- result := false;
- i := $FFFFFFFF;
- if i <= $FFFFFFFE then
- result := false;
- j := $FFFFFFFF;
- if i <= j then
- begin
- if result then
- WriteLn('Success.')
- else
- Fail;
- end
- else
- Fail;
- end;
- procedure int64TestGE;
- var
- i, j: int64;
- result : boolean;
- begin
- Write('int64 >= int64 test...');
- result := true;
- i := $FFFFFFFE;
- j := $FFFFFFFF;
- if i >= j then
- result := false;
- i := $FFFFFFFE;
- j := $FFFFFFFF;
- if i > j then
- result := false;
- i := $FFFFFFFE;
- if i > $FFFFFFFE then
- result := false;
- i := $FFFFFFFF;
- j := $FFFFFFFF;
- if i >= j then
- begin
- if result then
- WriteLn('Success.')
- else
- Fail;
- end
- else
- Fail;
- end;
- { QWord testing }
- procedure qwordTestAdd;
- var
- i: qword;
- j: qword;
- result : boolean;
- begin
- Write('qword + qword test...');
- result := true;
- i:=0;
- j:=0;
- i := i + 10000;
- if i <> 10000 then
- result := false;
- j := 32767;
- i := i + j;
- if i <> 42767 then
- result := false;
- i := i + j + 50000;
- if i <> 125534 then
- result := false;
- i:=0;
- j:=10000;
- i:= i + j + j + i + j;
- if i <> 30000 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestSub;
- var
- i, j, k : qword;
- result : boolean;
- begin
- Write('qword - qword test...');
- result := true;
- i:=100000;
- j:=54;
- k:=56;
- i:= i - 100;
- if i <> 99900 then
- result := false;
- i := i - j - k - 100;
- if i <> 99690 then
- result := false;
- i:=100;
- j:=1000;
- k:=100;
- i:= j - i - k;
- if i <> 800 then
- result := false;
- j := 900 - i;
- if (j <> 100) then
- result := false;
- i := 1000000000;
- k := i;
- i := i * 10;
- j := 1000000000 - i;
- k := k - i;
- if j <> k then
- result := false;
- if j <> (1000000000-(qword(1000000000) * 10)) then
- result := false;
- j := (qword(1) shl 33);
- i := (qword(1) shl 34) - j;
- if (i <> (qword(1) shl 33)) then
- result := false;
- i := 1 - j;
- if (i <> (1-(qword(1) shl 33))) then
- result := false;
- i := 100000;
- i := i - 90000;
- if (i <> 10000) then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestMul;
- var
- i : qword;
- j : qword;
- k: qword;
- result: boolean;
- begin
- Write('qword * qword test...');
- result := true;
- i:=0;
- j:=0;
- i:=i * 32;
- if i <> 0 then
- result := false;
- i:=10;
- i:=i * 16;
- if i <> 160 then
- result := false;
- j:=10000;
- i:=10000;
- i:=i * j;
- if i <> 100000000 then
- result := false;
- i:=1;
- j:=10;
- k:=16;
- i := i * j * k;
- if i <> 160 then
- result := false;
- i := 1;
- j := 10;
- k := 16;
- i := i * 10 * j * i * j * 16 * k;
- if i <> 256000 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestXor;
- var
- i, j : qword;
- result : boolean;
- begin
- Write('qword XOR qword test...');
- result := true;
- i := 0;
- j := 0;
- i := i xor $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i xor j;
- if i <> $10000001 then
- result := false;
- i := 0;
- j := $55555555;
- i := i xor j xor $AAAAAAAA;
- if i <> $FFFFFFFF then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestOr;
- var
- i,j : qword;
- result : boolean;
- Begin
- Write('qword OR qword test...');
- result := true;
- i := 0;
- j := 0;
- i := i or $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i or j;
- if i <> $10000001 then
- result := false;
- i := 0;
- j := $55555555;
- i := i or j or $AAAAAAAA;
- if i <> $FFFFFFFF then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestAnd;
- var
- i,j : qword;
- result : boolean;
- Begin
- Write('qword AND qword test...');
- result := true;
- i := $1000001;
- j := 0;
- i := i and $1000001;
- if i <> $1000001 then
- result := false;
- i:=0;
- j:=$10000001;
- i:=i and j;
- if i <> 0 then
- result := false;
- i := $FFFFFFFF;
- j := $55555555;
- i := i and j;
- if i <> $55555555 then
- result := false;
- i := $FFFFFFFF;
- i := i and $AAAAAAAA;
- if i <> $AAAAAAAA then
- result := false;
- i := 0;
- j := $55555555;
- i := i and j and $AAAAAAAA;
- if i <> 0 then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestEqual;
- var
- i,j : qword;
- result : boolean;
- Begin
- Write('qword = qword test...');
- result := true;
- i := $1000001;
- j := 0;
- if i = 0 then
- result := false;
- if i = j then
- result := false;
- if j = i then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestNotEqual;
- var
- i,j : qword;
- result : boolean;
- Begin
- Write('qword <> qword test...');
- result := true;
- i := $1000001;
- j := $1000001;
- if i <> $1000001 then
- result := false;
- if i <> j then
- result := false;
- if j <> i then
- result := false;
- if not result then
- Fail
- else
- WriteLn('Success.');
- end;
- procedure QwordTestLE;
- var
- i, j: qword;
- result : boolean;
- begin
- Write('qword <= qword test...');
- result := true;
- i := 1;
- j := 2;
- if j <= i then
- result := false;
- i := 2;
- j := $FFFF;
- if i >= j then
- result := false;
- i := $FFFFFFFF;
- if i <= $FFFFFFFE then
- result := false;
- j := $FFFFFFFF;
- if i <= j then
- begin
- if result then
- WriteLn('Success.')
- else
- Fail;
- end
- else
- Fail;
- end;
- procedure QwordTestGE;
- var
- i, j: qword;
- result : boolean;
- begin
- Write('qword >= qword test...');
- result := true;
- i := $FFFFFFFE;
- j := $FFFFFFFF;
- if i >= j then
- result := false;
- i := $FFFFFFFE;
- j := $FFFFFFFF;
- if i > j then
- result := false;
- i := $FFFFFFFE;
- if i > $FFFFFFFE then
- result := false;
- i := $FFFFFFFF;
- j := $FFFFFFFF;
- if i >= j then
- begin
- if result then
- WriteLn('Success.')
- else
- Fail;
- end
- else
- Fail;
- end;
- Begin
- { These should be tested first, since if they do not }
- { work, they will false all other results. }
- Int64TestEqual;
- Int64TestNotEqual;
- Int64TestAdd;
- Int64TestMul;
- Int64TestOr;
- Int64TestAnd;
- Int64TestXor;
- Int64TestLe;
- Int64TestGe;
- Int64TestSub;
- QwordTestEqual;
- QwordTestNotEqual;
- QwordTestAdd;
- QwordTestMul;
- QwordTestOr;
- QwordTestAnd;
- QwordTestXor;
- QwordTestLe;
- QwordTestGe;
- QwordTestSub;
- end.
- {
- $Log$
- Revision 1.7 2002-09-29 14:37:22 carl
- * must more 64-bit testing (to detect endian specific problems)
- Revision 1.6 2002/09/08 20:29:36 jonas
- * some extra int64 - int64 tests for RISC processors
- Revision 1.5 2002/09/07 15:40:49 peter
- * old logs removed and tabs fixed
- Revision 1.4 2002/04/13 21:02:48 carl
- * fixed typos
- Revision 1.3 2002/03/05 21:55:11 carl
- * Adapted for automated testing
- Revision 1.2 2001/06/24 23:58:14 carl
- * fixed problem with log
- }
|