Skip to content

Commit 43f0a78

Browse files
committed
add script mode test
1 parent 252dd09 commit 43f0a78

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let compileScenario (scenario: Scenario) (method: Method) =
4848
|> withMethod method
4949
|> compile
5050

51-
let scenarios = scenarios |> List.map (fun c -> [| box c |])
51+
let scenarios = scriptCompilationScenario :: scenarios |> List.map (fun c -> [| box c |])
5252

5353
[<Theory>]
5454
[<MemberData(nameof scenarios)>]

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

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

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,4 +1119,71 @@ let internal misorderedScenario =
11191119
val a: int -> int
11201120
"""
11211121
(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+
"""
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 |])
11221189
]

0 commit comments

Comments
 (0)