Skip to content

Commit

Permalink
Add test and go back to first fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Jun 29, 2016
1 parent c60b7e4 commit c213aea
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4991,7 +4991,8 @@ module private ScriptPreprocessClosure =
[ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs.

let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat
ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns) :: loadedSources |> List.map FindClosure |> List.concat // Final closure is in reverse order. Keep the closed source at the top.
(loadedSources |> List.map FindClosure |> List.concat)
@ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)]
| None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])]

closureDirectives |> List.map FindClosure |> List.concat, !tcConfig
Expand Down Expand Up @@ -5053,7 +5054,7 @@ module private ScriptPreprocessClosure =
let rootWarnings = rootWarnings |> List.filter isRootRange

let result : LoadClosure =
{ SourceFiles = List.groupByFirst !sourceFiles
{ SourceFiles = List.groupByFirst !sourceFiles |> List.rev
References = List.groupByFirst references
UnresolvedReferences = unresolvedReferences
Inputs = !sourceInputs
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun
let co =
{
ProjectFileName = filename + ".fsproj" // Make a name that is unique in this directory.
ProjectFileNames = fas.Inputs |> List.map fst |> List.toArray
ProjectFileNames = fas.SourceFiles |> List.map fst |> List.toArray
OtherOptions = otherFlags
ReferencedProjects= [| |]
IsIncompleteTypeCheckEnvironment = false
Expand Down
12 changes: 12 additions & 0 deletions tests/service/ProjectOptionsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,17 @@ let ``Project file parsing -- space in file name``() =
|> set
|> should equal (set [ "Test2File1.fs"; "Test2File2.fs" ])

[<Test>]
let ``Test ProjectFileNames order for GetProjectOptionsFromScript`` () = // See #594
let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/Main.fsx"
let scriptSource = File.ReadAllText scriptPath
let projOpts =
checker.GetProjectOptionsFromScript(scriptPath, scriptSource)
|> Async.RunSynchronously
projOpts.ProjectFileNames
|> Array.map Path.GetFileNameWithoutExtension
|> (=) [|"BaseLib"; "Lib1"; "Lib2"; "Main"|]
|> shouldEqual true

#endif

3 changes: 3 additions & 0 deletions tests/service/data/ScriptProject/BaseLib.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BaseLib

let add2 x = x + 2
2 changes: 2 additions & 0 deletions tests/service/data/ScriptProject/Lib1.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#load "BaseLib.fs"
let add3 = BaseLib.add2 >> ((+) 1)
2 changes: 2 additions & 0 deletions tests/service/data/ScriptProject/Lib2.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#load "BaseLib.fs"
let add4 = BaseLib.add2 >> ((+) 2)
4 changes: 4 additions & 0 deletions tests/service/data/ScriptProject/Main.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#load "Lib1.fsx"
#load "Lib2.fsx"
Lib1.add3 5 |> printfn "%i"
Lib2.add4 5 |> printfn "%i"

0 comments on commit c213aea

Please sign in to comment.