| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- program t74_caselist;
- { t74 -- comma-separated CASE labels, and ranges that actually work.
- CALC.INC's IBMCh has
- 'G', 'I', 'O', 'Q': Ch := #00;
- The parser read ONE label and then demanded ':', so the list was ENoSemi.
- While fixing that, the range emitter turned out to be wrong too: it compared
- the selector with lo and then with hi, BOTH requiring equality, so `1..5'
- matched nothing unless lo = hi. A minimal probe (i := 3; case i of 1..5)
- printed the ELSE arm. No error, just a wrong answer - which is why this
- fixture pins the low edge, the high edge, a list mixing values and ranges,
- and misses on both a char list and a range list. }
- var
- c : char;
- i : integer;
- begin
- c := 'I';
- case c of
- 'G', 'I', 'O', 'Q': writeln ('group')
- else
- writeln ('other')
- end;
- c := 'A';
- case c of
- 'G', 'I', 'O', 'Q': writeln ('group')
- else
- writeln ('other')
- end;
- i := 3;
- case i of
- 1..5: writeln ('range')
- else
- writeln ('outside')
- end;
- i := 5;
- case i of
- 1..5: writeln ('range')
- else
- writeln ('outside')
- end;
- i := 7;
- case i of
- 1..5, 7, 9..10: writeln ('list')
- else
- writeln ('miss')
- end;
- i := 8;
- case i of
- 1..5, 7, 9..10: writeln ('list')
- else
- writeln ('miss')
- end;
- i := 10;
- case i of
- 1..5, 7, 9..10: writeln ('list')
- else
- writeln ('miss')
- end
- end.
|