|
|
I was just thinking that it might be a good idea to give a higher probability to leap days (and possibly also +/- 1 day around them) to catch the frequent mistakes we programmers tend to make around them.
What do you think?
|
|
Coordinator
Oct 9, 2012 at 12:52 AM
|
Hmm, don't know. Wouldn't that matter mostly to implementors of DateTime - the rest of us hopefully deal with addition subtraction and day counting through DateTime and TImeSpan -right? I think probably more mistakes happen when converting between different
type of dates, like DateTime, an Excel date or a SQL date. Not sure if FsCheck matters much there.
I can of course be swayed by a convincing example ;)
|
|
Oct 9, 2012 at 11:30 PM
Edited Oct 9, 2012 at 11:31 PM
|
Yeah, good point, intuitively it seemed like a good idea but the ocurrences of leap day bugs I've seen involved parsing dates from external sources, e.g. web forms, functions like string -> DateTime or int -> int -> DateTime, but not functions
DateTime -> a
Of course, it's always possible to screw up, e.g.:
let sameDayIn2011 (t: DateTime) = DateTime(2011, t.Month, t.Day)
let sameDayInApril (t: DateTime) = DateTime(t.Year, 4, t.Day)
FsCheck currently finds the bug in sameDayInApril with the default MaxTest = 100 in most runs, but not likely in sameDayIn2011. If I bump MaxTest it seems to take between 260 and 4500 tests to find the failing case.
But I agree that it's probably not common enough to be worth the change, and with a domain like DateTime you shouldn't expect to find all bugs in 100 tests anyway.
Cheers
|
|