Skip to content

Commit e8bd6ce

Browse files
committed
Add tests for reference collection in free-format parameters
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
1 parent ce7c496 commit e8bd6ce

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

tests/suite/references.test.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,14 @@ test("references_9", async () => {
381381
const cache = await parser.getDocs(uri, lines, {ignoreCache: true, withIncludes: true, collectReferences: true});
382382

383383
const procedure = cache.find(`InputIsValid`);
384-
const validationResult = procedure.scope.find(`validationResult`);
385384

385+
const validationResult = procedure.scope.find(`validationResult`);
386386
expect(validationResult.references.length).toEqual(7);
387387
expect(validationResult.references.every(ref => lines.substring(ref.offset.start, ref.offset.end) === `validationResult`)).toBe(true);
388+
389+
const comp = procedure.scope.find(`comp`);
390+
expect(comp.references.length).toEqual(2);
391+
expect(comp.references.every(ref => lines.substring(ref.offset.start, ref.offset.end) === `comp`)).toBe(true);
388392
});
389393

390394
test('references_10', async () => {
@@ -1833,4 +1837,51 @@ test('references_27_fixed_reference', async () => {
18331837

18341838
expect(offsetContent.toUpperCase()).toBe(`WCFGKEY`);
18351839
}
1840+
});
1841+
1842+
test('reference_28_parameters', async () => {
1843+
const lines = [
1844+
`**free`,
1845+
``,
1846+
`ctl-opt dftactgrp(*no);`,
1847+
``,
1848+
`dcl-pi upddept;`,
1849+
` deptno char(3);`,
1850+
` deptname char(36);`,
1851+
` mgrno char(6);`,
1852+
` admrdept char(3);`,
1853+
` location char(16);`,
1854+
`end-pi;`,
1855+
``,
1856+
`dcl-ds result qualified dim(1);`,
1857+
` success char(1);`,
1858+
`end-ds;`,
1859+
``,
1860+
`exec sql`,
1861+
` update dept`,
1862+
` set deptname = :deptname,`,
1863+
` mgrno = :mgrno,`,
1864+
` admrdept = :admrdept,`,
1865+
` location = :location`,
1866+
` where deptno = :deptno;`,
1867+
``,
1868+
`if (SQLCOD = 0);`,
1869+
` result(1).success = 'Y';`,
1870+
`else;`,
1871+
` result(1).success = 'N';`,
1872+
`endif;`,
1873+
``,
1874+
`dcl-s return char(length) inz('Y');`,
1875+
``,
1876+
`exec sql set result sets array :result for 1 rows;`,
1877+
`// Hello`,
1878+
`return;`,
1879+
].join(`\n`);
1880+
1881+
const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: true, collectReferences: true });
1882+
1883+
const deptno = cache.find(`deptno`);
1884+
expect(deptno).toBeDefined();
1885+
expect(deptno.references.length).toBe(2);
1886+
expect(deptno.references.every(ref => lines.substring(ref.offset.start, ref.offset.end) === `deptno`)).toBe(true);
18361887
});

0 commit comments

Comments
 (0)