         Edinburgh IMP77 Compiler - Version 8.4

    1  !* Program Name : SCOMP
    2  
    3  !*   Title      :  IV.d   The IMP  SHORT  Facilities
    4  !*   Version    :  II
    5  !*   Date       :  24 August 1985
    6  !*   Description:  Tests all the SHORT comparison operators.
    7  
    8  %Begin
    9  
   10     %string(255) param  {Used to get input from CLI}
   11  
   12     %Short %Integer J
   13     %Short %Integer K
   14  
   15     %Constant %Short %Integer  CInt3 = 10
   16     %Constant %Short %Integer  CInt4 = 3
   17  
   18  %owninteger failures=0
   19  
   20  %routine pass
   21    printstring("Pass")
   22    New Line
   23  %end
   24  %routine fail
   25    printstring("FAIL")
   26    New Line
   27    failures = failures+1
   28  %end
   29  
   30     %Short %Integer %Function  F
   31  
   32       !*  An extremely simple short integer function that merely
   33       !*  returns the number THREE.  Note that this function 
   34       !*  does not presuppose parameter passing or expression
   35       !*  evaluation within functions.  It merely tests the
   36       !*  ability to encorporate functions within expressions. 
   37                                                             
   38       %Result = 3
   39  
   40      %End
   41  
   42     ! Code to find out where the output is to be sent
   43     ! -----------------------------------------------
   44     ! Where the output goes to depends on the parameter after the
   45     ! name used to run the program.
   46     !                       Parameter   |   Result
   47     !                       ------------|-------------
   48     !                     No parameter  |  No output
   49     !                          "s"      |  The screen
   50     !                          "j"      |  "journal"
   51     !                     anything else |  file name entered
   52  
   53     ! NOTE THAT THIS CODE USES STRING COMPARISONS, WHICH MAY NOT HAVE BEEN
   54     ! TESTED YET. IF THE PROGRAM FAILS CHECK IT WAS NOT IN THIS PART.
   55  
   56     param=cliparam
   57     %if param = "" %then select output (2) %c
   58+    %else %if param="s" %or param="S" %then select output(1) %c
   59+    %else %if param="j" %or param="J" %then  %c
   60+       open output(2,"journal") %and select output (2) %c
   61+    %else open output(2,param) %and select output (2)
   62     
   63  
   64  
   65     New Lines(2)
   66     Print String("SHORT INTEGER Arithmetic Validation");   New Line
   67     Print String("===================================");   New Lines (3)
   68  
   69     Print String("Test the Six Simple Relational Comparators");  New Line
   70     Print String("------------------------------------------");  New Lines (3)
   71  
   72  
   73  
   74     !*    Test the simple relational operations between Short Integers
   75  
   76  
   77  
   78  
   79     New Line
   80     Print String("Test for Short Integer Equality")
   81     New Line
   82     Print String("-------------------------------")
   83     New Line
   84  
   85     %If 3 = 3 %then pass %else fail
   86     %If CInt4 = 3 %then pass %else fail
   87     %If 3 = CInt4 %then pass %else fail
   88     %If CInt4 = CInt4 %then pass %else fail
   89  
   90     J = CInt4
   91     K = CInt4
   92  
   93     %If J = CInt4 %then pass %else fail
   94     %If CInt4 = J %then pass %else fail
   95     %If J = K %then pass %else fail
   96     %If J = J %then pass %else fail
   97     %If J = 3 %then pass %else fail
   98     %If 3 = J %then pass %else fail
   99     %If 3 = F %then pass %else fail
  100     %If F = 3 %then pass %else fail
  101     %If F * 3 + 10 = F * F + 5 * 2 %then pass %else fail
  102  
  103  
  104  
  105     New Line
  106     Print String("Test for Short Integer Inequality  ")
  107     New Line
  108     Print String("---------------------------------")
  109     New Line
  110  
  111     %If 3 # 3 %then fail %else pass
  112     %If CInt4 # 3 %then fail %else pass
  113     %If 3 # CInt4 %then fail %else pass
  114     %If CInt4 # CInt4 %then fail %else pass
  115     %If J # CInt4 %then fail %else pass
  116     %If CInt4 # J %then fail %else pass
  117     %If J # K %then fail %else pass
  118     %If J # J %then fail %else pass
  119     %If J # 3 %then fail %else pass
  120     %If 3 # J %then fail %else pass
  121     %If  3 # F %then fail %else pass
  122     %If  F # 3 %then fail %else pass
  123  
  124   
  125  
  126     New Line
  127     Print String("Test for LESS THAN in Short Integers  ")
  128     New Line
  129     Print String("------------------------------------")
  130     New Line
  131  
  132     J = CInt4
  133  
  134     %If 3 < 3 %then fail %else pass
  135     %If 3 < J %then fail %else pass
  136     %If J < 3 %then fail %else pass
  137     %If 3 < CInt4 %then fail %else pass
  138     %If CInt4 < 3 %then fail %else pass
  139     %If J < CInt4 %then fail %else pass
  140     %If CInt4 < J %then fail %else pass
  141     %If CInt4 < CInt4 %then fail %else pass
  142     %If J < J %then fail %else pass
  143     %If F < 3 %then fail %else pass
  144  
  145  
  146  
  147     New Line
  148     Print String ("Test for LESS THAN OR EQUALS in Short Integers  ")
  149     New Line
  150     Print String("----------------------------------------------")
  151     New Line
  152  
  153     J = CInt4
  154  
  155     %If 3 <= 3 %then pass %else fail
  156     %If 3 <= J %then pass %else fail
  157     %If J <= 3 %then pass %else fail
  158     %If 3 <= CInt4 %then pass %else fail
  159     %If CInt4 <= 3 %then pass %else fail
  160     %If J <= CInt4 %then pass %else fail
  161     %If CInt4 <= J %then pass %else fail
  162     %If CInt4 <= CInt4 %then pass %else fail
  163     %If J <= J %then pass %else fail
  164     %If F <= 3 %then pass %else fail
  165  
  166  
  167  
  168     New Line
  169     Print String("Test for GREATER THAN in Short Integers  ")
  170     New Line
  171     Print String("---------------------------------------")
  172     New Line
  173  
  174     J = CInt4
  175  
  176     %If 3 > 3 %then fail %else pass
  177     %If 3 > J %then fail %else pass
  178     %If J > 3 %then fail %else pass
  179     %If CInt4 > 3 %then fail %else pass
  180     %If J > CInt4 %then fail %else pass
  181     %If CInt4 > J %then fail %else pass
  182     %If CInt4 > CInt4 %then fail %else pass
  183     %If J > J %then fail %else pass
  184     %If F > 3 %then fail %else pass
  185  
  186  
  187  
  188     New Line
  189     Print String("Test for GREATER THAN OR EQUALS in Short Integers  ")
  190     New line
  191     Print String("-------------------------------------------------")
  192     New Line
  193  
  194     J = CInt4
  195  
  196     %If 3 >= 3 %then pass %else fail
  197     %If 3 >= J %then pass %else fail
  198     %If J >= 3 %then pass %else fail
  199     %If 3 >= CInt4 %then pass %else fail
  200     %If CInt4 >= 3 %then pass %else fail
  201     %If J >= CInt4 %then pass %else fail
  202     %If CInt4 >= J %then pass %else fail
  203     %If CInt4 >= CInt4 %then pass %else fail
  204     %If J >= J %then pass %else fail
  205     %If F >= 3 %then pass %else fail
  206  
  207  
  208  
  209     New Line
  210     Print String("Second test for Short Integer Equality  ")
  211     New Line
  212     Print String("--------------------------------------")
  213     New Line
  214  
  215     %If 3 = 10 %then fail %else pass
  216     %If CInt4 = 10 %then fail %else pass
  217     %If 10 = CInt4 %then fail %else pass
  218     %If CInt4 = CInt3 %then fail %else pass
  219     
  220     J = CInt4
  221     K = CInt3
  222  
  223     %If J = CInt3 %then fail %else pass
  224     %If CInt3 = J %then fail %else pass
  225     %If J = K %then fail %else pass
  226     %If J = 10 %then fail %else pass
  227     %If 10 = J %then fail %else pass
  228  
  229  
  230  
  231     New Line
  232     Print String("Second test for Short Integer Inequality  ")
  233     New Line
  234     Print String("----------------------------------------")
  235     New Line
  236  
  237     %If 3 # 10 %then pass %else fail
  238     %If CInt4 # 10 %then pass %else fail
  239     %If 10 # CInt4 %then pass %else fail
  240     %If CInt4 # CInt3 %then pass %else fail
  241     %If J # CInt3 %then pass %else fail
  242     %If CInt3 # J %then pass %else fail
  243     %If J # K %then pass %else fail
  244     %If J # 10 %then pass %else fail
  245     %If 10 # J %then pass %else fail
  246  
  247  
  248   
  249     New Line
  250     Print String ("Second test for LESS THAN in Short Integers  ")
  251     New Line
  252     Print String("-------------------------------------------")
  253     New Line
  254  
  255     %If 3 < 10 %then pass %else fail
  256     %If 10 < J %then fail %else pass
  257     %If J < 10 %then pass %else fail
  258     %If 10 < CInt4 %then fail %else pass
  259     %If CInt4 < 10 %then pass %else fail
  260     %If J < CInt3 %then pass %else fail
  261     %If CInt3 < J %then fail %else pass
  262     %If CInt4 < CInt3 %then pass %else fail
  263  
  264  
  265  
  266     New Line
  267     Print String("Second test for LESS THAN OR EQUALS in Short Integers  ")
  268     New Line
  269     Print String("-----------------------------------------------------")
  270     New Line
  271  
  272     %If 3 <= 10 %then pass %else fail
  273     %If 10 <= J %then fail %else pass
  274     %If J <= 10 %then pass %else fail
  275     %If 10 <= CInt4 %then fail %else pass
  276     %If CInt4 <= 10 %then pass %else fail
  277     %If J <= CInt3 %then pass %else fail
  278     %If CInt3 <= J %then fail %else pass
  279     %If CInt4 <= CInt3 %then pass %else fail
  280     %If J <= J %then pass %else fail
  281  
  282  
  283  
  284     New Line
  285     Print String("Second test for GREATER THAN in Short Integers  ")
  286     New Line
  287     Print String("----------------------------------------------")
  288     New Line
  289  
  290     %If 3 > 10 %then fail %else pass
  291     %If 10 > J %then pass %else fail
  292     %If J > 10 %then fail %else pass
  293     %If 3 > CInt3 %then fail %else pass
  294     %If CInt4 > 10 %then fail %else pass
  295     %If J > CInt3 %then fail %else pass
  296     %If CInt3 > J %then pass %else fail
  297     %If CInt4 > CInt3 %then fail %else pass
  298  
  299  
  300  
  301     New Line
  302     Print String("Second test for GREATER THAN OR EQUALS in Short Integers  ")
  303     New Line
  304     Print String("--------------------------------------------------------")
  305     New Line
  306  
  307     %If 10 >= 3 %then pass %else fail
  308     %If 10 >= J %then pass %else fail
  309     %If J >= 10 %then fail %else pass
  310     %If 10 >= CInt4 %then pass %else fail
  311     %If CInt3 >= 3 %then pass %else fail
  312     %If J >= CInt3 %then fail %else pass
  313     %If CInt3 >= J %then pass %else fail
  314     %If CInt3 >= CInt4 %then pass %else fail
  315  
  316  
  317  select output(1)
  318  write(failures,1);  printstring(" failure(s)");  newline
  319  
  320  %End %of %Program

  218 Statements compiled
