         Edinburgh IMP77 Compiler - Version 8.4

    1  
    2  !*   Title      :  IV    The IMP  INTEGER  Facilities
    3  !*   Version    :  I
    4  !*   Date       :  12 July 1984
    5  !*   Description:  Tests all the INTEGER comparison operators.
    6  
    7  %Begin
    8  
    9     %Integer J
   10     %Integer K
   11  
   12     %Constant %Byte %Integer  CB1 = 255
   13     %Constant %Byte %Integer  CB2 = 0
   14  
   15     %Constant %Integer  CInt3 = 10
   16     %Constant %Integer  CInt4 = 3
   17  
   18  %owninteger failures=0
   19  
   20  %routine pass
   21    printstring("Pass: ")
   22  %end
   23  %routine fail
   24    printstring("FAIL: ")
   25    failures = failures+1
   26  %end
   27  
   28     %Integer %Function  F
   29  
   30       !*  An extremely simple integer function that merely
   31       !*  returns the number THREE.  Note that this function 
   32       !*  does not presuppose parameter passing or expression
   33       !*  evaluation within functions.  It merely tests the
   34       !*  ability to encorporate functions within expressions. 
   35                                                             
   36       %Result = 3
   37  
   38      %End
   39  
   40  
   41  
   42  
   43     Open Output (2, "Journal")
   44     Select Output (2)
   45  
   46  
   47  
   48     New Lines(2)
   49     Print String("INTEGER Arithmetic Validation");   New Line
   50     Print String("=============================");   New Lines (2)
   51  
   52  
   53     Print String("Entities:");  New Line
   54     Print String("-------- ");  New Lines (2)
   55     
   56     Print String("Constants:                      ");  New Line
   57     Print String("---------                       ");  New Line
   58     Print String("%Integer  CInt3 = 10               ");  New Line
   59     Print String("%Integer  CInt4 = 3                ");  New Lines (2)
   60     
   61     New Lines (3)
   62  
   63  
   64     Print String("Variables: ");  New Line
   65     Print String("---------  ");  New Line
   66     Print String("%Integer J ");  New Line
   67     Print String("%Integer K ");  New Lines (2)
   68  
   69  
   70  
   71  
   72  
   73  
   74     New Lines (4)
   75     Print String("Test the Six Simple Relational Comparators");  New Line
   76     Print String("------------------------------------------");  New Lines (2)
   77  
   78  
   79  
   80     !*    Test the simple relational operations between Integers
   81  
   82  
   83     !*   ---<<<  Test for %Integer Equality  >>>---
   84  
   85     %If 3 = 3 %then pass %else fail
   86     Print String("3 = 3")
   87     New Line
   88  
   89     %If CInt4 = 3 %then pass %else fail
   90     Print String("CInt4 = 3")
   91     New Line
   92  
   93     %If 3 = CInt4 %then pass %else fail
   94     Print String("3 = CInt4")
   95     New Line
   96  
   97     %If CInt4 = CInt4 %then pass %else fail
   98     Print String("CInt4 = CInt4")
   99  
  100     New Lines (3)
  101  
  102  
  103     Print String("Let:    J = K = CInt4");   New Line
  104     Print String("---")
  105     New Lines (2)
  106  
  107     J = CInt4
  108     K = CInt4
  109  
  110     %If J = CInt4 %then pass %else fail
  111     Print String("J = CInt4")
  112     New Line
  113  
  114     %If CInt4 = J %then pass %else fail
  115     Print String("CInt4 = J")
  116     New Line
  117  
  118     %If J = K %then pass %else fail
  119     Print String("J = K")
  120     New Line
  121  
  122     %If J = J %then pass %else fail
  123     Print String("J = J")
  124     New Line
  125  
  126     %If J = 3 %then pass %else fail
  127     Print String("J = 3")
  128     New Line
  129  
  130     %If 3 = J %then pass %else fail
  131     Print String("3 = J")
  132     New Line
  133  
  134     %If 3 = F %then pass %else fail
  135     Print String("3 = F")
  136     New Line
  137  
  138     %If F = 3 %then pass %else fail
  139     Print String("F = 3")
  140     New Line
  141  
  142  
  143     %If F * 3 + 10 = F * F + 5 * 2 %then pass %else fail
  144     Print String("F * 3 + 10 = F * F + 5 * 2")
  145     New Lines (2)
  146  
  147  
  148  
  149  
  150     !*   ---<<<  Test for Integer Inequality  >>>---
  151  
  152  
  153     %If 3 # 3 %then fail %else pass
  154     Print String("3 # 3")
  155     New Line
  156  
  157     %If CInt4 # 3 %then fail %else pass
  158     Print String("CInt4 # 3")
  159     New Line
  160  
  161     %If 3 # CInt4 %then fail %else pass
  162     Print String("3 # CInt4")
  163     New Line
  164  
  165     %If CInt4 # CInt4 %then fail %else pass
  166     Print String("CInt4 # CInt4")
  167     New Line
  168  
  169  
  170  
  171     %If J # CInt4 %then fail %else pass
  172     Print String("J # CInt4")
  173     New Line
  174  
  175     %If CInt4 # J %then fail %else pass
  176     Print String("CInt4 # J")
  177     New Line
  178  
  179     %If J # K %then fail %else pass
  180     Print String("J # K")
  181     New Line
  182  
  183     %If J # J %then fail %else pass
  184     Print String("J # J")
  185     New Line
  186  
  187     %If J # 3 %then fail %else pass
  188     Print String("J # 3")
  189     New Line
  190  
  191     %If 3 # J %then fail %else pass
  192     Print String("3 # J")
  193     New Line
  194  
  195     %If  3 # F %then fail %else pass
  196     Print String("3 # F")
  197     New Line
  198  
  199     %If  F # 3 %then fail %else pass
  200     Print String("F # 3")
  201     New Lines (2)
  202  
  203  
  204   
  205  
  206     !*    ---<<<   Test for LESS THAN in Integers  >>>---
  207  
  208  
  209     J = CInt4
  210  
  211     %If 3 < 3 %then fail %else pass
  212     Print String("3 < 3")
  213     New Line
  214  
  215     %If 3 < J %then fail %else pass
  216     Print String("3 < J")
  217     New Line
  218  
  219     %If J < 3 %then fail %else pass
  220     Print String("J < 3")
  221     New Line
  222  
  223     %If 3 < CInt4 %then fail %else pass
  224     Print String("3 < CInt4")
  225     New Line
  226  
  227     %If CInt4 < 3 %then fail %else pass
  228     Print String("CInt4 < 3")
  229     New Line
  230  
  231     %If J < CInt4 %then fail %else pass
  232     Print String("J < CInt4")
  233     New Line
  234  
  235     %If CInt4 < J %then fail %else pass
  236     Print String("CInt4 < J")
  237     New Line
  238  
  239     %If CInt4 < CInt4 %then fail %else pass
  240     Print String("CInt4 < CInt4")
  241     New Line
  242  
  243     %If J < J %then fail %else pass
  244     Print String("J < J")
  245     New Line
  246  
  247     %If F < 3 %then fail %else pass
  248     Print String("F < 3")
  249     New Lines (2)
  250  
  251  
  252  
  253  
  254  
  255     !*    ---<<<   Test for LESS THAN or EQUALS  in Integers  >>>---
  256  
  257  
  258     J = CInt4
  259  
  260     %If 3 <= 3 %then pass %else fail
  261     Print String("3 <= 3")
  262     New Line
  263  
  264     %If 3 <= J %then pass %else fail
  265     Print String("3 <= J")
  266     New Line
  267  
  268     %If J <= 3 %then pass %else fail
  269     Print String("J <= 3")
  270     New Line
  271  
  272     %If 3 <= CInt4 %then pass %else fail
  273     Print String("3 <= CInt4")
  274     New Line
  275  
  276     %If CInt4 <= 3 %then pass %else fail
  277     Print String("CInt4 <= 3")
  278     New Line
  279  
  280     %If J <= CInt4 %then pass %else fail
  281     Print String("J <= CInt4")
  282     New Line
  283  
  284     %If CInt4 <= J %then pass %else fail
  285     Print String("CInt4 <= J")
  286     New Line
  287  
  288     %If CInt4 <= CInt4 %then pass %else fail
  289     Print String("CInt4 <= CInt4")
  290     New Line
  291  
  292     %If J <= J %then pass %else fail
  293     Print String("J <= J")
  294     New Line
  295  
  296     %If F <= 3 %then pass %else fail
  297     Print String("F <= 3")
  298     New Lines (2)
  299  
  300  
  301     
  302  
  303     !*    ---<<<   Test for GREATER THAN in Integers  >>>---
  304  
  305  
  306     J = CInt4
  307  
  308     %If 3 > 3 %then fail %else pass
  309     Print String("3 > 3")
  310     New Line
  311  
  312     %If 3 > J %then fail %else pass
  313     Print String("3 > J")
  314     New Line
  315  
  316     %If J > 3 %then fail %else pass
  317     Print String("J > 3")
  318     New Line
  319  
  320     %If 3 > CInt4 %then fail %else pass
  321     Print String("3 > CInt4")
  322     New Line
  323  
  324     %If CInt4 > 3 %then fail %else pass
  325     Print String("CInt4 > 3")
  326     New Line
  327  
  328     %If J > CInt4 %then fail %else pass
  329     Print String("J > CInt4")
  330     New Line
  331  
  332     %If CInt4 > J %then fail %else pass
  333     Print String("CInt4 > J")
  334     New Line
  335  
  336     %If CInt4 > CInt4 %then fail %else pass
  337     Print String("CInt4 > CInt4")
  338     New Line
  339  
  340     %If J > J %then fail %else pass
  341     Print String("J > J")
  342     New Line
  343  
  344     %If F > 3 %then fail %else pass
  345     Print String("F > 3")
  346     New Lines (2)
  347  
  348  
  349  
  350     !*    ---<<<   Test for GREATER THAN OR EQUALS TO  in Integers  >>>---
  351  
  352     J = CInt4
  353  
  354     %If 3 >= 3 %then pass %else fail
  355     Print String("3 >= 3")
  356     New Line
  357  
  358     %If 3 >= J %then pass %else fail
  359     Print String("3 >= J")
  360     New Line
  361  
  362     %If J >= 3 %then pass %else fail
  363     Print String("J >= 3")
  364     New Line
  365  
  366     %If 3 >= CInt4 %then pass %else fail
  367     Print String("3 >= CInt4")
  368     New Line
  369  
  370     %If CInt4 >= 3 %then pass %else fail
  371     Print String("CInt4 >= 3")
  372     New Line
  373  
  374     %If J >= CInt4 %then pass %else fail
  375     Print String("J >= CInt4")
  376     New Line
  377  
  378     %If CInt4 >= J %then pass %else fail
  379     Print String("CInt4 >= J")
  380     New Line
  381  
  382     %If CInt4 >= CInt4 %then pass %else fail
  383     Print String("CInt4 >= CInt4")
  384     New Line
  385  
  386     %If J >= J %then pass %else fail
  387     Print String("J >= J")
  388     New Line
  389  
  390  
  391     %If F >= 3 %then pass %else fail
  392     Print String("F >= 3")
  393  
  394     New Lines (4)
  395  
  396  
  397  
  398     !*   ---<<<  Test for Integer Equality  >>>---
  399  
  400     %If 3 = 10 %then fail %else pass
  401     Print String("3 = 10")
  402     New Line
  403  
  404     %If CInt4 = 10 %then fail %else pass
  405     Print String("CInt4 = 10")
  406     New Line
  407  
  408     %If 10 = CInt4 %then fail %else pass
  409     Print String("10 = CInt4")
  410     New Line
  411  
  412     %If CInt4 = CInt3 %then fail %else pass
  413     Print String("CInt4 = CInt3")
  414     New Lines (2)
  415  
  416  
  417  
  418     Print String("Let:   J = CInt4");     New Line
  419     Print String("---    K  = CInt3")
  420     New Lines (2)
  421     
  422     J = CInt4
  423     K = CInt3
  424  
  425     %If J = CInt3 %then fail %else pass
  426     Print String("J = CInt3")
  427     New Line
  428  
  429     %If CInt3 = J %then fail %else pass
  430     Print String("CInt3 = J")
  431     New Line
  432  
  433     %If J = K %then fail %else pass
  434     Print String("J = K")
  435     New Line
  436  
  437     %If J = 10 %then fail %else pass
  438     Print String("J = 10")
  439     New Line
  440  
  441     %If 10 = J %then fail %else pass
  442     Print String("10 = J")
  443     New Lines (2)
  444  
  445  
  446  
  447  
  448  !*      ---<<<  Test for Integer Inequality  >>>---
  449  
  450  
  451     %If 3 # 10 %then pass %else fail
  452     Print String("3 # 10")
  453     New Line
  454  
  455     %If CInt4 # 10 %then pass %else fail
  456     Print String("CInt4 # 10")
  457     New Line
  458  
  459     %If 10 # CInt4 %then pass %else fail
  460     Print String("10 # CInt4")
  461     New Line
  462  
  463     %If CInt4 # CInt3 %then pass %else fail
  464     Print String("CInt4 # CInt3")
  465     New Line
  466  
  467  
  468  
  469     %If J # CInt3 %then pass %else fail
  470     Print String("J # CInt3")
  471     New Line
  472  
  473     %If CInt3 # J %then pass %else fail
  474     Print String("CInt3 # J")
  475     New Line
  476  
  477     %If J # K %then pass %else fail
  478     Print String("J # K")
  479     New Line
  480  
  481     %If J # 10 %then pass %else fail
  482     Print String("J # 10")
  483     New Line
  484  
  485     %If 10 # J %then pass %else fail
  486     Print String("10 # J")
  487     New Lines (2)
  488  
  489  
  490   
  491  
  492     !*    ---<<<   Test for LESS THAN in Integers  >>>---
  493  
  494  
  495  
  496     %If 3 < 10 %then pass %else fail
  497     Print String("3 < 10")
  498     New Line
  499  
  500     %If 10 < J %then fail %else pass
  501     Print String("10 < J")
  502     New Line
  503  
  504     %If J < 10 %then pass %else fail
  505     Print String("J < 10")
  506     New Line
  507  
  508     %If 10 < CInt4 %then fail %else pass
  509     Print String("10 < CInt4")
  510     New Line
  511  
  512     %If CInt4 < 10 %then pass %else fail
  513     Print String("CInt4 < 10")
  514     New Line
  515  
  516     %If J < CInt3 %then pass %else fail
  517     Print String("J < CInt3")
  518     New Line
  519  
  520     %If CInt3 < J %then fail %else pass
  521     Print String("CInt3 < J")
  522     New Line
  523  
  524     %If CInt4 < CInt3 %then pass %else fail
  525     Print String("CInt4 < CInt3")
  526     New Lines (2)
  527  
  528  
  529  
  530  
  531     !*    ---<<<   Test for LESS THAN or EQUALS  in Integers  >>>---
  532  
  533  
  534  
  535     %If 3 <= 10 %then pass %else fail
  536     Print String("3 <= 10")
  537     New Line
  538  
  539     %If 10 <= J %then fail %else pass
  540     Print String("10 <= J")
  541     New Line
  542  
  543     %If J <= 10 %then pass %else fail
  544     Print String("J <= 10")
  545     New Line
  546  
  547     %If 10 <= CInt4 %then fail %else pass
  548     Print String("10 <= CInt4")
  549     New Line
  550  
  551     %If CInt4 <= 10 %then pass %else fail
  552     Print String("CInt4 <= 10")
  553     New Line
  554  
  555     %If J <= CInt3 %then pass %else fail
  556     Print String("J <= CInt3")
  557     New Line
  558  
  559     %If CInt3 <= J %then fail %else pass
  560     Print String("CInt3 <= J")
  561     New Line
  562  
  563     %If CInt4 <= CInt3 %then pass %else fail
  564     Print String("CInt4 <= CInt3")
  565     New Line
  566  
  567     %If J <= J %then pass %else fail
  568     Print String("J <= J")
  569     New Lines (2)
  570  
  571  
  572     !*    ---<<<   Test for GREATER THAN in Integers  >>>---
  573  
  574  
  575  
  576     %If 3 > 10 %then fail %else pass
  577     Print String("3 > 10")
  578     New Line
  579  
  580     %If 10 > J %then pass %else fail
  581     Print String("10 > J")
  582     New Line
  583  
  584     %If J > 10 %then fail %else pass
  585     Print String("J > 10")
  586     New Line
  587  
  588     %If 3 > CInt3 %then fail %else pass
  589     Print String("3 > CInt3")
  590     New Line
  591  
  592     %If CInt4 > 10 %then fail %else pass
  593     Print String("CInt4 > 10")
  594     New Line
  595  
  596     %If J > CInt3 %then fail %else pass
  597     Print String("J > CInt3")
  598     New Line
  599  
  600     %If CInt3 > J %then pass %else fail
  601     Print String("CInt3 > J")
  602     New Line
  603  
  604     %If CInt4 > CInt3 %then fail %else pass
  605     Print String("CInt4 > CInt3")
  606     New Lines (2)
  607  
  608  
  609  
  610     !*    ---<<<   Test for GREATER THAN OR EQUALS TO  in Integers  >>>---
  611  
  612  
  613     %If 10 >= 3 %then pass %else fail
  614     Print String("10 >= 3")
  615     New Line
  616  
  617     %If 10 >= J %then pass %else fail
  618     Print String("10 >= J")
  619     New Line
  620  
  621     %If J >= 10 %then fail %else pass
  622     Print String("J >= 10")
  623     New Line
  624  
  625     %If 10 >= CInt4 %then pass %else fail
  626     Print String("10 >= CInt4")
  627     New Line
  628  
  629     %If CInt3 >= 3 %then pass %else fail
  630     Print String("CInt3 >= 3")
  631     New Line
  632  
  633     %If J >= CInt3 %then fail %else pass
  634     Print String("J >= CInt3")
  635     New Line
  636  
  637     %If CInt3 >= J %then pass %else fail
  638     Print String("CInt3 >= J")
  639     New Line
  640  
  641     %If CInt3 >= CInt4 %then pass %else fail
  642     Print String("CInt3 >= CInt4")
  643  
  644     New Lines (3)
  645  
  646  select output(0)
  647  write(failures,1);  printstring(" failure(s)");  newline
  648  
  649  %End %of %Program
?CB2 unused
?CB1 unused

  420 Statements compiled
