digitalmars.D.bugs - -cov causes div by zero if file has no executable lines
- Don Clugston (4/4) Dec 08 2005 For example, a file consisting only of typedefs.
- Don Clugston (8/13) Dec 09 2005 Bug is in cover.d line 174.
- Hasan Aljudy (7/23) Dec 10 2005 I think that would be somewhat hackish, what if we needed the real value...
- Derek Parnell (15/40) Dec 10 2005 I was thinking along similar lines...
For example, a file consisting only of typedefs. When it prints "Module xxx is nn% covered" at runtime it crashes when calculating the percentage, because it's 0/0. I think it should report 100% coverage.
Dec 08 2005
Don Clugston wrote:For example, a file consisting only of typedefs. When it prints "Module xxx is nn% covered" at runtime it crashes when calculating the percentage, because it's 0/0. I think it should report 100% coverage.Bug is in cover.d line 174. ------ fwritefln(flst, "%s is %s%% covered", c.filename, (nyes * 100) / (nyes + nno)); --------- Easy fix is to add this line above it: if (nyes+nno==0) nyes=1; // avoid div by zero
Dec 09 2005
Don Clugston wrote:Don Clugston wrote:I think that would be somewhat hackish, what if we needed the real value of nyes later? how about something more like: auto temp = nyes + nno; //pick a better name than temp auto coverage = (!temp)? 100 : (nyes * 100) / temp; fwritefln(flst, "%s is %s%% covered", c.filename, coverage );For example, a file consisting only of typedefs. When it prints "Module xxx is nn% covered" at runtime it crashes when calculating the percentage, because it's 0/0. I think it should report 100% coverage.Bug is in cover.d line 174. ------ fwritefln(flst, "%s is %s%% covered", c.filename, (nyes * 100) / (nyes + nno)); --------- Easy fix is to add this line above it: if (nyes+nno==0) nyes=1; // avoid div by zero
Dec 10 2005
On Sat, 10 Dec 2005 01:43:27 -0700, Hasan Aljudy wrote:Don Clugston wrote:I was thinking along similar lines... if (nyes+nno==0) { fwritefln(flst, "%s does not need coverage.", c.filename); } else { fwritefln(flst, "%s is %s%% covered", c.filename, (nyes * 100) / (nyes + nno)); } -- Derek Parnell Melbourne, Australia 10/12/2005 9:47:35 PMDon Clugston wrote:I think that would be somewhat hackish, what if we needed the real value of nyes later? how about something more like: auto temp = nyes + nno; //pick a better name than temp auto coverage = (!temp)? 100 : (nyes * 100) / temp; fwritefln(flst, "%s is %s%% covered", c.filename, coverage );For example, a file consisting only of typedefs. When it prints "Module xxx is nn% covered" at runtime it crashes when calculating the percentage, because it's 0/0. I think it should report 100% coverage.Bug is in cover.d line 174. ------ fwritefln(flst, "%s is %s%% covered", c.filename, (nyes * 100) / (nyes + nno)); --------- Easy fix is to add this line above it: if (nyes+nno==0) nyes=1; // avoid div by zero
Dec 10 2005