@@ -13,7 +13,13 @@ import {
1313import * as fg from 'fast-glob' ;
1414
1515import { FortranLintingProvider } from '../src/features/linter-provider' ;
16- import { GNULinter , GNUModernLinter , IntelLinter , NAGLinter } from '../src/lib/linters' ;
16+ import {
17+ GNULinter ,
18+ GNUModernLinter ,
19+ IntelLinter ,
20+ NAGLinter ,
21+ LFortranLinter ,
22+ } from '../src/lib/linters' ;
1723import { EXTENSION_ID , pipInstall } from '../src/lib/tools' ;
1824
1925suite ( 'Linter integration' , ( ) => {
@@ -75,7 +81,7 @@ suite('Linter integration', () => {
7581 } ) ;
7682
7783 test ( 'Linter user setting returns the right linter internally' , ( ) => {
78- const names = [ 'gfortran' , 'ifort' , 'ifx' , 'nagfor' , 'fake' ] ;
84+ const names = [ 'gfortran' , 'ifort' , 'ifx' , 'nagfor' , 'lfortran' , ' fake'] ;
7985 for ( const n of names ) {
8086 const compiler = linter [ 'getLinter' ] ( n ) ;
8187 if ( n === 'gfortran' ) {
@@ -88,6 +94,8 @@ suite('Linter integration', () => {
8894 strictEqual ( compiler instanceof IntelLinter , true ) ;
8995 } else if ( n === 'nagfor' ) {
9096 strictEqual ( compiler instanceof NAGLinter , true ) ;
97+ } else if ( n == 'lfortran' ) {
98+ strictEqual ( compiler instanceof LFortranLinter , true ) ;
9199 } else {
92100 strictEqual ( compiler instanceof GNULinter , true ) ;
93101 }
@@ -787,3 +795,48 @@ Sequence Error: lint/err-mod.f90, line 3: The IMPLICIT statement cannot occur he
787795 deepStrictEqual ( diags , ref ) ;
788796 } ) ;
789797} ) ;
798+
799+ // -----------------------------------------------------------------------------
800+
801+ suite ( 'LFortran (lfortran) lint single' , ( ) => {
802+ const linter = new LFortranLinter ( ) ;
803+ const msg = `
804+ lint/err-mod.f90:3-3:5-12: syntax error: Token 'implicit' is unexpected here
805+ ` ;
806+ suite ( 'REGEX matches' , ( ) => {
807+ const matches = [ ...msg . matchAll ( linter . regex ) ] ;
808+ const g = matches [ 0 ] . groups ;
809+ test ( 'REGEX: filename' , ( ) => {
810+ strictEqual ( g ?. [ 'fname' ] , 'lint/err-mod.f90' ) ;
811+ } ) ;
812+ test ( 'REGEX: line number start <ls>' , ( ) => {
813+ strictEqual ( g ?. [ 'ls' ] , '3' ) ;
814+ } ) ;
815+ test ( 'REGEX: line number end <le>' , ( ) => {
816+ strictEqual ( g ?. [ 'le' ] , '3' ) ;
817+ } ) ;
818+ test ( 'REGEX: column number start <cs>' , ( ) => {
819+ strictEqual ( g ?. [ 'cs' ] , '5' ) ;
820+ } ) ;
821+ test ( 'REGEX: column number end <ce>' , ( ) => {
822+ strictEqual ( g ?. [ 'ce' ] , '12' ) ;
823+ } ) ;
824+ test ( 'REGEX: severity <sev>' , ( ) => {
825+ strictEqual ( g ?. [ 'sev' ] , 'syntax error' ) ;
826+ } ) ;
827+ test ( 'REGEX: message <msg>' , ( ) => {
828+ strictEqual ( g ?. [ 'msg' ] , `Token 'implicit' is unexpected here` ) ;
829+ } ) ;
830+ } ) ;
831+ test ( 'Diagnostics Array' , ( ) => {
832+ const diags = linter . parse ( msg ) ;
833+ const ref = [
834+ new Diagnostic (
835+ new Range ( new Position ( 2 , 4 ) , new Position ( 2 , 12 ) ) ,
836+ `Token 'implicit' is unexpected here` ,
837+ DiagnosticSeverity . Error
838+ ) ,
839+ ] ;
840+ deepStrictEqual ( diags , ref ) ;
841+ } ) ;
842+ } ) ;
0 commit comments