You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/truth_vectors/qbasic/control_flow.json
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -308,6 +308,67 @@
308
308
{ "var": "FalseRuns", "val": 0, "type": "number", "message": "WHILE must completely skip execution if the initial condition is 0" }
309
309
]
310
310
}
311
+
},
312
+
{
313
+
"name": "Line Numbers (Archaic Labels)",
314
+
"syntax": "linenumber statement",
315
+
"description": "In older BASIC dialects, every line required a number. QBasic supports these numbers as archaic labels for control flow statements like GOTO, GOSUB, and RESTORE. They do not require a trailing colon.",
316
+
"example": {
317
+
"code": [
318
+
"10 PRINT \"START\"",
319
+
"GOTO 30",
320
+
"20 PRINT \"SKIPPED\"",
321
+
"30 PRINT \"END\""
322
+
],
323
+
"output": "START\nEND"
324
+
},
325
+
"quirks_and_tests": {
326
+
"description": "Validates that a raw integer at the start of a statement acts as a valid jump target without requiring a trailing colon.",
327
+
"setup": [
328
+
"LineVal = 0",
329
+
"10 LineVal = 10",
330
+
"GOTO 30",
331
+
"20 LineVal = 20",
332
+
"30 FinalLine = LineVal"
333
+
],
334
+
"assertions": [
335
+
{ "var": "FinalLine", "val": 10, "type": "number", "message": "GOTO must successfully bypass line 20 and land on line 30 using numeric labels." }
336
+
]
337
+
}
338
+
},
339
+
{
340
+
"name": "Implicit GOTO (IF THEN Line Number)",
341
+
"syntax": "IF condition THEN linenumber [ELSE linenumber]",
342
+
"description": "A legacy shorthand where providing a line number directly after THEN or ELSE implicitly executes a GOTO instruction.",
343
+
"example": {
344
+
"code": [
345
+
"IF 1 = 1 THEN 100 ELSE 200",
346
+
"100 PRINT \"TRUE\"",
347
+
"END",
348
+
"200 PRINT \"FALSE\""
349
+
],
350
+
"output": "TRUE"
351
+
},
352
+
"quirks_and_tests": {
353
+
"description": "CRITICAL QUIRK: This implicit jump ONLY works with numeric line numbers, not text labels. It is heavily used in code golf and demoscene programs.",
354
+
"setup": [
355
+
"Flag = 1",
356
+
"IF Flag = 1 THEN 100 ELSE 200",
357
+
"100 ThenPath = 1",
358
+
"GOTO 300",
359
+
"200 ThenPath = 2",
360
+
"300 Flag = 0",
361
+
"IF Flag = 1 THEN 400 ELSE 500",
362
+
"400 ElsePath = 1",
363
+
"GOTO 600",
364
+
"500 ElsePath = 2",
365
+
"600 FinalEnd = 1"
366
+
],
367
+
"assertions": [
368
+
{ "var": "ThenPath", "val": 1, "type": "number", "message": "Implicit THEN jump must successfully land on line 100." },
369
+
{ "var": "ElsePath", "val": 2, "type": "number", "message": "Implicit ELSE jump must successfully land on line 500." }
0 commit comments