|
| 1 | +import * as path from 'path'; |
1 | 2 | import { strictEqual, deepStrictEqual } from 'assert';
|
2 |
| -import { Diagnostic, DiagnosticSeverity, Range, Position } from 'vscode'; |
| 3 | +import { Diagnostic, DiagnosticSeverity, Range, Position, window, workspace, Uri } from 'vscode'; |
3 | 4 | import { FortranLintingProvider } from '../src/features/linter-provider';
|
| 5 | +import { delay } from '../src/lib/helper'; |
4 | 6 |
|
5 | 7 | suite('GNU (gfortran) lint single', () => {
|
6 | 8 | const linter = new FortranLintingProvider();
|
@@ -232,8 +234,8 @@ suite('Intel (ifort) lint single', () => {
|
232 | 234 | linter['compiler'] = 'ifort';
|
233 | 235 | const msg = `
|
234 | 236 | /fetch/radiant/RADIANT_Matrix_Free_Subgrid_Scale.F90(102): error #5082: Syntax error, found '::' when expecting one of: ( : % [ . = =>
|
235 |
| - PetscInt :: ierr |
236 |
| ----------------^ |
| 237 | + PetscInt :: ierr |
| 238 | +---------------^ |
237 | 239 | `;
|
238 | 240 | suite('REGEX matches', () => {
|
239 | 241 | const regex = linter['getCompilerREGEX'](linter['compiler']);
|
@@ -514,3 +516,44 @@ C:\\Some\\random\\path\\sample.f90(4): error #6631: A non-optional actual argume
|
514 | 516 | deepStrictEqual(matches, ref);
|
515 | 517 | });
|
516 | 518 | });
|
| 519 | + |
| 520 | +// ----------------------------------------------------------------------------- |
| 521 | +suite('NAG (nagfor) lint single', () => { |
| 522 | + const linter = new FortranLintingProvider(); |
| 523 | + linter['compiler'] = 'nagfor'; |
| 524 | + const msg = ` |
| 525 | +Sequence Error: lint/err-mod.f90, line 3: The IMPLICIT statement cannot occur here |
| 526 | +`; |
| 527 | + suite('REGEX matches', () => { |
| 528 | + const regex = linter['getCompilerREGEX'](linter['compiler']); |
| 529 | + const matches = [...msg.matchAll(regex)]; |
| 530 | + const g = matches[0].groups; |
| 531 | + test('REGEX: filename', () => { |
| 532 | + strictEqual(g['fname'], 'lint/err-mod.f90'); |
| 533 | + }); |
| 534 | + test('REGEX: line number', () => { |
| 535 | + strictEqual(g['ln'], '3'); |
| 536 | + }); |
| 537 | + test('REGEX: severity <sev1>', () => { |
| 538 | + strictEqual(g['sev1'], 'Sequence Error'); |
| 539 | + }); |
| 540 | + test('REGEX: message <msg1>', () => { |
| 541 | + strictEqual(g['msg1'], 'The IMPLICIT statement cannot occur here'); |
| 542 | + }); |
| 543 | + }); |
| 544 | + test('Diagnostics Array', async () => { |
| 545 | + const fileUri = Uri.file(path.resolve(__dirname, '../../test/fortran/lint/err-mod.f90')); |
| 546 | + const doc = await workspace.openTextDocument(fileUri); |
| 547 | + await window.showTextDocument(doc); |
| 548 | + await delay(100); |
| 549 | + const matches = linter['getLinterResults'](msg); |
| 550 | + const ref = [ |
| 551 | + new Diagnostic( |
| 552 | + new Range(new Position(2, 0), new Position(2, 17)), |
| 553 | + 'The IMPLICIT statement cannot occur here', |
| 554 | + DiagnosticSeverity.Error |
| 555 | + ), |
| 556 | + ]; |
| 557 | + deepStrictEqual(matches, ref); |
| 558 | + }); |
| 559 | +}); |
0 commit comments