-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Fable.Tests.CompilationTests | ||
|
||
open System.IO | ||
open Expecto | ||
|
||
let private data = Path.Combine(__SOURCE_DIRECTORY__, "data") | ||
|
||
let tests = | ||
Directory.EnumerateDirectories(data) | ||
|> Seq.map (fun testCaseDir -> // | ||
testCaseAsync | ||
(Path.GetDirectoryName(testCaseDir)) | ||
(async { | ||
let project = | ||
Directory.GetFileSystemEntries(testCaseDir, "*.fsproj") |> Seq.exactlyOne | ||
// clean up old actual files | ||
for f in Directory.GetFileSystemEntries(testCaseDir, "*.actual") do | ||
File.Delete f | ||
|
||
// Compile project | ||
let exitCode = | ||
Fable.Cli.Entry.main [| project; "--cwd"; "$\"{testCaseDir}\""; "-e"; ".js.actual" |] | ||
|
||
Expect.equal exitCode 0 "Expected exit code to be 0" | ||
|
||
for expected in Directory.GetFileSystemEntries(testCaseDir, "*.expected") do | ||
let actual = Path.ChangeExtension(expected, ".actual") | ||
Expect.isTrue (File.Exists actual) $"No actual file was produced for {expected}" | ||
let expectedContent = File.ReadAllText expected | ||
let actualContent = File.ReadAllText actual | ||
Expect.equal actualContent expectedContent "The expected content differs from the actual content" | ||
|
||
return () | ||
})) | ||
|
||
|> Seq.toList | ||
|> ftestList "Compilation" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ let allTests = | |
[ | ||
Cli.tests | ||
FileWatcher.tests | ||
CompilationTests.tests | ||
] | ||
|
||
open Expecto | ||
|
4 changes: 4 additions & 0 deletions
4
tests/Integration/Integration/data/signatureHidesFunction/Library.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Lib | ||
|
||
let g a = a + 1 | ||
let f b = g b |
3 changes: 3 additions & 0 deletions
3
tests/Integration/Integration/data/signatureHidesFunction/Library.fsi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Lib | ||
|
||
val f: b:int -> int |
9 changes: 9 additions & 0 deletions
9
tests/Integration/Integration/data/signatureHidesFunction/Library.js.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
function g(a) { | ||
return a + 1; | ||
} | ||
|
||
export function f(b) { | ||
return g(b); | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
tests/Integration/Integration/data/signatureHidesFunction/signatureHidesFunction.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Library.fsi" /> | ||
<Compile Include="Library.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Fable.Core" Version="4.0.0" /> | ||
<PackageReference Update="FSharp.Core" Version="7.0.400" /> | ||
</ItemGroup> | ||
|
||
</Project> |