10 PRINT "PROGRAM FILE 26: PRECEDENCE RULES FOR NUMERIC EXPRESSIONS."
20 PRINT "    ANSI STANDARD 7.2, 7.4"
30 PRINT
40 PRINT "THIS PROGRAM TESTS WHETHER THE PRECEDENCE RULES ARE"
50 PRINT "CORRECTLY IMPLEMENTED."
60 PRINT
70 PRINT "SECTION 26.1: PRECEDENCE ACCORDING TO OPERATOR AND"
80 PRINT "        POSITION (LEFT TO RIGHT)."
90 PRINT
100 PRINT "THIS SECTION TESTS THE PRECEDENCE RULES USING SIMPLE"
110 PRINT "INTEGER OPERANDS AND ALL ORDERED PAIRS OF OPERATORS"
120 PRINT "FOR WHICH THE ORDER OF EVALUATION MAKES A DIFFERENCE."
130 PRINT "NO PARENTHESES ARE USED."
140 PRINT
150 PRINT "                  BEGIN TEST"
160 PRINT
163 PRINT "CASE #","SHOULD BE","ACTUAL","OUTCOME"
166 PRINT
170 LET F=0
180 LET O$="1"
190 LET A=3+4   *  5
200 LET Y=23
210 GOSUB 9000
220 LET A=8+4  /  2
230 LET O$="2"
240 LET Y=10
250 GOSUB 9000
260 LET A=3.+3  ^  3
270 LET O$="3"
280 LET Y=30
290 GOSUB 9000
300 LET A=3  -  40.00E-1+5
310 LET O$="4"
320 LET Y=4
330 GOSUB 9000
340 LET A=3.00 - 4-.5E+1
350 LET O$="5"
360 LET Y=-6
370 GOSUB 9000
380 LET O$="6"
390 LET A=20.E-1-3 * 4
400 LET Y=-10
410 GOSUB 9000
420 LET A=8-4  /  2
430 LET O$="7"
440 LET Y=6
450 GOSUB 9000
460 LET A=3-2 ^ 3
470 LET O$="8"
480 LET Y=-5
490 GOSUB 9000
500 LET A=3 * 4+5
510 LET O$="9"
520 LET Y=17
530 GOSUB 9000
540 LET O$="10"
550 LET A=3.00E0 * 4.00E+00-5.00E-00
560 LET Y=7
570 GOSUB 9000
580 LET A=003.0*2. ^ 3.
590 LET O$="11"
600 LET Y=24
610 GOSUB 9000
620 LET A=6 / 2+1
630 LET O$="12"
640 LET Y=4
650 GOSUB 9000
660 LET A=6 / 2-1
670 LET O$="13"
680 LET Y=2
690 GOSUB 9000
700 LET A=2 / 1*2
710 LET O$="14"
720 LET Y=4
730 GOSUB 9000
740 LET A=8 / 2/2
750 LET O$="15"
760 LET Y=2
770 GOSUB 9000
780 LET O$="16"
790 LET A=8/2 ^ 2
800 LET Y=2
810 GOSUB 9000
820 LET A=2 ^ 2+2
830 LET O$="17"
840 LET Y=6
850 GOSUB 9000
860 LET A=2 ^ 3-2
870 LET O$="18"
880 LET Y=6
890 GOSUB 9000
900 LET A=2 ^ 2*2
910 LET O$="19"
920 LET Y=8
930 GOSUB 9000
940 LET A=3 ^ 3/3
950 LET O$="20"
960 LET Y=9
970 GOSUB 9000
980 LET A=2 ^ 3^2
990 LET O$="21"
1000 LET Y=64
1010 GOSUB 9000
1020 LET A=-  2+2
1030 LET O$="22"
1040 LET Y=0
1050 GOSUB 9000
1060 LET A=-  2-2
1070 LET O$="23"
1080 LET Y=-4
1090 GOSUB 9000
1100 LET A=-2  ^  2
1110 LET O$="24"
1120 LET Y=-4
1130 GOSUB 9000
1140 PRINT
1150 IF F=0 THEN 1180
1160 PRINT "*** TEST FAILED IN ";F;" CASE(S). ***"
1170 GOTO 1190
1180 PRINT "*** TEST PASSED ***"
1190 PRINT
1200 PRINT "                  END TEST"
1210 PRINT
2000 PRINT "SECTION 26.2: MIXED OPERATORS, PARENTHESES, AND VARIABLES"
2020 PRINT
2030 PRINT "THIS SECTION TESTS THE USE OF PARENTHESES TO ALTER THE"
2040 PRINT "ORDER OF EVALUATION, EXPRESSIONS WITH SEVERAL OPERATORS,"
2050 PRINT "AND THE USE OF VARIABLES AND CONSTANTS."
2060 PRINT
2070 PRINT "                   BEGIN TEST"
2080 PRINT
2083 PRINT "CASE #","SHOULD BE","ACTUAL","OUTCOME"
2086 PRINT
2090 LET F=0
2100 LET O$="1"
2110 LET A=4
2120 LET A=3-(A-5)
2130 LET Y=4
2140 GOSUB 9000
2150 LET O$="2"
2160 LET B=2
2170 LET A=+2-B+2/B*2^B
2180 LET Y=4
2190 GOSUB 9000
2195 LET O$="3"
2200 LET A=-B-B+B/002.*.2E+01^2
2210 LET Y=0
2220 GOSUB 9000
2225 LET O$="4"
2230 LET A=-3
2240 LET B=-4
2250 LET A=-(A-B)-B-(A-((+B-(B-A))-A))
2260 LET Y=6
2270 GOSUB 9000
2280 LET O$="5"
2290 LET B=4
2299 REM BWBASIC HALTS ON THIS LINE:  2300 LET A=-(1-(-3))^(+(-B^1)/(-2))
2300 LET A=-999999
2310 LET Y=-16
2320 GOSUB 9000
2330 LET O$="6"
2340 LET A=-2
2350 LET B=16
2360 LET C=-30
2370 LET A=(-B+(B^.02E+02-4*A*C)^.5)/(2*A)
2380 LET Y=3
2390 GOSUB 9000
2400 LET O$="7"
2410 LET A=60/(10-(-(-9))-7)/2
2420 LET Y=-5
2430 GOSUB 9000
2900 PRINT
2910 IF F=0 THEN 2940
2920 PRINT "*** TEST FAILED IN ";F;" CASE(S). ***"
2930 GOTO 2950
2940 PRINT "*** TEST PASSED ***"
2950 PRINT
2960 PRINT "                    END TEST"
8970 PRINT
8980 PRINT "END PROGRAM 26"
8990 STOP
9000 REM HANDLE ERROR REPORT
9005 PRINT O$,Y,A,
9007 LET P$="FAILS"
9010 LET M=0.1
9020 IF Y>1 THEN 9050
9030 IF Y<-1 THEN 9050
9040 LET M=0.01
9050 LET T=A-Y
9060 IF T>M THEN 9100
9070 LET T=Y-A
9080 IF T>M THEN 9100
9090 LET P$="PASSES"
9095 GOTO 9110
9100 LET F=F+1
9110 PRINT "TEST ";P$
9130 RETURN
9140 END
