Skip to content

Commit 9cd63e9

Browse files
committed
Assurance test for #209
Signed-off-by: worksofliam <[email protected]>
1 parent 90782ff commit 9cd63e9

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

tests/suite/linter.test.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3724,4 +3724,53 @@ test("DS template references", async () => {
37243724
expect(lines.substring(err.offset.start, err.offset.end)).toContain(`inz`);
37253725
}
37263726

3727-
});
3727+
});
3728+
3729+
test('embedded sql with variable references (#209)', async () => {
3730+
const lines = [
3731+
`**free`,
3732+
`Ctl-Opt DftActGrp(*no)ActGrp(*StgMdl)`,
3733+
`StgMdl(*SNGLVL)`,
3734+
`Thread(*Concurrent)`,
3735+
`Option(*NoUnRef :*SrcStmt :*NoDebugIo)`,
3736+
`DatFmt(*Iso) TimFmt(*Iso)`,
3737+
`Debug(*Constants)`,
3738+
`Expropts(*AlwBlankNum)`,
3739+
`AlwNull(*UsrCtl)`,
3740+
`DftName(TESTFORM)`,
3741+
`Text('Test for format document');`,
3742+
`// ____________________________________________________________________________`,
3743+
``,
3744+
`Dcl-s Ostpc Char(10);`,
3745+
``,
3746+
`Exec Sql`,
3747+
` Set Option Datfmt = *Iso, Timfmt = *Iso, Closqlcsr = *EndMod, Commit = *none;`,
3748+
``,
3749+
`Ostpc = 'TEST';`,
3750+
``,
3751+
`Exec Sql`,
3752+
` update testupdate`,
3753+
` set ostpc = :OStPc`,
3754+
` where ococl = '20470' and otito = 'FCT';`,
3755+
``,
3756+
`Return;`,
3757+
].join(`\n`);
3758+
3759+
const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: true, collectReferences: true });
3760+
const { errors } = Linter.getErrors({ uri, content: lines }, {
3761+
IncorrectVariableCase: true,
3762+
SQLHostVarCheck: true
3763+
}, cache);
3764+
3765+
expect(errors.length).toBe(2);
3766+
3767+
const hostError = errors[0];
3768+
expect(hostError.type).toBe(`SQLHostVarCheck`);
3769+
expect(lines.substring(hostError.offset.start, hostError.offset.end)).toContain(`ostpc`);
3770+
expect(hostError.newValue).toBe(`:ostpc`);
3771+
3772+
const caseError = errors[1];
3773+
expect(caseError.type).toBe(`IncorrectVariableCase`);
3774+
expect(lines.substring(caseError.offset.start, caseError.offset.end)).toContain(`OStPc`);
3775+
expect(caseError.newValue).toBe(`Ostpc`);
3776+
})

0 commit comments

Comments
 (0)