123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- {****************************************************************}
- { CODE GENERATOR TEST PROGRAM }
- {****************************************************************}
- { NODE TESTED : secondfor() }
- {****************************************************************}
- { PRE-REQUISITES: secondload() }
- { secondassign() }
- { secondcalln() }
- { secondinline() }
- { secondadd() }
- {****************************************************************}
- { DEFINES: }
- {****************************************************************}
- { REMARKS: }
- {****************************************************************}
- program tfor;
- const LOOP_NUMS = 100;
- {$ifndef fpc}
- type cardinal = longint;
- {$endif}
- procedure fail;
- begin
- WriteLn('Failure.');
- halt(1);
- end;
- function getupper : longint;
- begin
- getupper:=LOOP_NUMS;
- end;
- function getupper0: longint;
- begin
- getupper0 := 1;
- end;
- {$ifdef fpc}
- function getupper64 : int64;
- begin
- getupper64:=1;
- end;
- function getupper64high : int64;
- begin
- getupper64high:=LOOP_NUMS;
- end;
- {$endif}
- var
- index_signed: longint;
- index_unsigned : cardinal;
- count:longint;
- count1 : longint;
- loop_count : longint;
- failed : boolean;
- {$ifdef fpc}
- index64 : int64;
- count64 : int64;
- count642 : int64;
- {$endif}
- begin
- loop_count:=0;
- count := LOOP_NUMS;
- count1 := LOOP_NUMS;
- { SIGNED INDEX }
- failed := false;
- Write('Signed index for loop testing (forward)...');
- { lowerbound : constant }
- { upper bound :: LOC_REFERENCE }
- for index_signed:=1 to count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=1 to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_CONSTANT }
- loop_count:=0;
- for index_signed:=1 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REFERENCE }
- { upper bound : constant }
- count:=1;
- loop_count:=0;
- for index_signed:=count to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=count to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_signed:=count to count1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REGISTER }
- { upper bound : constant }
- count:=0;
- loop_count:=0;
- for index_signed:=getupper0 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=getupper0 to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_signed:=getupper0 to count1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- if failed then
- fail
- else
- WriteLn('Passed!');
- { UNSIGNED INDEX }
- Write('Unsigned index for loop testing (forward)...');
- loop_count:=0;
- failed := false;
- count := LOOP_NUMS;
- count1 := LOOP_NUMS;
- { lowerbound : constant }
- { upper bound :: LOC_REFERENCE }
- for index_unsigned:=1 to count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=1 to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_CONSTANT }
- loop_count:=0;
- for index_unsigned:=1 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REFERENCE }
- { upper bound : constant }
- count:=1;
- loop_count:=0;
- for index_unsigned:=count to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=count to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_unsigned:=count to count1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REGISTER }
- { upper bound : constant }
- count:=0;
- loop_count:=0;
- for index_unsigned:=getupper0 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=getupper0 to getupper do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_unsigned:=getupper0 to count1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- if failed then
- fail
- else
- WriteLn('Passed!');
- (* UNSUPPORTED IN FPC VERSION 1.0.x (CEC)
- { --------------------- int64 testing!------------------- }
- WriteLn('int64 testing...');
- loop_count:=0;
- count64 := LOOP_NUMS;
- count1 := LOOP_NUMS;
- { SIGNED INDEX }
- failed := false;
- { lowerbound : constant }
- { upper bound :: LOC_REFERENCE }
- for index64:=1 to count64 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index64:=1 to getupper64high do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_CONSTANT }
- loop_count:=0;
- for index64:=1 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REFERENCE }
- { upper bound : constant }
- count64:=1;
- count642:=LOOP_NUMS;
- loop_count:=0;
- for index64:=count64 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index64:=count64 to getupper64high do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index64:=count64 to count642 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REGISTER }
- { upper bound : constant }
- count64:=LOOP_NUMS;
- loop_count:=0;
- for index64:=getupper64 to LOOP_NUMS do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index64:=getupper64 to getupper64high do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index64:=getupper64 to count64 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- if failed then
- fail
- else
- WriteLn('Passed!');
- *)
- loop_count:=0;
- count := LOOP_NUMS;
- count1 := LOOP_NUMS;
- { SIGNED INDEX }
- failed := false;
- Write('Signed index for loop testing (backward)...');
- { lowerbound : constant }
- { upper bound :: LOC_REFERENCE }
- for index_signed:=count downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=getupper downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_CONSTANT }
- loop_count:=0;
- for index_signed:=LOOP_NUMS downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REFERENCE }
- { upper bound : constant }
- count:=1;
- loop_count:=0;
- for index_signed:=LOOP_NUMS downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=getupper downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_signed:=count1 downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REGISTER }
- { upper bound : constant }
- count:=0;
- loop_count:=0;
- for index_signed:=LOOP_NUMS downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_signed:=getupper downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_signed:=count1 downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- if failed then
- fail
- else
- WriteLn('Passed!');
- { UNSIGNED INDEX }
- Write('Unsigned index for loop testing (backward)...');
- loop_count:=0;
- failed := false;
- count := LOOP_NUMS;
- count1 := LOOP_NUMS;
- { lowerbound : constant }
- { upper bound :: LOC_REFERENCE }
- for index_unsigned:=count downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=getupper downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_CONSTANT }
- loop_count:=0;
- for index_unsigned:=LOOP_NUMS downto 1 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REFERENCE }
- { upper bound : constant }
- count:=1;
- loop_count:=0;
- for index_unsigned:=LOOP_NUMS downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=getupper downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_unsigned:=count1 downto count do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { lowerbound : LOC_REGISTER }
- { upper bound : constant }
- count:=0;
- loop_count:=0;
- for index_unsigned:=LOOP_NUMS downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REGISTER }
- loop_count:=0;
- for index_unsigned:=getupper downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- { upper bound : LOC_REFERENCE }
- loop_count:=0;
- for index_unsigned:=count1 downto getupper0 do
- loop_count:=loop_count+1;
- if loop_count <> LOOP_NUMS then
- failed := true;
- if failed then
- fail
- else
- WriteLn('Passed!');
- end.
|