Skip to content

Commit 49bec72

Browse files
committed
test: add unittest for gfortran v11+
1 parent 9d78b4f commit 49bec72

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

test/linter-provider.test.ts

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,131 @@ Error: Missing actual argument for argument 'a' at (1)
345345
deepStrictEqual(matches, ref);
346346
});
347347
});
348+
suite('GNU (gfortran v11+) lint single plain output', () => {
349+
const linter = new FortranLintingProvider();
350+
linter['compiler'] = 'gfortran';
351+
linter['settings']['modernGNU'] = true;
352+
const msg = `err-mod.f90:3:17: Error: (1)`;
353+
suite('REGEX matches', () => {
354+
const regex = linter['getCompilerREGEX'](linter['compiler']);
355+
const matches = [...msg.matchAll(regex)];
356+
const g = matches[0].groups;
357+
test('REGEX: filename', () => {
358+
strictEqual(g?.['fname'], 'err-mod.f90');
359+
});
360+
test('REGEX: line number', () => {
361+
strictEqual(g?.['ln'], '3');
362+
});
363+
test('REGEX: column number', () => {
364+
strictEqual(g?.['cn'], '17');
365+
});
366+
test('REGEX: severity <sev>', () => {
367+
strictEqual(g?.['sev'], 'Error');
368+
});
369+
test('REGEX: message <msg>', () => {
370+
strictEqual(g?.['msg'], '(1)');
371+
});
372+
});
373+
test('Diagnostics Array', () => {
374+
const matches = linter['parseLinterOutput'](msg);
375+
const ref = [
376+
new Diagnostic(
377+
new Range(new Position(2, 17), new Position(2, 17)),
378+
'(1)',
379+
DiagnosticSeverity.Error
380+
),
381+
];
382+
deepStrictEqual(matches, ref);
383+
});
384+
});
385+
suite('GNU (gfortran v11+) lint multiple plain output', () => {
386+
const linter = new FortranLintingProvider();
387+
linter['compiler'] = 'gfortran';
388+
linter['settings']['modernGNU'] = true;
389+
const msg = `
390+
err-mod.f90:3:17: Error: (1)
391+
err-mod.f90:2:11: Error: IMPLICIT NONE statement at (1) cannot follow PRIVATE statement at (2)
392+
err-mod.f90:10:22: Error: Missing actual argument for argument ‘arg1’ at (1)`;
393+
suite('REGEX matches', () => {
394+
const regex = linter['getCompilerREGEX'](linter['compiler']);
395+
const matches = [...msg.matchAll(regex)];
396+
const g = matches[0].groups;
397+
test('REGEX: filename', () => {
398+
strictEqual(g?.['fname'], 'err-mod.f90');
399+
});
400+
test('REGEX: line number', () => {
401+
strictEqual(g?.['ln'], '3');
402+
});
403+
test('REGEX: column number', () => {
404+
strictEqual(g?.['cn'], '17');
405+
});
406+
test('REGEX: severity <sev>', () => {
407+
strictEqual(g?.['sev'], 'Error');
408+
});
409+
test('REGEX: message <msg>', () => {
410+
strictEqual(g?.['msg'], '(1)');
411+
});
412+
413+
const g2 = matches[1].groups;
414+
test('REGEX: filename', () => {
415+
strictEqual(g2?.['fname'], 'err-mod.f90');
416+
});
417+
test('REGEX: line number', () => {
418+
strictEqual(g2?.['ln'], '2');
419+
});
420+
test('REGEX: column number', () => {
421+
strictEqual(g2?.['cn'], '11');
422+
});
423+
test('REGEX: severity <sev>', () => {
424+
strictEqual(g2?.['sev'], 'Error');
425+
});
426+
test('REGEX: message <msg>', () => {
427+
strictEqual(
428+
g2?.['msg'],
429+
'IMPLICIT NONE statement at (1) cannot follow PRIVATE statement at (2)'
430+
);
431+
});
432+
433+
const g3 = matches[2].groups;
434+
test('REGEX: filename', () => {
435+
strictEqual(g3?.['fname'], 'err-mod.f90');
436+
});
437+
test('REGEX: line number', () => {
438+
strictEqual(g3?.['ln'], '10');
439+
});
440+
test('REGEX: column number', () => {
441+
strictEqual(g3?.['cn'], '22');
442+
});
443+
test('REGEX: severity <sev>', () => {
444+
strictEqual(g3?.['sev'], 'Error');
445+
});
446+
test('REGEX: message <msg>', () => {
447+
strictEqual(g3?.['msg'], 'Missing actual argument for argument ‘arg1’ at (1)');
448+
});
449+
});
450+
451+
test('Diagnostics Array', () => {
452+
const matches = linter['parseLinterOutput'](msg);
453+
const ref = [
454+
new Diagnostic(
455+
new Range(new Position(2, 17), new Position(2, 17)),
456+
'(1)',
457+
DiagnosticSeverity.Error
458+
),
459+
new Diagnostic(
460+
new Range(new Position(1, 11), new Position(1, 11)),
461+
'IMPLICIT NONE statement at (1) cannot follow PRIVATE statement at (2)',
462+
DiagnosticSeverity.Error
463+
),
464+
new Diagnostic(
465+
new Range(new Position(9, 22), new Position(9, 22)),
466+
'Missing actual argument for argument ‘arg1’ at (1)',
467+
DiagnosticSeverity.Error
468+
),
469+
];
470+
deepStrictEqual(matches, ref);
471+
});
472+
});
348473

349474
// -----------------------------------------------------------------------------
350475

0 commit comments

Comments
 (0)