How to test the Option module

Apr 14, 2014 at 11:53 AM
Hi

Now that F# accepts contributions, I'd like to submit a small feature for the Options module, so I've forked the repo, and pulled it down.

However, I can't find any test coverage of the current Option module. In order to investigate, I renamed the Option.isNone function just to see what would break, and apart from two occurrences in the Seq module, nothing breaks if I do this.

It's as if the Option module isn't covered by tests at all.

Is this really the case?
Coordinator
Apr 14, 2014 at 6:09 PM
Grepping the test sources for \bOption\.([a-zA-Z]+), it appears that there is usage of most of the Option methods, though not all. Some of the coverage is in test areas that are not part of the open source drop. So there is a moderate level of implicit test coverage. (Interestingly, Option.isSome/isNone are both used in tests\fsharp\core\syntax\test.fsx. Did this test area pass?)

But no, complete targeted testing of the Option module is not currently in place. Implementing such tests would make for a great contribution, if you are interested - the most appropriate place would be in the core unit tests, perhaps a new file OptionModule.fs in src\fsharp\FSharp.Core.Unittests\FSharp.Core\Microsoft.FSharp.Core

Thanks,
-Lincoln
Apr 14, 2014 at 7:27 PM
Actually, I already tried adding a new OptionModule.fs file in the unit test project, but ran into problems. I'd love to help out with this, but I'd need a little help to get started, it seems...

First, I couldn't get it to compile at all when I added a new function to the Option module, because the compiler insisted that the function isn't there. Then I discovered that if I also add a 'declaration' in option.fsi, my new test compiles. Unfortunately, when I run the tests, it fails with a MissingMethod exception. Is the NUnit test runner picking up the 'normal', installed FSharp.Core library, instead of the FSharp.Core library referenced in the solution? That would explain the MissingMethod exception.

Is there any way to get around that? Or is the problem something completely different?
Coordinator
Apr 14, 2014 at 7:46 PM
Yes, much of the F# compiler and runtime use .fsi signature files, which need to be kept updated if you alter the public surface area.

Regarding running the tests - make sure you are compiling and running them from the command line via RunTest.cmd, and that proper versions of your built binaries are GACed. See TESTGUIDE.html for the steps to do this.
Apr 15, 2014 at 8:50 AM