Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved fsharpqa/Libraries/Core/LanguagePrimitives test cases to NUnit #9396

Merged
merged 7 commits into from
Jun 4, 2020

Conversation

ThorstenReichert
Copy link
Contributor

Contributes to #7075.

Quick question on the side, I've found some .fsx test cases in fsharpqa/Libraries/Core/LanguagePrimitives, any pointers on how to run those and validate their output in NUnit tests?

@KevinRansom
Copy link
Member

@ThorstenReichert

CompilerAssert.RunScriptWithOptions

Here are a couple of examples:

I hope this helps.

Kevin

    [<Test>]
    let ``Reverse slicing quotation on array2d with fixed index return expected expression``() =
        CompilerAssert.RunScriptWithOptions [| "--langversion:preview" |]
            """
open System
open System.Text.RegularExpressions
open FSharp.Quotations
open FSharp.Quotations.DerivedPatterns
open FSharp.Quotations.ExprShape
open FSharp.Quotations.Patterns
let test() = 
    let xs = array2D [ [1;2;3]; ]
    let q = <@ xs.[0..^1, ^1] @>
    
    let expectEqualWithoutWhitespace s1 s2 = 
        let a = Regex.Replace(s1, "\s", "") 
        let b = Regex.Replace(s2, "\s", "")
        if a <> b then failwithf "Expected '%s', but got\n'%s'" a b
        ()
    
    let expected = "Call (None, GetArraySlice2DFixed2, [ValueWithName ([[1; 2; 3]], xs), NewUnionCase (Some, Value (0)), NewUnionCase (Some, Call(None, [,]`1.GetReverseIndex,[ValueWithName([[1;2;3]], xs), Value(0), Value(1)])), Call(None, [,]`1.GetReverseIndex,[ValueWithName([[1;2;3]], xs), Value(1), Value(1)])])"
    expectEqualWithoutWhitespace expected (q.ToString())
    
test()
            """
            []

@KevinRansom
Copy link
Member

@ThorstenReichert ,
BTW, @vzarytovskii is working on reorganizing and improving our TestFramework, so any feedback you have would be supper welcome right now.

Thanks again

Kevin

Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cartermp cartermp merged commit 526f35b into dotnet:master Jun 4, 2020
@ThorstenReichert
Copy link
Contributor Author

@KevinRansom, thank you for the detailed example! Will try it out these days.

As for feedback for the testing framework (cc @vzarytovskii), I've found it relatively easy to get started. Most thoughts I have are probably in large parts due to a lack of familiarity with the codebase (in fact, I've only worked in FSharpSuite.Tests so far):

  • The overall focus of what is being tested seems a bit fuzzy: I've seen tests for compiler warnings, IL code, some sporadic library modules, etc... Also, none of these areas seems to be tested exhaustively there, most of the tests I've seen are few and often for very specific scenarios (many of them seem to be regression tests). Compare this to e.g. the dotnet/runtime libraries tests, there it's a clear one production .dll / one test .dll responsible for testing that entire .dll.
  • Some conventions around how to name tests / test modules, in what namespace to put them, or similar organisational "metadata" could be helpful to give the tests a coherent look-n-feel.

@ThorstenReichert ThorstenReichert deleted the Issues/MigrateFsharpqa4 branch June 8, 2020 20:25
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
…otnet#9396)

* Migrated FormatSpec test cases to NUnit

* Migrated string constructor test cases to NUnit

* Unlisted migrated test cases from env.lst

* Migrated comparison test cases to NUnit

* Migrated cast to units test cases to NUnit

* Cleanup

* Cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants