Skip to content

Commit a3a4958

Browse files
committed
Extract unit tests and add some basic regression tests.
1 parent a7a6c74 commit a3a4958

14 files changed

+956
-932
lines changed

tests/ParallelTypeCheckingTests/Code/AlwaysLinkDetection.fs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,3 @@ let doesFileHasAutoOpenBehavior (ast: ParsedInput) : bool =
4545
isAnyAttributeAutoOpen attribs
4646
|| kind = SynModuleOrNamespaceKind.GlobalNamespace)
4747
contents
48-
49-
// ==============================================================================================================================
50-
// ==============================================================================================================================
51-
52-
open System.IO
53-
open NUnit.Framework
54-
open FSharp.Compiler.Service.Tests.Common
55-
56-
[<Test>]
57-
let ``detect auto open`` () =
58-
let file =
59-
Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "..", "..", "src", "Compiler", "Utilities", "ImmutableArray.fsi")
60-
61-
let ast = parseSourceCode (file, File.ReadAllText(file))
62-
Assert.True(doesFileHasAutoOpenBehavior ast)

tests/ParallelTypeCheckingTests/Code/DependencyResolution.fs

Lines changed: 0 additions & 744 deletions
Large diffs are not rendered by default.

tests/ParallelTypeCheckingTests/Code/FileContentMapping.fs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -669,18 +669,3 @@ let mkFileContent (f: FileWithAST) : FileContentEntry list =
669669

670670
[ yield! attributes; yield! contentEntries ])
671671
contents
672-
673-
// ================================================================================================================================
674-
// ================================================================================================================================
675-
module Tests =
676-
open NUnit.Framework
677-
open FSharp.Compiler.Service.Tests.Common
678-
679-
[<Test>]
680-
let ``Test a single file`` () =
681-
let fileName =
682-
@"C:\Users\nojaf\Projects\main-fantomas\src\Fantomas.Core\Selection.fs"
683-
684-
let ast = parseSourceCode (fileName, System.IO.File.ReadAllText(fileName))
685-
let contents = mkFileContent { Idx = 0; File = fileName; AST = ast }
686-
ignore contents

tests/ParallelTypeCheckingTests/Code/TrieApproach/Continuation.fs

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ParallelTypeCheckingTests/Code/TrieApproach/Types.fs

Lines changed: 0 additions & 122 deletions
This file was deleted.

tests/ParallelTypeCheckingTests/ParallelTypeCheckingTests.fsproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,21 @@
3838
<Compile Include="Code\Parallel.fs" />
3939
<Compile Include="Code\GraphProcessing.fs" />
4040
<Compile Include="Code\ParallelTypeChecking.fs" />
41-
<Compile Include="Code\TrieApproach\Types.fs" />
42-
<Compile Include="Code\TrieApproach\Continuation.fs" />
43-
<Compile Include="Code\TrieApproach\SampleData.fs" />
4441
<Compile Include="Tests\Utils.fs" />
4542
<Compile Include="Tests\AssemblySetUp.fs" />
4643
<Compile Include="Tests\TestCompilation.fs" />
4744
<Compile Include="Tests\TestCompilationFromCmdlineArgs.fs" />
48-
<Compile Include="Tests\TestGraph.fs" />
4945
<Content Include="Tests\FCS.args.txt" />
5046
<Content Include="Tests\FCS.prepare.ps1" />
5147
<Content Include="Tests\ComponentTests.args.txt" />
5248
<Content Include="Tests\.gitignore" />
5349
<Compile Include="Tests\TypedTreeGraph.fs" />
50+
<Compile Include="Tests\QueryTrieTests.fs" />
51+
<Compile Include="Tests\AlwaysLinkDetectionTests.fs" />
52+
<Compile Include="Tests\TrieMappingTests.fs" />
53+
<Compile Include="Tests\FileContentMappingTests.fs" />
54+
<Compile Include="Tests\Scenarios.fs" />
55+
<Compile Include="Tests\DependencyResolutionTests.fs" />
5456
<Compile Include="Program.fs" />
5557
<Content Include="Docs.md" />
5658
</ItemGroup>

tests/ParallelTypeCheckingTests/Program.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ open ParallelTypeCheckingTests.DependencyResolution
3232
[<EntryPoint>]
3333
let main _argv =
3434
let filesWithAST =
35-
fcsFiles
35+
ParallelTypeCheckingTests.Tests.DependencyResolutionTests.fcsFiles
3636
|> Array.Parallel.mapi (fun idx file ->
3737
{
3838
Idx = idx
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module ParallelTypeCheckingTests.Tests.AlwaysLinkDetectionTests
2+
3+
open NUnit.Framework
4+
open FSharp.Compiler.Service.Tests.Common
5+
open ParallelTypeCheckingTests.AlwaysLinkDetection
6+
7+
[<Test>]
8+
let ``Detect top level auto open`` () =
9+
let fileContent =
10+
"""
11+
[<AutoOpen>]
12+
module internal Internal.Utilities.Library.Block
13+
14+
open System.Collections.Immutable
15+
16+
[<RequireQualifiedAccess>]
17+
module ImmutableArrayBuilder =
18+
19+
val create: size: int -> ImmutableArray<'T>.Builder
20+
21+
[<RequireQualifiedAccess>]
22+
module ImmutableArray =
23+
24+
[<GeneralizableValue>]
25+
val empty<'T> : ImmutableArray<'T>
26+
27+
val init: n: int -> f: (int -> 'T) -> ImmutableArray<'T>
28+
"""
29+
30+
let ast = parseSourceCode ("ImmutableArray.fsi", fileContent)
31+
Assert.True(doesFileHasAutoOpenBehavior ast)
32+
33+
[<Test>]
34+
let ``Detect global namespace`` () =
35+
let fileContent =
36+
"""
37+
namespace global
38+
39+
type X = { Y: int }
40+
"""
41+
42+
let ast = parseSourceCode ("Global.fsi", fileContent)
43+
Assert.True(doesFileHasAutoOpenBehavior ast)

0 commit comments

Comments
 (0)