@@ -1411,4 +1411,122 @@ test('can define on the first line', async () => {
1411
1411
1412
1412
const cache = await parser . getDocs ( uri , lines , { ignoreCache : true , withIncludes : false } ) ;
1413
1413
expect ( cache . subroutines . length ) . toBe ( 3 ) ;
1414
+ } ) ;
1415
+
1416
+ test ( 'fixed-format c spec' , async ( ) => {
1417
+ const lines = [
1418
+ ` Farticle1 UF E K DISK` ,
1419
+ `` ,
1420
+ ` d UpdArt pr` ,
1421
+ ` d qty 5 0 value` ,
1422
+ ` d id like(new.ODARID)` ,
1423
+ `` ,
1424
+ ` D PARM1 DS` ,
1425
+ ` * Physical file name` ,
1426
+ ` D FNAME 10` ,
1427
+ ` * Physical file library` ,
1428
+ ` D LNAME 10` ,
1429
+ ` * Member name` ,
1430
+ ` D MNAME 10` ,
1431
+ ` * Trigger event 1=Ins, 2=Del, 3=Upd` ,
1432
+ ` D TEVEN 1` ,
1433
+ ` * Trigger time 1=After, 2=Before` ,
1434
+ ` D TTIME 1` ,
1435
+ ` * Commit lock level` ,
1436
+ ` D CMTLCK 1` ,
1437
+ ` * Reserved` ,
1438
+ ` D 3` ,
1439
+ ` * CCSID` ,
1440
+ ` D CCSID 10i 0` ,
1441
+ ` * Reserved` ,
1442
+ ` D 8` ,
1443
+ ` * Offset to the original record` ,
1444
+ ` D OLDOFF 10i 0` ,
1445
+ ` * length of the original record` ,
1446
+ ` D OLDLEN 10i 0` ,
1447
+ ` * Offset to the original record null byte map` ,
1448
+ ` D ONOFF 10i 0` ,
1449
+ ` * length of the null byte map` ,
1450
+ ` D ONLEN 10i 0` ,
1451
+ ` * Offset to the new record` ,
1452
+ ` D NEWOFF 10i 0` ,
1453
+ ` * length of the new record` ,
1454
+ ` D NEWLEN 10i 0` ,
1455
+ ` * Offset to the new record null byte map` ,
1456
+ ` D NNOFF 10i 0` ,
1457
+ ` * length of the null byte map` ,
1458
+ ` D NNLEN 10i 0` ,
1459
+ `` ,
1460
+ ` * Trigger Buffer Length` ,
1461
+ ` D parm2 s 10i 0` ,
1462
+ `` ,
1463
+ ` * Record to be inserted or new values` ,
1464
+ ` D NEW E DS EXTNAME(detord)` ,
1465
+ ` D qualified` ,
1466
+ ` D based(pn)` ,
1467
+ `` ,
1468
+ ` * Record to be deleted or old values` ,
1469
+ ` D OLD E DS EXTNAME(detord)` ,
1470
+ ` D qualified` ,
1471
+ ` D based(po)` ,
1472
+ ` * SET UP THE ENTRY PARAMETER LIST.` ,
1473
+ `` ,
1474
+ ` C *ENTRY PLIST` ,
1475
+ ` C PARM PARM1` ,
1476
+ ` C PARM PARM2` ,
1477
+ ` C if %parms = 0` ,
1478
+ ` C seton lr` ,
1479
+ ` C return` ,
1480
+ ` C ENDIF` ,
1481
+ ` C select` ,
1482
+ ` c when teven = '1'` ,
1483
+ ` c eval pn = %addr(parm1) + newoff` ,
1484
+ ` c callp UpdArt(new.odqty:new.odarid)` ,
1485
+ ` c when teven = '2'` ,
1486
+ ` c eval po = %addr(parm1) + oldoff` ,
1487
+ ` c callp(e) addlogEntry('ORD700:Order Line deleted ' +` ,
1488
+ ` c %char(Old.odorid) + ' ' + %char(Old.odline)` ,
1489
+ ` c + ' article : ' + old.odarid` ,
1490
+ ` c + ' quantity : ' + %char(old.odqty))` ,
1491
+ ` c callp UpdArt(-Old.odqty + Old.odqtyliv:old.odarid)` ,
1492
+ ` c when teven = '3'` ,
1493
+ ` c eval pn = %addr(parm1) + newoff` ,
1494
+ ` c eval po = %addr(parm1) + oldoff` ,
1495
+ ` c if new.odarid = Old.odarid` ,
1496
+ ` c callp UpdArt((New.odqty - Old.odqty)` ,
1497
+ ` c - (New.odqtyLiv - Old.odqtyLiv)` ,
1498
+ ` c :new.odarid)` ,
1499
+ ` c else` ,
1500
+ ` c callp UpdArt(new.odqty- new.odqtyliv:new.odarid)` ,
1501
+ ` c callp UpdArt(-Old.odqty + Old.odqtyliv:old.odarid)` ,
1502
+ ` c endif` ,
1503
+ ` c endsl` ,
1504
+ ` c return` ,
1505
+ `` ,
1506
+ ` P UpdArt b` ,
1507
+ ` d UpdArt pi` ,
1508
+ ` d qty 5 0 value` ,
1509
+ ` d id like(new.ODARID)` ,
1510
+ ` c if qty = 0` ,
1511
+ ` c return` ,
1512
+ ` c ENDIF` ,
1513
+ ` c id chain article1` ,
1514
+ ` c if not %found` ,
1515
+ ` c return` ,
1516
+ ` c ENDIF` ,
1517
+ ` c eval ARCUSQTY += qty` ,
1518
+ ` c update farti` ,
1519
+ ` P UpdArt e` ,
1520
+ ] . join ( `\n` ) ;
1521
+
1522
+ const cache = await parser . getDocs ( uri , lines , { ignoreCache : true , withIncludes : false } ) ;
1523
+ expect ( cache . constants . length ) . toBe ( 0 ) ;
1524
+ expect ( cache . procedures . length ) . toBe ( 1 ) ;
1525
+ expect ( cache . procedures [ 0 ] . name ) . toBe ( `UpdArt` ) ;
1526
+ expect ( cache . procedures [ 0 ] . subItems . length ) . toBe ( 2 ) ;
1527
+
1528
+ console . log ( cache . variables ) ;
1529
+ expect ( cache . structs . length ) . toBe ( 3 ) ;
1530
+ expect ( cache . variables . length ) . toBe ( 1 ) ;
1531
+
1414
1532
} ) ;
0 commit comments