Page images
PDF
EPUB

1350 GOTO 1900

1500 REM TEST RECURSIVE USE OF GOSUB

1510 LET L9=0

1520 LET MO=0

1540 GOSUB 1570

1560 RETURN

1570 REM BINOMIAL COEFFICIENT SUBROUTINE

1580 REM FINDS KO-BIN(IO, JO)

1590 REM ADD 1 TO LEVEL-COUNTER (L9) AND SAVE STATE 1600 LET L9=L9+1

1610 LET M(L9)=MO

1620 LET I(L9)=10

1630 LET J(L9)=JO

1640 IF IO=0 THEN 1670

1650 IF I0=JO THEN 1670

1660 GOTO 1740

1670 LET K0=1

1680 REM RESTORE STATE

1690 LET IO=I(L9)

1700 LET JO=J(L9)

1710 LET MO=M(L9)

1720 LET L9=L9-1

1730 RETURN

1740 REM BIN(IO, JO) = BIN (IO, JO-1)+BIN (IO-1, JO-1)

[blocks in formation]

2030 PRINT "SECTION 85.3: GOSUB WITHOUT RETURN."

2040 PRINT

2050 PRINT "THIS SECTION TESTS THAT PROGRAM EXECUTION MAY VALIDLY" 2060 PRINT "TERMINATE EVEN THOUGH MORE GOSUBS HAVE BEEN EXECUTED " 2070 PRINT "THAN RETURNS."

[blocks in formation]

2110 GOSUB 2200

2120 PRINT "*** TEST FAILED

2130 GOTO 2990

2200 PRINT "IF PROGRAM TERMINATES NORMALLY, THEN"

2220 PRINT "*** TEST PASSED

2990 PRINT

3000 PRINT "

3010 PRINT

3020 PRINT "END PROGRAM 85"

4000 END

***11

END TEST."

PROGRAM FILE 85: GENERAL CAPABILITIES OF GOSUB/RETURN. ANSI STANDARD 10.4

SECTION 85.1: SIMPLE NESTING OF GOSUBS.

THIS SECTION TESTS THAT SUBROUTINES MAY CALL ONE ANOTHER AND THAT A SUBROUTINE MAY BE CALLED FROM SEVERAL PLACES.

[blocks in formation]

THIS SECTION TESTS THAT RETURN ADDRESSES ARE PROPERLY STACKED BY GOSUBS (INCLUDING SEVERAL EXECUTIONS OF THE SAME GOSUB) AND UNSTACKED BY CORRESPONDING RETURNS.

[blocks in formation]

THIS SECTION TESTS THAT PROGRAM EXECUTION MAY VALIDLY TERMINATE EVEN THOUGH MORE GOSUBS HAVE BEEN EXECUTED THAN RETURNS.

[blocks in formation]
[blocks in formation]

60 PRINT "ENCOUNTERING A RETURN-STATEMENT WITHOUT HAVING EXECUTED A" 70 PRINT "CORRESPONDING GOSUB-STATEMENT SHOULD RESULT IN THE "

80 PRINT "TERMINATION OF THE PROGRAM AND THE GENERATION OF A MESSAGE" 90 PRINT "IDENTIFYING THE EXCEPTION."

100 PRINT

110 PRINT "TO PASS THIS TEST:"

120 PRINT

130 PRINT "

140 PRINT " 150 PRINT

160 PRINT " 170 PRINT " 180 PRINT 190 PRINT "

200 PRINT

210 LET I=0

220 GOSUB 310

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE"
DISPLAYED, AND"

2) THE PROCESSOR MUST TERMINATE THIS PROGRAM WHEN"
THE RETURN-STATEMENT IS ENCOUNTERED."

230 IF I>1 THEN 330

240 GOTO 280

250 GOSUB 300

260 GOTO 330

280 REM SKIP GOSUB

290 GOTO 310

BEGIN TEST."

[merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][ocr errors][merged small][merged small][merged small]

ENCOUNTERING A RETURN-STATEMENT WITHOUT HAVING EXECUTED A
CORRESPONDING GOSUB-STATEMENT SHOULD RESULT IN THE

