Advertisement
paul_nicholls

Untitled

Feb 6th, 2024
1,280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.18 KB | None | 0 0
  1. program testSuite;
  2.  
  3. uses
  4.   uTests;
  5.  
  6. begin
  7.   runTests;
  8. end.
  9.  
  10. //---------------------------
  11.  
  12. unit uTests;
  13.  
  14. uses
  15.   c64_vic;
  16.  
  17. var
  18.   x,y   : Byte;
  19.   count : Word;
  20.  
  21. //----------------------------
  22. function test1 : Boolean;
  23. var
  24.   a,b : Word;
  25. begin
  26.   a := 4;
  27.   Result := (a < word(10));
  28. end;
  29. //----------------------------
  30. function test2 : Boolean;
  31. var
  32.   a,b : Word;
  33. begin
  34.   a := 5;
  35.   Result := (a <= word(5));
  36. end;
  37. //----------------------------  
  38. function test3 : Boolean;
  39. var
  40.   a,b : Word;
  41. begin
  42.   a := 5;
  43.   Result := (a = word(5));
  44. end;
  45. //----------------------------
  46. function test4 : Boolean;
  47. var
  48.   a,b : Word;
  49. begin
  50.   a := 20;
  51.   b := 19;
  52.   Result := b < a;
  53. end;
  54. //----------------------------
  55. function test5 : Boolean;
  56. var
  57.   a,b : Word;
  58. begin
  59.   a := 20;
  60.   b := 20;
  61.   Result := a <= b;
  62. end;
  63. //----------------------------
  64. function test6 : Boolean;
  65. var
  66.   a,b : Word;
  67. begin
  68.   a := 30;
  69.   b := 19;
  70.   Result := a > b;
  71. end;
  72. //----------------------------
  73. function test7 : Boolean;
  74. var
  75.   a,b : Word;
  76. begin
  77.   a := 30;
  78.   b := 30;
  79.   Result := a >= b;
  80. end;
  81. //----------------------------
  82.  
  83. const
  84.   rString : String = 'ft';
  85.   rColor  : array of Byte = (cyan,green);
  86.  
  87. procedure doTest(v : Byte);
  88. var
  89.   r   : Byte;
  90.   ofs : Word;
  91.   c   : Byte;
  92. begin
  93.   r := v and 1;
  94.  
  95.   ofs := y * 40;
  96.   ofs := ofs + x;
  97.  
  98.   // draw test number
  99.   c := 48+((count shr 8) and $0f);
  100.   poke(1024 + 0 + ofs,c);
  101.  
  102.   c := 48+((count shr 4) and $0f);
  103.   poke(1024 + 1 + ofs,c);
  104.  
  105.   c := 48+(count and $0f);
  106.   poke(1024 + 2 + ofs,c);
  107.  
  108.   // draw test result
  109.   poke(1024  + 4 + ofs,rString[r+1]);
  110.   poke($d800 + 4 + ofs,rColor[r]);
  111.  
  112.   y := y + 1;
  113.  
  114.   if y = 24 then begin
  115.     y := 0;
  116.     x := x + 6;
  117.   end;
  118.  
  119.   decimalModeOn;
  120.   count := count + 1;
  121.   decimalModeOff;
  122. end;
  123.  
  124. procedure runTests;
  125. var
  126.   i : Byte;
  127. begin
  128.   vic_clearScreen(1024,32);
  129.   vic_clearScreen($d800,white);
  130.   vic_border    := black;
  131.   vic_bg_color0 := black;
  132.  
  133.   x := 0;
  134.   y := 0;
  135.   count := $0001;
  136.  
  137.   doTest(test1);    
  138.   doTest(test2);    
  139.   doTest(test3);
  140.   doTest(test4);    
  141.   doTest(test5);    
  142.   doTest(test6);
  143.  
  144.   while true do;  
  145. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement