Skip to content

Commit

Permalink
New range test
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Jan 21, 2024
1 parent ce1020b commit 18278d3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/suite/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3463,4 +3463,41 @@ exports.on_excp_2 = async () => {
expectedIndent: 2,
currentIndent: 0
});
}

exports.range_1 = async () => {
const lines = [
`**free`,
`ctl-opt debug option(*nodebugio: *srcstmt) dftactgrp(*no) actgrp(*caller)`,
`main(Main);`,
`dcl-s x timestamp;`,
`dcl-s y timestamp;`,
`dcl-proc Main;`,
` dsply %CHAR(CalcDiscount(10000));`,
` dsply %char(CalcDiscount(1000));`,
` x = %TIMESTAMP(y);`,
` y = %TimeStamp(x);`,
` return;`,
`end-proc;`,
].join(`\n`);

const cache = await parser.getDocs(uri, lines, {ignoreCache: true, withIncludes: true});
Linter.getErrors({ uri, content: lines }, {
CollectReferences: true
}, cache);

const rangeRefs = cache.referencesInRange({position: 220, end: 260});
assert.strictEqual(rangeRefs.length, 2);
assert.ok(rangeRefs[0].dec.name === `x`);
assert.ok(rangeRefs[1].dec.name === `y`);

assert.deepStrictEqual(rangeRefs[0].refs, [
{ position: 220, end: 221 },
{ position: 256, end: 257 }
]);

assert.deepStrictEqual(rangeRefs[1].refs, [
{ position: 235, end: 236 },
{ position: 241, end: 242 }
]);
}

0 comments on commit 18278d3

Please sign in to comment.