Skip to content

Commit 5d68b92

Browse files
committed
clean up tests
1 parent c032cc3 commit 5d68b92

File tree

3 files changed

+78
-75
lines changed

3 files changed

+78
-75
lines changed

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationTests.fs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,22 @@ let compileScenario (scenario: Scenario) (method: Method) =
4848
|> withMethod method
4949
|> compile
5050

51-
let scenarios = scriptCompilationScenario :: scenarios |> List.map (fun c -> [| box c |])
51+
let compileAValidScenario (scenario: Scenario) (method: Method) =
52+
compileScenario scenario method
53+
|> shouldSucceed
54+
|> ignore
55+
56+
let scenarios = compilingScenarios |> List.map (fun c -> [| box c |])
5257

5358
[<Theory>]
5459
[<MemberData(nameof scenarios)>]
5560
let ``Compile a valid scenario using graph-based type-checking`` (scenario) =
56-
compileScenario scenario Method.Graph
57-
|> shouldSucceed
58-
|> ignore
61+
compileAValidScenario scenario Method.Graph
5962

6063
[<Theory>]
6164
[<MemberData(nameof scenarios)>]
6265
let ``Compile a valid scenario using sequential type-checking`` (scenario) =
63-
compileScenario scenario Method.Sequential
64-
|> shouldSucceed
65-
|> ignore
66+
compileAValidScenario scenario Method.Sequential
6667

6768
[<Fact>]
6869
let ``Compile misordered scenario using graph-based type-checking fails`` () =

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ open Xunit
55
open FSharp.Compiler.GraphChecking
66
open Scenarios
77

8-
let scenarios = scriptCompilationScenario :: misorderedScenario :: scenarios |> Seq.map (fun p -> [| box p |])
8+
let scenarios = scenarios |> Seq.map (fun p -> [| box p |])
99

1010
[<Theory>]
1111
[<MemberData(nameof scenarios)>]

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let private sourceFile fileName content (dependencies: Set<int>) =
3131
Content = content
3232
}
3333

34-
let internal scenarios =
34+
let internal compilingScenarios =
3535
[
3636
scenario
3737
"Link via full open statement"
@@ -1085,9 +1085,76 @@ module Y = global.Z.N
10851085
"""
10861086
(set [| 0 |])
10871087
]
1088+
scenario
1089+
"Script compilation with #load and downstream files"
1090+
[
1091+
sourceFile
1092+
"A.fs"
1093+
"""
1094+
module LibA
1095+
1096+
type A = { Value: int }
1097+
1098+
let inc x = x + 1
1099+
"""
1100+
Set.empty
1101+
sourceFile
1102+
"B.fs"
1103+
"""
1104+
module LibB
1105+
1106+
let append s i = s + string i
1107+
"""
1108+
(set [| 0 |])
1109+
sourceFile
1110+
"Run.fsx"
1111+
"""
1112+
namespace Script
1113+
1114+
#load "A.fs"
1115+
#load "B.fs"
1116+
1117+
open LibA
1118+
open LibB
1119+
1120+
module ScriptModule =
1121+
let compute s =
1122+
let a = inc 41
1123+
append s a
1124+
"""
1125+
(set [| 1 |])
1126+
sourceFile
1127+
"Independent.fs"
1128+
"""
1129+
module Independent
10881130
1131+
let z = 0
1132+
"""
1133+
Set.empty
1134+
sourceFile
1135+
"DependsOnScript.fs"
1136+
"""
1137+
module Consumer
1138+
1139+
open Script.ScriptModule
1140+
1141+
let result = compute "ok"
1142+
"""
1143+
(set [| 2 |])
1144+
sourceFile
1145+
"AlsoDependsOnScript.fs"
1146+
"""
1147+
module AnotherConsumer
1148+
1149+
let value = Script.ScriptModule.compute "hi"
1150+
"""
1151+
(set [| 2 |])
1152+
]
10891153
]
10901154

1155+
1156+
// Implementation given before signature file. This scenario will not compile, but is supported.
1157+
// Produced graph should have a necessary dependecy to trigger expected errors.
10911158
let internal misorderedScenario =
10921159
// New scenario: signature file erroneously follows implementation
10931160
// We add a backward link from implementation to signature, to correctly trigger
@@ -1121,69 +1188,4 @@ let internal misorderedScenario =
11211188
(set [| 0 |])
11221189
]
11231190

1124-
let internal scriptCompilationScenario =
1125-
scenario
1126-
"Script compilation with #load and downstream files"
1127-
[
1128-
sourceFile
1129-
"A.fs"
1130-
"""
1131-
module LibA
1132-
1133-
type A = { Value: int }
1134-
1135-
let inc x = x + 1
1136-
"""
1137-
Set.empty
1138-
sourceFile
1139-
"B.fs"
1140-
"""
1141-
module LibB
1142-
1143-
let append s i = s + string i
1144-
"""
1145-
(set [| 0 |])
1146-
sourceFile
1147-
"Run.fsx"
1148-
"""
1149-
namespace Script
1150-
1151-
#load "A.fs"
1152-
#load "B.fs"
1153-
1154-
open LibA
1155-
open LibB
1156-
1157-
module ScriptModule =
1158-
let compute s =
1159-
let a = inc 41
1160-
append s a
1161-
"""
1162-
(set [| 1 |])
1163-
sourceFile
1164-
"Independent.fs"
1165-
"""
1166-
module Independent
1167-
1168-
let z = 0
1169-
"""
1170-
Set.empty
1171-
sourceFile
1172-
"DependsOnScript.fs"
1173-
"""
1174-
module Consumer
1175-
1176-
open Script.ScriptModule
1177-
1178-
let result = compute "ok"
1179-
"""
1180-
(set [| 2 |])
1181-
sourceFile
1182-
"AlsoDependsOnScript.fs"
1183-
"""
1184-
module AnotherConsumer
1185-
1186-
let value = Script.ScriptModule.compute "hi"
1187-
"""
1188-
(set [| 2 |])
1189-
]
1191+
let internal scenarios = misorderedScenario :: compilingScenarios

0 commit comments

Comments
 (0)