123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- {$mode macpas}
- {$r-}
- {$q-}
- procedure testlongintrot;
- const
- haltoffset = 0;
- var
- l : longint;
- begin
- l := 1;
- l := brotl(l,1);
- if (l <> 2) then
- halt(1+haltoffset);
- l := brotr(l,1);
- if (l <> 1) then
- halt(2+haltoffset);
- l := longint($80000001);
- l := brotl(l,2);
- if (l <> 6) then
- halt(3+haltoffset);
- l := brotr(l,3);
- if (l <> longint($c0000000)) then
- halt(4+haltoffset);
- l := brotr(l,2);
- // "longint($c0000000) shr 2" is evaluated using 64 bit :/
- if (l <> (longint(cardinal($c0000000) shr 2))) then
- halt(5+haltoffset);
- end;
- procedure testcardinalrot;
- const
- haltoffset = 5;
- var
- l : cardinal;
- begin
- l := 1;
- l := brotl(l,1);
- if (l <> 2) then
- halt(1+haltoffset);
- l := brotr(l,1);
- if (l <> 1) then
- halt(2+haltoffset);
- l := $80000001;
- l := brotl(l,2);
- if (l <> 6) then
- halt(3+haltoffset);
- l := brotr(l,3);
- if (l <> $c0000000) then
- halt(4+haltoffset);
- l := brotr(l,2);
- if (l <> (cardinal($c0000000) shr 2)) then
- halt(5+haltoffset);
- end;
- procedure testint64rot;
- const
- haltoffset = 10;
- var
- l : int64;
- begin
- l := 1;
- l := brotl(l,1);
- if (l <> 2) then
- halt(1+haltoffset);
- l := brotr(l,1);
- if (l <> 1) then
- halt(2+haltoffset);
- l := $80000001;
- l := brotl(l,2);
- if (l <> $200000004) then
- halt(3+haltoffset);
- l := brotr(l,3);
- if (l <> int64($8000000040000000)) then
- halt(4+haltoffset);
- l := brotr(l,2);
- if (l <> (int64($8000000040000000) shr 2)) then
- halt(5+haltoffset);
- end;
- procedure testqwordrot;
- const
- haltoffset = 15;
- var
- l : qword;
- begin
- l := 1;
- l := brotl(l,1);
- if (l <> 2) then
- halt(1+haltoffset);
- l := brotr(l,1);
- if (l <> 1) then
- halt(2+haltoffset);
- l := $80000001;
- l := brotl(l,2);
- if (l <> $200000004) then
- halt(3+haltoffset);
- l := brotr(l,3);
- if (l <> qword($8000000040000000)) then
- halt(4+haltoffset);
- l := brotr(l,2);
- if (l <> (qword($8000000040000000) shr 2)) then
- halt(5+haltoffset);
- end;
- procedure testlongintnot;
- const
- haltoffset = 20;
- var
- l, j : longint;
- begin
- l := low(longint);
- for j := 1 to (maxlongint div 13579) do
- begin
- if not(l) <> bnot(l) then
- halt(haltoffset+1);
- inc(l,13579*2);
- end;
- end;
- procedure testcardinalnot;
- const
- haltoffset = 21;
- var
- l, j : cardinal;
- begin
- l := 0;
- for j := 1 to (maxlongint div 13579) do
- begin
- if not(l) <> bnot(l) then
- halt(haltoffset+1);
- inc(l,13579*2);
- end;
- end;
- procedure testint64not;
- const
- haltoffset = 22;
- var
- l, j : int64;
- begin
- l := low(int64);
- j := 1;
- repeat
- if not(l) <> bnot(l) then
- halt(haltoffset+1);
- inc(l,int64(13579)*high(longint)*2);
- inc(j);
- until (j = (high(int64) div (int64(13579) * high(longint))));
- end;
- procedure testqwordnot;
- const
- haltoffset = 22;
- var
- l, j : qword;
- begin
- l := 0;
- j := 1;
- repeat
- if not(l) <> bnot(l) then
- halt(haltoffset+1);
- inc(l,int64(13579)*high(longint)*2);
- inc(j);
- until (j = (high(int64) div (int64(13579) * high(longint))));
- end;
- begin
- testlongintrot;
- testcardinalrot;
- testint64rot;
- testqwordrot;
- testlongintnot;
- testcardinalnot;
- testint64not;
- testqwordnot;
- end.
|