TERMINATION OF THE PROGRAM AND THE GENERATION OF A MESSAGE
IDENTIFYING THE EXCEPTION.

**

TO PASS THIS TEST:

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE
DISPLAYED, AND

2) THE PROCESSOR MUST TERMINATE THIS PROGRAM WHEN
THE RETURN-STATEMENT IS ENCOUNTERED.

BEGIN TEST.

? RETURN BEFORE GOSUB IN LINE 320

*** **

20 PRINT"

10 PRINT "PROGRAM FILE 87: ERROR TRANSFER TO NON-EXISTING LINE"
15 PRINT "
NUMBER USING THE GOSUB-STATEMENT."
ANSI STANDARD 10.4"

30 PRINT

40 PRINT "SECTION 87.1: ERROR 50 PRINT "

60 PRINT

TRANSFER TO NON-EXISTING LINE "
NUMBER USING THE GOSUB-STATEMENT."

70 PRINT "THIS IS A TEST FOR A NON-STANDARD FEATURE OF MINIMAL BASIC." 80 PRINT "TO PASS THIS TEST, THE PROCESSOR MUST EITHER:"

90 PRINT

100 PRINT " 1) ACCEPT THE PROGRAM AND BE ACCOMPANIED BY DOCUMENTATION"
110 PRINT "
ACCURATELY DESCRIBING THE FEATURE'S INTERPRETATION"
BY THE PROCESSOR, OR"

120 PRINT "

130 PRINT

140 PRINT " 2) REJECT THE PROGRAM WITH AN APPROPRIATE ERROR MESSAGE" 150 PRINT

160 PRINT "SEE THE NBS MINIMAL BASIC TEST PROGRAMS USER'S MANUAL" 170 PRINT "FOR DETAILED CRITERIA."

180 PRINT

190 PRINT "

200 PRINT

210 LET X=0

220 LET Y=0

230 GOSUB 285

240 IF X=1 THEN 310

250 IF Y=1 THEN 330

BEGIN TEST."

260 PRINT "THE PROCESSOR IGNORED THE GOSUB STATEMENT."

270 GOTO 340

280 LET X=1

290 LET Y=1

300 RETURN

310 PRINT "THE PROCESSOR SUBSTITUTED AN EXISTING, LOWER LINE NUMBER." 320 GOTO 340

330 PRINT "THE PROCESSOR SUBSTITUTED AN EXISTING, HIGHER LINE NUMBER." 340 PRINT

350 PRINT "

END TEST."

*****

****

蛋黃

360 PRINT

370 PRINT "END PROGRAM 87"

380 END

? UNDEFINED LINE NUMBER 285 IN LINE 230

10 PRINT "PROGRAM FILE 88: THE ON-GOTO-STATEMENT.' 11

20 PRINT " ANSI STANDARD 10.2, 10.4"

30 PRINT

60 PRINT "SECTION 88.1: THE ON-GOTO EXPRESSION WITH INTEGER VALUES." 80 PRINT

90 PRINT "

100 PRINT

120 LET N=0

130 FOR I=1 TO 5

BEGIN TEST."

140 REM 3RD DIGIT OF LINE NUMBER IS ITS POSITION IN LIST

150 ON I GOTO 221, 252, 213, 244, 235

160 PRINT "CONTROL FELL THROUGH ON-GOTO"

170 GOTO 280

213 IF I=3 THEN 290

218 LET K=3

219 GOTO 270

221 IF I=1 THEN 290

228 LET K=1

229 GOTO 270

235 IF I=5 THEN 290

238 LET K=5

239 GOTO 270

244 IF I=4 THEN 290

248 LET K=4

249 GOTO 270

252 IF I=2 THEN 290

258 LET K=2

259 GOTO 270

270 PRINT "CONTROL WENT TO LINE #";K;" IN LIST EVEN THOUGH ON-GOTO"; 275 PRINT " EXPRESSION = ";I

[merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][ocr errors][merged small][merged small][merged small]
« PreviousContinue »