xref: /csrg-svn/usr.bin/pascal/pdx/test/setest.p (revision 62160)
148085Sbostic(*
2*62160Sbostic * Copyright (c) 1980, 1993
3*62160Sbostic *	The Regents of the University of California.  All rights reserved.
448085Sbostic *
548085Sbostic * %sccs.include.redist.c%
648085Sbostic *
7*62160Sbostic *	@(#)setest.p	8.1 (Berkeley) 06/06/93
848085Sbostic *)
948085Sbostic
1048085Sbosticprogram setest(input,output);
1148085Sbostic
1248085Sbostictype
1348085Sbosticaset = set of 1..41;
1448085Sbosticsint = 0 .. 30000;
1548085Sbostic
1648085Sbosticvar
1748085Sbosticset1, set2 :aset;
1848085Sbosticptr :^aset;
1948085Sbostici :sint;
2048085Sbostic
2148085Sbosticbegin
2248085Sbosticwriteln('Enter a number between 2 and 41.');
2348085Sbosticwriteln('Numbers 2, 10..12, 17, and 37 print "false" all others "true".');
2448085Sbostici := ord(input^);
2548085Sbosticread(i);
2648085Sbosticwriteln('i =',i:2);
2748085Sbosticwrite('The set opcodes work :');
2848085Sbosticset1 := [5..15];
2948085Sbosticset2 := [10];
3048085Sbosticif set1 * [23] = [] then
3148085Sbosticwrite(' []')
3248085Sbosticelse
3348085Sbosticwrite(false:6);
3448085Sbosticif set1-set2 <> [5..9,11..15] then
3548085Sbostic   write(false:6);
3648085Sbosticnew(ptr);
3748085Sbosticptr^ := [2,10,37,i];
3848085Sbosticset1 := ptr^ - [1..3];
3948085Sbosticset2 := ptr^ + [10..12,17];
4048085Sbosticif ptr^ * set1 = set1 then
4148085Sbostic   write(' mul plus minus')
4248085Sbosticelse
4348085Sbostic   write(false:6);
4448085Sbosticif (17 in [10..13,15..20,25..30]) and
4548085Sbostic   (not (22 in [1..17,36..41])) then
4648085Sbostic   write(' in')
4748085Sbosticelse
4848085Sbostic   write(false:6);
4948085Sbosticif (set1 <> set2) and
5048085Sbostic   (set1 <  set2) and
5148085Sbostic   (set2 >  set1) and
5248085Sbostic   (set2 >= ptr^) and
5348085Sbostic   (set1 <= set2) and
5448085Sbostic   (set1 >= set1) and
5548085Sbostic   (set1 <= set1) and
5648085Sbostic   (card(set2) = 7) then
5748085Sbostic   write(' and rel')
5848085Sbosticelse
5948085Sbostic   write(false:6);
6048085Sbosticif (set1 <> set1) or
6148085Sbostic   (set2 <  set1) or
6248085Sbostic   (set1 >  set2) or
6348085Sbostic   (ptr^ >= set2) or
6448085Sbostic   (set2 <= set1) or
6548085Sbostic   (set1 =  set2) or
6648085Sbostic   (17 in set2) then
6748085Sbostic   writeln(' or rel')
6848085Sbosticelse
6948085Sbostic   writeln(false:6);
7048085Sbostici := pred(i);
7148085Sbostici := (i + i) div i;
7248085Sbosticend.
73