tw29906.pp 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {$mode objfpc}
  2. type
  3. tsub = 1..19;
  4. function test(s: tsub): longint;
  5. begin
  6. { use different number of instructions for several cases so wrongly
  7. calculated jump table offsets are more likely to wreak havoc }
  8. case s of
  9. 1:
  10. result:=1;
  11. 2:
  12. begin
  13. writeln('two');
  14. result:=2;
  15. end;
  16. 3:
  17. begin
  18. s:=4;
  19. result:=3;
  20. end;
  21. 4:
  22. begin
  23. result:=4;
  24. s:=s*s+result;
  25. end;
  26. 5:
  27. result:=5;
  28. 6:
  29. result:=6;
  30. 7:
  31. begin
  32. s:=s+s*s div s;
  33. result:=7;
  34. end;
  35. 8:
  36. result:=8;
  37. 9:
  38. result:=9;
  39. 10:
  40. result:=10;
  41. 11:
  42. result:=11;
  43. 12:
  44. result:=12;
  45. 13:
  46. result:=13;
  47. 14:
  48. result:=14;
  49. 15:
  50. result:=15;
  51. 16:
  52. result:=16;
  53. 17:
  54. result:=17;
  55. 18:
  56. result:=18;
  57. 19:
  58. result:=19;
  59. end;
  60. end;
  61. var
  62. i: tsub;
  63. begin
  64. for i:=low(tsub) to high(tsub) do
  65. if test(i)<>i then
  66. halt(i);
  67. end.