PROGRAM setranges7(output); { Written by: Mirsad Todorovac Nov 2001; copying by GPL. ------------------------------------------------------------ Stresses setrange construction and IN operator. (all possile intervals within 0..maxN range). Unexpectedly passed on 64 bit Alpha!!! (when SET initializations and adding and subtracting tests failed. more specifically designed tests are required to isolate the bug.) lasts few seconds where I've tested it. Warning: t ~ maxN^3} CONST maxN = 255; VAR seta, setb, setc: SET OF 0..maxN value [0..maxN]; i, j, len: Cardinal; start, endr: 0 .. maxN; extra: Boolean = false; missing: Boolean = false; extI, extS, extE, misI, misS, misE: 0..maxN; BEGIN {Test whether the set was initialized properly is mirsad03.pas} FOR len:= 1 TO maxN+1 DO FOR start:= 0 TO maxN-len+1 DO BEGIN endr := start+len-1; {writeln('constr. range = ', start, ',', endr);} FOR i:= 0 TO maxN DO BEGIN {It's sufficient for one example to fail to have found a bug!} {is i outside [start..endr] found in??? it shouldn't be.} IF (NOT extra AND((iendr))AND (i IN [start..endr]))THEN BEGIN extra := true; extI := i; extS := start; extE := endr; END; {is i, start<=i<=endr found in [start..endr] by IN operator??? if not, we've found a bug!} IF (NOT missing AND(i>=start)AND(i<=endr)AND NOT(i IN [start..endr])) THEN BEGIN missing := true; misI := i; misS := start; misE := endr; END END END; IF (NOT extra AND NOT missing) THEN writeln('OK') ELSE BEGIN write('Failed:'); IF (extra) THEN write(' extra: ',extI,' IN [',0,'..',maxN,']-[',extS,'..',extE,']'); IF (missing) THEN write(' miss: ',misI,' NOT IN [',0,'..',maxN,']-[',misS,'..',misE,']'); writeln; END; END.