Skip to content

Commit 2812497

Browse files
authored
Clean up FsUnit (#17781)
1 parent 6cdcc3c commit 2812497

File tree

11 files changed

+48
-92
lines changed

11 files changed

+48
-92
lines changed

tests/FSharp.Compiler.ComponentTests/Signatures/HashConstraintTests.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ let noa<'n when 'n :> Node> (n: 'n option) =
2121
| Some n -> [| n :> Node |]
2222
"""
2323
|> printSignatures
24-
|> should
25-
equal
24+
|> assertEqualIgnoreLineEnding
2625
"""
2726
module Foo
2827

tests/FSharp.Compiler.ComponentTests/Signatures/MemberTests.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ type Foo() =
1515
member f.X with internal get (key1, key2) = true and public set (key1, key2) value = ()
1616
"""
1717
|> printSignatures
18-
|> should
19-
equal
18+
|> assertEqualIgnoreLineEnding
2019
"""
2120
module Foo
2221
@@ -38,8 +37,7 @@ type Foo() =
3837
member f.Y with public get () = 'y' and internal set y = ignore<char> y
3938
"""
4039
|> printSignatures
41-
|> should
42-
equal
40+
|> assertEqualIgnoreLineEnding
4341
"""
4442
module Foo
4543

tests/FSharp.Compiler.ComponentTests/Signatures/ModuleOrNamespaceTests.fs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ type Map<'t,'v> =
2020
"""
2121
|> printSignatures
2222
|> prependNewline
23-
|> should
24-
equal
23+
|> assertEqualIgnoreLineEnding
2524
"""
2625
namespace Foo.Types
2726
@@ -43,8 +42,7 @@ type Foo =
4342
"""
4443
|> printSignatures
4544
|> prependNewline
46-
|> should
47-
equal
45+
|> assertEqualIgnoreLineEnding
4846
"""
4947
namespace Hey.There
5048
@@ -101,8 +99,7 @@ module internal CodePrinter =
10199
id"""
102100
|> printSignatures
103101
|> prependNewline
104-
|> should
105-
equal
102+
|> assertEqualIgnoreLineEnding
106103
"""
107104
namespace Fantomas.Core
108105
@@ -156,7 +153,7 @@ open System.Runtime.CompilerServices
156153
do ()
157154
"""
158155
|> printSignatures
159-
|> should equal "namespace System"
156+
|> assertEqualIgnoreLineEnding "namespace System"
160157

161158
[<Fact>]
162159
let ``Empty module`` () =
@@ -167,7 +164,7 @@ module Foobar
167164
do ()
168165
"""
169166
|> printSignatures
170-
|> should equal "module Foobar"
167+
|> assertEqualIgnoreLineEnding "module Foobar"
171168

172169
[<Fact>]
173170
let ``Two empty namespaces`` () =
@@ -183,7 +180,7 @@ do ()
183180
"""
184181
|> printSignatures
185182
|> prependNewline
186-
|> should equal """
183+
|> assertEqualIgnoreLineEnding """
187184
namespace Foo
188185
namespace Bar"""
189186

@@ -196,7 +193,7 @@ namespace rec Foobar
196193
do ()
197194
"""
198195
|> printSignatures
199-
|> should equal "namespace Foobar"
196+
|> assertEqualIgnoreLineEnding "namespace Foobar"
200197

201198
[<Fact>]
202199
let ``Attribute on nested module`` () =
@@ -211,7 +208,7 @@ module Area =
211208
"""
212209
|> printSignatures
213210
|> prependNewline
214-
|> should equal """
211+
|> assertEqualIgnoreLineEnding """
215212
namespace MyApp.Types
216213
217214
[<RequireQualifiedAccess; CompilationRepresentation (enum<CompilationRepresentationFlags> (4))>]

tests/FSharp.Compiler.ComponentTests/Signatures/NestedTypeTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let f (g: Upper<int>.Lower<string>) = g.Meh()
3535
"""
3636
|> withReferences [ CSLib ]
3737
|> printSignatures
38-
|> should equal
38+
|> assertEqualIgnoreLineEnding
3939
"""
4040
module Sample
4141
@@ -74,7 +74,7 @@ let f (g: Root<TimeSpan,TimeSpan,TimeSpan,TimeSpan,TimeSpan>.Foo<int, float, str
7474
"""
7575
|> withReferences [ CSLib ]
7676
|> printSignatures
77-
|> should equal
77+
|> assertEqualIgnoreLineEnding
7878
"""
7979
module Sample
8080

tests/FSharp.Compiler.ComponentTests/Signatures/RecordTests.fs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ type PullActions =
1919
}
2020
"""
2121
|> printSignaturesWith 80
22-
|> should
23-
equal
22+
|> assertEqualIgnoreLineEnding
2423
"""
2524
module SignatureFileGeneration.MyModule
2625
@@ -63,7 +62,7 @@ type SomeTypeName =
6362
"""
6463
|> printSignatures
6564
|> prependNewline
66-
|> should equal
65+
|> assertEqualIgnoreLineEnding
6766
"""
6867
namespace MyApp.Types
6968
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
module Signatures.TestHelpers
22

33
open System
4-
open FsUnit
4+
open Xunit
55
open FSharp.Test.Compiler
66

77
let prependNewline v = String.Concat("\n", v)
88

9-
let equal x =
10-
let x =
11-
match box x with
12-
| :? String as s -> s.Replace("\r\n", "\n") |> box
13-
| x -> x
14-
15-
equal x
9+
let assertEqualIgnoreLineEnding (x: string) (y: string) =
10+
Assert.Equal(x, y, ignoreLineEndingDifferences = true)
1611

1712
let assertSingleSignatureBinding implementation signature =
1813
FSharp $"module A\n\n{implementation}"
1914
|> printSignatures
20-
|> should equal $"\nmodule A\n\n{signature}"
15+
|> assertEqualIgnoreLineEnding $"\nmodule A\n\n{signature}"

tests/FSharp.Compiler.ComponentTests/Signatures/TypeTests.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ and FormatSelectionRange =
4444
"""
4545
|> printSignatures
4646
|> prependNewline
47-
|> should equal
47+
|> assertEqualIgnoreLineEnding
4848
"""
4949
namespace Foo.Types
5050
@@ -87,7 +87,7 @@ type List<'E> with
8787
member this.X = this.Head
8888
"""
8989
|> printSignatures
90-
|> should equal
90+
|> assertEqualIgnoreLineEnding
9191
"""
9292
module Extensions
9393
type List<'E> with
@@ -104,7 +104,7 @@ type Map<'K, 'V when 'K: comparison> with
104104
member m.X (t: 'T) (k: 'K) = Some k, ({| n = [|k|] |}, 0)
105105
"""
106106
|> printSignatures
107-
|> should equal
107+
|> assertEqualIgnoreLineEnding
108108
"""
109109
module Extensions
110110
type Map<'K,'V when 'K: comparison> with
@@ -126,7 +126,7 @@ type ConcurrentDictionary<'key, 'value> with
126126
| _ -> None
127127
"""
128128
|> printSignatures
129-
|> should equal
129+
|> assertEqualIgnoreLineEnding
130130
"""
131131
module Extensions
132132
type System.Collections.Concurrent.ConcurrentDictionary<'key,'value> with
@@ -161,7 +161,7 @@ type DataItem< ^input> with
161161
DataItem.Create< ^input>(stringValue, friendlyStringValue, item)
162162
"""
163163
|> printSignatures
164-
|> should equal
164+
|> assertEqualIgnoreLineEnding
165165
"""
166166
module Extensions
167167
@@ -237,7 +237,7 @@ type Foo =
237237
member x.Bar with get () = 5 and set v = ignore<int> v
238238
"""
239239
|> printSignatures
240-
|> should equal
240+
|> assertEqualIgnoreLineEnding
241241
"""
242242
module Lib
243243
@@ -254,7 +254,7 @@ type Foo =
254254
member x.Bar with get (a:int) = 5 and set (a:int) v = ignore<int> v
255255
"""
256256
|> printSignatures
257-
|> should equal
257+
|> assertEqualIgnoreLineEnding
258258
"""
259259
module Lib
260260

tests/FSharp.Compiler.Service.Tests/ExprTests.fs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,12 @@ let ``Test Unoptimized Declarations Project1`` useTransparentCompiler =
788788
printDeclarations None (List.ofSeq file1.Declarations)
789789
|> Seq.toList
790790
|> Utils.filterHack
791-
|> shouldPairwiseEqual (Utils.filterHack expected)
791+
|> shouldEqual (Utils.filterHack expected)
792792

793793
printDeclarations None (List.ofSeq file2.Declarations)
794794
|> Seq.toList
795795
|> Utils.filterHack
796-
|> shouldPairwiseEqual (Utils.filterHack expected2)
796+
|> shouldEqual (Utils.filterHack expected2)
797797

798798
()
799799

@@ -930,12 +930,12 @@ let ``Test Optimized Declarations Project1`` useTransparentCompiler =
930930
printDeclarations None (List.ofSeq file1.Declarations)
931931
|> Seq.toList
932932
|> Utils.filterHack
933-
|> shouldPairwiseEqual (Utils.filterHack expected)
933+
|> shouldEqual (Utils.filterHack expected)
934934

935935
printDeclarations None (List.ofSeq file2.Declarations)
936936
|> Seq.toList
937937
|> Utils.filterHack
938-
|> shouldPairwiseEqual (Utils.filterHack expected2)
938+
|> shouldEqual (Utils.filterHack expected2)
939939

940940
()
941941

@@ -1045,11 +1045,11 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi
10451045

10461046
// fail test on first line that fails, show difference in output window
10471047
resultUnoptFiltered
1048-
|> shouldPairwiseEqual expectedUnoptFiltered
1048+
|> shouldEqual expectedUnoptFiltered
10491049

10501050
// fail test on first line that fails, show difference in output window
10511051
resultOptFiltered
1052-
|> shouldPairwiseEqual expectedOptFiltered
1052+
|> shouldEqual expectedOptFiltered
10531053
end
10541054

10551055
[<Fact>]
@@ -3134,7 +3134,7 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) =
31343134
let createOptions() = createProjectOptions dirName [fileSource1] []
31353135

31363136
#if !NETFRAMEWORK && DEBUG
3137-
[<Fact(Skip = "Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.")>]
3137+
[<Theory(Skip = "Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.")>]
31383138
#else
31393139
[<Theory>]
31403140
[<InlineData(false)>]
@@ -3263,7 +3263,7 @@ let ``Test ProjectForWitnesses1`` useTransparentCompiler =
32633263
|> Seq.toList
32643264
printfn "actual:\n\n%A" actual
32653265
actual
3266-
|> shouldPairwiseEqual expected
3266+
|> shouldEqual expected
32673267

32683268

32693269
[<Theory>]
@@ -3380,7 +3380,7 @@ let ``Test ProjectForWitnesses2`` useTransparentCompiler =
33803380
|> Seq.toList
33813381
printfn "actual:\n\n%A" actual
33823382
actual
3383-
|> shouldPairwiseEqual expected
3383+
|> shouldEqual expected
33843384

33853385
//---------------------------------------------------------------------------------------------------------
33863386
// This project is for witness arguments, testing for https://github.com/dotnet/fsharp/issues/10364
@@ -3437,7 +3437,7 @@ let ``Test ProjectForWitnesses3`` useTransparentCompiler =
34373437
|> Seq.toList
34383438
printfn "actual:\n\n%A" actual
34393439
actual
3440-
|> shouldPairwiseEqual expected
3440+
|> shouldEqual expected
34413441

34423442
[<Theory>]
34433443
[<InlineData(false)>]
@@ -3532,7 +3532,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` useTransparentCompiler =
35323532
|> Seq.toList
35333533
printfn "actual:\n\n%A" actual
35343534
actual
3535-
|> shouldPairwiseEqual expected
3535+
|> shouldEqual expected
35363536

35373537
module internal ProjectForNoWarnHashDirective =
35383538

tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ let ``Test project2 all symbols in signature`` () =
713713
"field x"; "field y"; "GenericClass`1"; "generic parameter T"; "member .ctor";
714714
"member GenericMethod"; "generic parameter U"] |> List.sort
715715

