Skip to content

Commit caebe81

Browse files
committed
clean up tests
1 parent c032cc3 commit caebe81

File tree

3 files changed

+79
-77
lines changed

3 files changed

+79
-77
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: 70 additions & 69 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,67 +1085,30 @@ module Y = global.Z.N
10851085
"""
10861086
(set [| 0 |])
10871087
]
1088-
1089-
]
1090-
1091-
let internal misorderedScenario =
1092-
// New scenario: signature file erroneously follows implementation
1093-
// We add a backward link from implementation to signature, to correctly trigger
1094-
// FS0238 (implementation already given).
1095-
scenario
1096-
"Signature file follows implementation"
1097-
[
1098-
sourceFile
1099-
"A.fs"
1100-
"""
1101-
module A
1102-
1103-
let a x = x + 1
1104-
"""
1105-
Set.empty
1106-
sourceFile
1107-
"B.fs"
1108-
"""
1109-
module B
1110-
1111-
let b = A.a 42
1112-
"""
1113-
(set [| 0 |])
1114-
sourceFile
1115-
"A.fsi"
1116-
"""
1117-
module A
1118-
1119-
val a: int -> int
1120-
"""
1121-
(set [| 0 |])
1122-
]
1123-
1124-
let internal scriptCompilationScenario =
1125-
scenario
1126-
"Script compilation with #load and downstream files"
1127-
[
1128-
sourceFile
1129-
"A.fs"
1130-
"""
1088+
scenario
1089+
"Script compilation with #load and downstream files"
1090+
[
1091+
sourceFile
1092+
"A.fs"
1093+
"""
11311094
module LibA
11321095
11331096
type A = { Value: int }
11341097
11351098
let inc x = x + 1
11361099
"""
1137-
Set.empty
1138-
sourceFile
1139-
"B.fs"
1140-
"""
1100+
Set.empty
1101+
sourceFile
1102+
"B.fs"
1103+
"""
11411104
module LibB
11421105
11431106
let append s i = s + string i
11441107
"""
1145-
(set [| 0 |])
1146-
sourceFile
1147-
"Run.fsx"
1148-
"""
1108+
(set [| 0 |])
1109+
sourceFile
1110+
"Run.fsx"
1111+
"""
11491112
namespace Script
11501113
11511114
#load "A.fs"
@@ -1155,35 +1118,73 @@ open LibA
11551118
open LibB
11561119
11571120
module ScriptModule =
1158-
let compute s =
1159-
let a = inc 41
1160-
append s a
1121+
let compute s =
1122+
let a = inc 41
1123+
append s a
11611124
"""
1162-
(set [| 1 |])
1163-
sourceFile
1164-
"Independent.fs"
1165-
"""
1125+
(set [| 1 |])
1126+
sourceFile
1127+
"Independent.fs"
1128+
"""
11661129
module Independent
11671130
11681131
let z = 0
11691132
"""
1170-
Set.empty
1171-
sourceFile
1172-
"DependsOnScript.fs"
1173-
"""
1133+
Set.empty
1134+
sourceFile
1135+
"DependsOnScript.fs"
1136+
"""
11741137
module Consumer
11751138
11761139
open Script.ScriptModule
11771140
11781141
let result = compute "ok"
11791142
"""
1180-
(set [| 2 |])
1181-
sourceFile
1182-
"AlsoDependsOnScript.fs"
1183-
"""
1143+
(set [| 2 |])
1144+
sourceFile
1145+
"AlsoDependsOnScript.fs"
1146+
"""
11841147
module AnotherConsumer
11851148
11861149
let value = Script.ScriptModule.compute "hi"
11871150
"""
1188-
(set [| 2 |])
1189-
]
1151+
(set [| 2 |])
1152+
]
1153+
]
1154+
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.
1158+
let internal misorderedScenario =
1159+
scenario
1160+
"Signature file follows implementation"
1161+
[
1162+
sourceFile
1163+
"A.fs"
1164+
"""
1165+
module A
1166+
1167+
let a x = x + 1
1168+
"""
1169+
Set.empty
1170+
sourceFile
1171+
"B.fs"
1172+
"""
1173+
module B
1174+
1175+
let b = A.a 42
1176+
"""
1177+
(set [| 0 |])
1178+
sourceFile
1179+
"A.fsi"
1180+
"""
1181+
module A
1182+
1183+
val a: int -> int
1184+
"""
1185+
// We add a backward link from implementation to signature, to correctly trigger
1186+
// FS0238 (implementation already given).
1187+
(set [| 0 |])
1188+
]
1189+
1190+
let internal scenarios = misorderedScenario :: compilingScenarios

0 commit comments

Comments
 (0)