1*44173Sbosticprogram errs(input,output,junk,locked); 2*44173Sbostic 3*44173Sbosticlabel 99; 4*44173Sbostic 5*44173Sbostictype 6*44173Sbosticetype = (ECHR, EHALT, ENILPTR, ECASE, EOUTOFMEM, ECTSNG, 7*44173SbosticESTLIM, EARGV, EPACK, EUNPACK, EASRT, ELLIMIT, ETRASHHEAP, EPASTEOF, 8*44173SbosticEREFINAF, ENOFILE, ENAMESIZE, EBADINUM, EBADFNUM, ENUMNTFD, ENAMRNG, 9*44173SbosticEFMTSIZE, ESEEK, ECREATE, EREMOVE, EOPEN, EREADIT, EWRITEIT, ESQRT, 10*44173SbosticELN, ERANGE, ESUBSC, EGOTO, ECLOSE, EWRITE, ECTLWR, ECTUPR, xxx); 11*44173Sbosticbiggie = array[1..15000] of integer; 12*44173Sbostic 13*44173Sbosticvar 14*44173Sbosticch :char; 15*44173Sbosticchs :alfa; 16*44173Sbosticch1 :array[1..10] of char; 17*44173Sbosticptr, ptr1 :^char; 18*44173Sbosticptr2 :^biggie; 19*44173Sbosticjunk, locked, other :file of char; 20*44173Sbosticvariant :record 21*44173Sbostic case boolean of 22*44173Sbostic true:(val :1..100); 23*44173Sbostic false:(name :etype) 24*44173Sbostic end; 25*44173Sbostics :set of 1..4; 26*44173Sbostici :integer; 27*44173Sbosticr :real; 28*44173Sbosticerr :etype; 29*44173Sbostic 30*44173Sbosticbegin 31*44173Sbosticwriteln('Want a list of error names?'); 32*44173Sbosticreadln(ch); 33*44173Sbosticif ch = 'y' then begin 34*44173Sbostic for err:=ECHR to pred(xxx) do begin 35*44173Sbostic write(err:15); 36*44173Sbostic if ord(err) mod 5 = 4 then 37*44173Sbostic writeln; 38*44173Sbostic end; 39*44173Sbostic writeln; 40*44173Sbostic end; 41*44173Sbosticwriteln('enter an error name'); 42*44173Sbosticreadln(err); 43*44173Sbosticif err in [ESEEK, EGOTO, ECLOSE, EWRITE] then begin 44*44173Sbostic writeln(err, ': error cannot be simulated'); 45*44173Sbostic goto 99; 46*44173Sbostic end; 47*44173Sbosticcase err of 48*44173SbosticECHR: ch:=chr(128); 49*44173SbosticEHALT: halt; 50*44173SbosticENILPTR: ch:=ptr^; 51*44173SbosticECASE: case 4 of 1:; end; 52*44173SbosticEOUTOFMEM: while true do begin 53*44173Sbostic new(ptr2); 54*44173Sbostic writeln('alloc successful'); 55*44173Sbostic end; 56*44173SbosticECTLWR: begin 57*44173Sbostic i:=0; 58*44173Sbostic s:=[i..2]; 59*44173Sbostic end; 60*44173SbosticECTUPR: begin 61*44173Sbostic i:=5; 62*44173Sbostic s:=[1..i]; 63*44173Sbostic end; 64*44173SbosticECTSNG: begin 65*44173Sbostic i:=0; 66*44173Sbostic s:=[i]; 67*44173Sbostic end; 68*44173SbosticESTLIM: stlimit(0); 69*44173SbosticEARGV: argv(100,chs); 70*44173SbosticEPACK: pack(ch1,2,chs); 71*44173SbosticEUNPACK: unpack(chs,ch1,2); 72*44173SbosticEASRT: assert(false); 73*44173SbosticELLIMIT: begin 74*44173Sbostic linelimit(output,1); 75*44173Sbostic writeln('This only should print'); 76*44173Sbostic writeln; 77*44173Sbostic writeln('ERROR'); 78*44173Sbostic end; 79*44173SbosticETRASHHEAP: begin 80*44173Sbostic new(ptr); 81*44173Sbostic ptr1:=ptr; 82*44173Sbostic dispose(ptr1); 83*44173Sbostic dispose(ptr); 84*44173Sbostic end; 85*44173SbosticEPASTEOF: begin 86*44173Sbostic rewrite(junk); 87*44173Sbostic reset(junk); 88*44173Sbostic get(junk); 89*44173Sbostic get(junk); 90*44173Sbostic write(junk^); 91*44173Sbostic end; 92*44173SbosticEREFINAF: ch:=junk^; 93*44173SbosticENOFILE: ch:=other^; 94*44173SbosticENAMESIZE: rewrite(junk, 95*44173Sbostic'thisisaverylongandconvolutedfilenamewhichexceedsalllimitsofreasonablenessandgoodtaste'); 96*44173SbosticEBADINUM: begin 97*44173Sbostic writeln('Enter a letter'); 98*44173Sbostic read(i); 99*44173Sbostic end; 100*44173SbosticEBADFNUM: begin 101*44173Sbostic writeln('Enter a letter'); 102*44173Sbostic read(r); 103*44173Sbostic end; 104*44173SbosticENUMNTFD: begin 105*44173Sbostic writeln('Enter your name'); 106*44173Sbostic read(err); 107*44173Sbostic end; 108*44173SbosticENAMRNG: begin 109*44173Sbostic variant.val:=100; 110*44173Sbostic writeln(variant.name); 111*44173Sbostic end; 112*44173SbosticEFMTSIZE: begin 113*44173Sbostic i:=-1; 114*44173Sbostic writeln(1.0:i); 115*44173Sbostic end; 116*44173SbosticECREATE: rewrite(locked); 117*44173SbosticEREMOVE: remove('none'); 118*44173SbosticEOPEN: reset(locked); 119*44173SbosticEREADIT: read(output,ch); 120*44173SbosticEWRITEIT: write(input,ch); 121*44173SbosticESQRT: r:=sqrt(-1.0); 122*44173SbosticELN: r:=ln(0); 123*44173SbosticERANGE: ch:=succ(chr(127)); 124*44173SbosticESUBSC: ch:=ch1[127 + 1]; 125*44173Sbosticend; 126*44173Sbosticwriteln('*** ERROR NOT DETECTED ***'); 127*44173Sbostic99:end. 128