716-
shouldPairwiseEqual e r
716+
shouldEqual e r
717717

718718
[<Fact>]
719719
let ``Test project2 all uses of all signature symbols`` () =

tests/FSharp.Compiler.Service.Tests/Symbols.fs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern int private c()
6868
|> List.zip decls
6969
|> List.iter (fun (actual, expected) ->
7070
match actual with
71-
| SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> should equal expected
71+
| SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> shouldEqual expected
7272
| decl -> failwithf "unexpected decl: %O" decl)
7373

7474
[ "a", (true, false, false, false)
@@ -79,7 +79,7 @@ extern int private c()
7979
| :? FSharpMemberOrFunctionOrValue as mfv ->
8080
let access = mfv.Accessibility
8181
(access.IsPublic, access.IsProtected, access.IsInternal, access.IsPrivate)
82-
|> should equal expected
82+
|> shouldEqual expected
8383
| _ -> failwithf "Couldn't get mfv: %s" name)
8484

8585
[<Fact>]
@@ -289,7 +289,7 @@ type E = Ns1.Ns2.T
289289
match symbolUse.Symbol with
290290
| :? FSharpEntity as entity ->
291291
entity.AbbreviatedType.Format(symbolUse.DisplayContext)
292-
|> should equal expectedPrintedType
292+
|> shouldEqual expectedPrintedType
293293

