@@ -68,7 +68,9 @@ func TestIncludeExcludePatterns(t *testing.T) {
68
68
touch (filepath .Join (basePath , "b.js" ))
69
69
touch (filepath .Join (basePath , "src" , "svc.java" ))
70
70
touch (filepath .Join (basePath , "src" , "api.js" ))
71
+ touch (filepath .Join (basePath , "src" , "foo.F15" ))
71
72
touch (filepath .Join (basePath , "src" , "nested" , "util.js" ))
73
+ touch (filepath .Join (basePath , "src" , "nested" , "util2.f90" ))
72
74
73
75
filesCount , err := getFileCount (
74
76
basePath ,
@@ -89,14 +91,16 @@ func TestIncludeExcludePatterns(t *testing.T) {
89
91
},
90
92
)
91
93
r .Nil (err )
92
- r .Equal (float64 (4 ), filesCount )
94
+ r .Equal (float64 (6 ), filesCount )
93
95
94
96
filesCount , err = getFileCount (
95
97
basePath ,
96
98
[]string {},
97
99
[]string {
98
100
"*/*.java" ,
99
101
"a.js" ,
102
+ "**/nested/util2.f90" ,
103
+ "**/foo.F15" ,
100
104
},
101
105
)
102
106
r .Nil (err )
@@ -198,8 +202,8 @@ func TestDogFood(t *testing.T) {
198
202
inRange (r , total .Lines , 2000 , 4000 )
199
203
inRange (r , total .LinesOfCode , 2000 , 4000 )
200
204
inRange (r , total .Keywords , 200 , 400 )
201
- inRange (r , total .Indentations , 2500 , 3500 )
202
- inRange (r , total .IndentationsNormalized , 2500 , 3500 )
205
+ inRange (r , total .Indentations , 2500 , 3700 )
206
+ inRange (r , total .IndentationsNormalized , 2500 , 3700 )
203
207
inRange (r , total .IndentationsDiff , 400 , 600 )
204
208
inRange (r , total .IndentationsDiffNormalized , 400 , 600 )
205
209
inRange (r , total .IndentationsComplexity , 11 , 13 )
@@ -208,10 +212,10 @@ func TestDogFood(t *testing.T) {
208
212
209
213
average := summary .CountersByLanguage ["go" ].Average
210
214
inRange (r , average .Lines , 300 , 400 )
211
- inRange (r , average .LinesOfCode , 250 , 300 )
215
+ inRange (r , average .LinesOfCode , 250 , 330 )
212
216
inRange (r , average .Keywords , 30 , 40 )
213
- inRange (r , average .Indentations , 350 , 400 )
214
- inRange (r , average .IndentationsNormalized , 350 , 400 )
217
+ inRange (r , average .Indentations , 350 , 420 )
218
+ inRange (r , average .IndentationsNormalized , 350 , 420 )
215
219
inRange (r , average .IndentationsDiff , 60 , 70 )
216
220
inRange (r , average .IndentationsDiffNormalized , 60 , 70 )
217
221
inRange (r , average .IndentationsComplexity , 1 , 2 )
@@ -2055,3 +2059,59 @@ func TestCountersForPhpFullSample(t *testing.T) {
2055
2059
r .Equal (float64 (144 ), math .Round (counters .IndentationsComplexity * 100 ))
2056
2060
r .Equal (float64 (21 ), math .Round (counters .IndentationsDiffComplexity * 100 ))
2057
2061
}
2062
+
2063
+ func TestCountersForFortran (t * testing.T ) {
2064
+ r := assert .New (t )
2065
+
2066
+ // language=Fortran
2067
+ code := `
2068
+ program factorial
2069
+ implicit none
2070
+ integer :: n, fact, i
2071
+
2072
+ ! Prompt user for input
2073
+ print *, "Enter a positive integer:"
2074
+ read *, n
2075
+
2076
+ fact = 1 ! Initialize factorial
2077
+
2078
+ ! Calculate factorial
2079
+ do i = 1, n
2080
+ fact = fact * i
2081
+ end do
2082
+
2083
+ ! Output the result
2084
+ print *, "Factorial of", n, "is", fact
2085
+ end program factorial
2086
+ `
2087
+ counters , err := getCountersForCode (code , "fortran" )
2088
+ r .Nil (err )
2089
+ r .NotNil (counters )
2090
+
2091
+ r .Equal (float64 (20 ), counters .Lines )
2092
+ r .Equal (float64 (14 ), counters .LinesOfCode )
2093
+ r .Equal (float64 (8 ), counters .Keywords )
2094
+ r .Equal (float64 (52 ), counters .Indentations )
2095
+ r .Equal (float64 (13 ), math .Round (counters .IndentationsNormalized ))
2096
+ r .Equal (float64 (8 ), math .Round (counters .IndentationsDiff ))
2097
+ r .Equal (float64 (2 ), math .Round (counters .IndentationsDiffNormalized ))
2098
+ }
2099
+
2100
+ func TestCountersForFortranFullSample (t * testing.T ) {
2101
+ r := assert .New (t )
2102
+
2103
+ counters , err := getCountersForCode (test_resources .FortranCode , "fortran" )
2104
+ r .Nil (err )
2105
+ r .NotNil (counters )
2106
+
2107
+ r .Equal (float64 (346 ), counters .Lines )
2108
+ r .Equal (float64 (306 ), counters .LinesOfCode )
2109
+ r .Equal (float64 (146 ), counters .Keywords )
2110
+ r .Equal (float64 (2376 ), counters .Indentations )
2111
+ r .Equal (float64 (594 ), math .Round (counters .IndentationsNormalized ))
2112
+ r .Equal (float64 (160 ), math .Round (counters .IndentationsDiff ))
2113
+ r .Equal (float64 (40 ), math .Round (counters .IndentationsDiffNormalized ))
2114
+ r .Equal (float64 (48 ), math .Round (counters .KeywordsComplexity * 100 ))
2115
+ r .Equal (float64 (194 ), math .Round (counters .IndentationsComplexity * 100 ))
2116
+ r .Equal (float64 (13 ), math .Round (counters .IndentationsDiffComplexity * 100 ))
2117
+ }
0 commit comments