294294
| _ -> failwithf "Couldn't get entity: %s" symbolName)
295295

@@ -388,7 +388,7 @@ let tester: int folks = Cons(1, Nil)
388388
match symbolUse.Symbol with
389389
| :? FSharpMemberOrFunctionOrValue as v ->
390390
v.FullType.Format (symbolUse.DisplayContext.WithPrefixGenericParameters())
391-
|> should equal prefixForm
391+
|> shouldEqual prefixForm
392392
| _ -> failwithf "Couldn't get member: %s" entity
393393

394394
[<Fact>]
@@ -406,7 +406,7 @@ let tester: Folks<int> = Cons(1, Nil)
406406
match symbolUse.Symbol with
407407
| :? FSharpMemberOrFunctionOrValue as v ->
408408
v.FullType.Format (symbolUse.DisplayContext.WithSuffixGenericParameters())
409-
|> should equal suffixForm
409+
|> shouldEqual suffixForm
410410
| _ -> failwithf "Couldn't get member: %s" entity
411411

412412
[<Fact>]
@@ -431,7 +431,7 @@ let tester2: int Group = []
431431
match symbolUse.Symbol with
432432
| :? FSharpMemberOrFunctionOrValue as v ->
433433
v.FullType.Format symbolUse.DisplayContext
434-
|> should equal expectedTypeFormat
434+
|> shouldEqual expectedTypeFormat
435435
| _ -> failwithf "Couldn't get member: %s" entityName
436436
)
437437

@@ -497,10 +497,10 @@ let f2 b1 b2 b3 b4 b5 =
497497
| :? FSharpMemberOrFunctionOrValue as mfv ->
498498
match symbolTypes.TryGetValue(mfv.DisplayName) with
499499
| true, Some expectedType ->
500-
mfv.FullType.TypeDefinition.DisplayName |> should equal expectedType
500+
mfv.FullType.TypeDefinition.DisplayName |> shouldEqual expectedType
501501
| true, None ->
502-
mfv.FullType.IsGenericParameter |> should equal true
503-
mfv.FullType.AllInterfaces.Count |> should equal 0
502+
mfv.FullType.IsGenericParameter |> shouldEqual true
503+
mfv.FullType.AllInterfaces.Count |> shouldEqual 0
504504
| _ -> ()
505505
| _ -> ()
506506

0 commit comments

Comments
 (0)