-
Notifications
You must be signed in to change notification settings - Fork 831
Move signature tests from cambridge suite to component tests #14317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
108c0ac
File re-arrangement
T-Gro 6f1bed5
Component test for signature roundtrip
T-Gro 060fd59
access tests aligned
T-Gro 836e983
moving array tests
T-Gro 0093c1b
inner poly and generic measures ported
T-Gro 8da9543
measures ported
T-Gro c8d6003
Lib test and bug repro
T-Gro c8ed9e8
members test + issue filed
T-Gro ff0761a
making sure members tests work via signature generation roundtrip
T-Gro c7db2f8
Putting global.json back
T-Gro 4069c73
Merge branch 'main' into moveSignatureTestsToComponentTests
T-Gro e1d7c18
Tab -> spaces in fsproj
T-Gro 2cb94e0
Fixing typo
T-Gro 0bafc12
Merge branch 'main' into moveSignatureTestsToComponentTests
T-Gro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs
This file contains hidden or 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,34 @@ | ||
| module FSharp.Compiler.ComponentTests.Signatures.SigGenerationRoundTripTests | ||
|
|
||
| open Xunit | ||
| open FSharp.Test | ||
| open FSharp.Test.Compiler | ||
| open System.IO | ||
|
|
||
| let testCasesDir = Path.Combine(__SOURCE_DIRECTORY__,"TestCasesForGenerationRoundTrip") | ||
| let allTestCases = | ||
| Directory.EnumerateFiles(testCasesDir) | ||
| |> Seq.toArray | ||
| |> Array.map Path.GetFileName | ||
| |> Array.map (fun f -> [|f :> obj|]) | ||
|
|
||
| [<Theory>] | ||
| [<MemberData(nameof(allTestCases))>] | ||
| let ``Generate and compile`` implFileName = | ||
| let implContents = File.ReadAllText (Path.Combine(testCasesDir,implFileName)) | ||
|
|
||
| let generatedSignature = | ||
| Fs implContents | ||
| |> withLangVersionPreview | ||
| |> withDefines ["TESTS_AS_APP";"COMPILED"] | ||
| |> printSignatures | ||
|
|
||
| Fsi generatedSignature | ||
| |> withAdditionalSourceFile (FsSource implContents) | ||
| |> withLangVersionPreview | ||
| |> withDefines ["TESTS_AS_APP";"COMPILED"] | ||
| |> ignoreWarnings | ||
| |> asExe | ||
| |> compile | ||
| |> shouldSucceed | ||
|
|
8 changes: 8 additions & 0 deletions
8
...mpiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access-minimal-repro.fsx
This file contains hidden or 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,8 @@ | ||
| module Core_access | ||
|
|
||
| [<Sealed>] | ||
| type MyClassPropertyGetters = | ||
| member internal x.InstInternal = 12 | ||
| member private x.InstPrivate = 12 | ||
| member public x.InstPublic = 12 | ||
| member x.InstDefault = 12 | ||
287 changes: 287 additions & 0 deletions
287
tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/access.fsx
This file contains hidden or 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,287 @@ | ||
| module Core_access | ||
|
|
||
| #light | ||
| let failures = ref [] | ||
|
|
||
| let report_failure (s : string) = | ||
| stderr.Write" NO: " | ||
| stderr.WriteLine s | ||
| failures.Value <- failures.Value @ [s] | ||
|
|
||
| let test (s : string) b = | ||
| stderr.Write(s) | ||
| if b then stderr.WriteLine " OK" | ||
| else report_failure (s) | ||
|
|
||
| (*--------------------*) | ||
|
|
||
| // Test cases for bug://1562 | ||
| // Checking that generated signature can be compiled against the file. | ||
|
|
||
| type internal typInternal = | AAA1 | ||
| type private typPrivate = | AAA2 | ||
| type public typPublic = | AAA3 | ||
| type typDefault = | AAA4 | ||
| type internal rrr = | AAA | ||
|
|
||
| let internal ValInternal = 1212 | ||
| let private ValPrivate = 1212 | ||
| let public ValPublic = 1212 | ||
| let ValDefault = 1212 | ||
|
|
||
| [<Sealed>] | ||
| type MyClassFields = | ||
| val internal fieldInternal : int | ||
| val private fieldPrivate : int | ||
| val public fieldPublic : int | ||
|
|
||
| [<Sealed>] | ||
| type MyClassMutableFields = | ||
| val mutable internal mfieldInternal : int | ||
| val mutable private mfieldPrivate : int | ||
| val mutable public mfieldPublic : int | ||
|
|
||
| [<Sealed>] | ||
| type MyClassStaticMembers = | ||
| static member internal SInternal = 12 | ||
| static member private SPrivate = 12 | ||
| static member public SPublic = 12 | ||
| static member SDefault = 12 | ||
| static member internal SMInternal() = 12 | ||
| static member private SMPrivate() = 12 | ||
| static member public SMPublic() = 12 | ||
| static member SMDefault() = 12 | ||
|
|
||
| [<Sealed>] | ||
| type MyClassPropertiyGetters = | ||
| member internal x.InstInternal = 12 | ||
| member private x.InstPrivate = 12 | ||
| member public x.InstPublic = 12 | ||
| member x.InstDefault = 12 | ||
|
|
||
| type MyClassExplicitCtors = | ||
| val v : int | ||
| internal new(x) = { v = x } | ||
| private new(x,y) = { v = x + y} | ||
| public new(x,y,z) = { v = x + y + z} | ||
|
|
||
| type MyClassExplicitCtors2 = | ||
| new() = {} | ||
| internal new(x) = let v : int = x in {} | ||
| private new(x,y) = let v : int = x + y in {} | ||
| public new(x,y,z) = let v : int = x + y + z in {} | ||
|
|
||
| [<Sealed>] | ||
| type MyClassPropertyGetSetterMatrix = | ||
| //-- | ||
| member obj.PropGetSetInternalInternal | ||
| with internal get() = 1 | ||
| and internal set(x:int) = () | ||
| member obj.PropGetSetInternalPrivate | ||
| with internal get() = 1 | ||
| and private set(x:int) = () | ||
| member obj.PropGetSetInternalPublic | ||
| with internal get() = 1 | ||
| and public set(x:int) = () | ||
| //-- | ||
| member obj.PropGetSetPrivateInternal | ||
| with private get() = 1 | ||
| and internal set(x:int) = () | ||
| member obj.PropGetSetPrivatePrivate | ||
| with private get() = 1 | ||
| and private set(x:int) = () | ||
| member obj.PropGetSetPrivatePublic | ||
| with private get() = 1 | ||
| and public set(x:int) = () | ||
| //-- | ||
| member obj.PropGetSetPublicInternal | ||
| with public get() = 1 | ||
| and internal set(x:int) = () | ||
| member obj.PropGetSetPublicPrivate | ||
| with public get() = 1 | ||
| and private set(x:int) = () | ||
| member obj.PropGetSetPublicPublic | ||
| with public get() = 1 | ||
| and public set(x:int) = () | ||
|
|
||
| [<Sealed>] | ||
| type MyClassImplicitCtorInternal internal() = | ||
| member obj.Res = 12 | ||
|
|
||
| [<Sealed>] | ||
| type MyClassImplicitCtorPrivate private() = | ||
| member obj.Res = 12 | ||
|
|
||
| module internal ModInternal = begin end | ||
| module private ModPrivate = begin end | ||
| module public ModPublic = begin end | ||
|
|
||
| type recordRepInternal = internal { rfA1 : int } | ||
| type recordRepPrivate = private { rfA2 : int } | ||
| type recordRepPublic = public { rfA3 : int } | ||
|
|
||
| type dtypeRepInternal = internal | AA1 | BB1 | ||
| type dtypeRepPrivate = private | AA2 | BB2 | ||
| type dtypeRepPublic = public | AA3 | BB3 | ||
|
|
||
| type internal dtypeRepPublic2 = private | AA3 | BB3 | ||
| type private dtypeRepPublic3 = internal | AA3 | BB3 | ||
|
|
||
| type internal dtypeRepPublic4 = | ||
| private | ||
| | AA3 | ||
| | BB3 | ||
|
|
||
| module internal M = | ||
| module private PP = | ||
| type dtypeRepPublic5 = | ||
| | AA3 | ||
| | BB3 | ||
|
|
||
| module private M2 = | ||
| module internal P = | ||
| let vv = 12 | ||
|
|
||
|
|
||
| module RestrictedRecordsAndUnionsUsingPrivateAndInternalTypes = | ||
|
|
||
| module public Test1 = | ||
|
|
||
| type internal Data = | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| type public Datum = | ||
| internal | ||
| { | ||
| Thing: Data | ||
| } | ||
|
|
||
| type public Datum2 = | ||
| internal | A of Data * Data | B of Data | ||
|
|
||
| module public Test2 = | ||
|
|
||
| type internal Data = | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| type internal Datum = | ||
| { | ||
| Thing: Data | ||
| } | ||
|
|
||
| type internal Datum2 = | ||
| | A of Data * Data | B of Data | ||
|
|
||
| module public Test3 = | ||
|
|
||
| type public Data = | ||
| internal | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| type internal Datum = | ||
| { | ||
| Thing: Data | ||
| } | ||
|
|
||
| type internal Datum2 = | ||
| internal | A of Data * Data | B of Data | ||
|
|
||
|
|
||
| module public Test4 = | ||
|
|
||
| type internal Data = | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| type public Datum = | ||
| internal | ||
| { | ||
| Thing: Data | ||
| } | ||
|
|
||
| type public Datum2 = | ||
| internal | A of Data * Data | B of Data | ||
|
|
||
|
|
||
| module public Test5 = | ||
|
|
||
| type private Data = | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| type public Datum = | ||
| private | ||
| { | ||
| Thing: Data | ||
| } | ||
|
|
||
| type public Datum2 = | ||
| private | A of Data * Data | B of Data | ||
|
|
||
|
|
||
| module Test6 = | ||
| module internal HelperModule = | ||
|
|
||
| type public Data = | ||
| private | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| let internal handle (data:Data): int = data.Datum | ||
|
|
||
| module public Module = | ||
|
|
||
| type public Data = | ||
| private | ||
| { | ||
| Thing: HelperModule.Data | ||
| } | ||
|
|
||
| let public getInt (data:Data): int = HelperModule.handle data.Thing | ||
|
|
||
| module Test7 = | ||
| module internal HelperModule = | ||
|
|
||
| type Data = | ||
| { | ||
| Datum: int | ||
| } | ||
|
|
||
| let handle (data:Data): int = data.Datum | ||
|
|
||
| module Module = | ||
|
|
||
| type Data = | ||
| internal | ||
| { | ||
| Thing: HelperModule.Data | ||
| } | ||
|
|
||
| let getInt (data:Data): int = HelperModule.handle data.Thing | ||
|
|
||
|
|
||
| (*--------------------*) | ||
|
|
||
| #if TESTS_AS_APP | ||
T-Gro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let RUN() = failures.Value | ||
| #else | ||
| let aa = | ||
| match failures.Value with | ||
| | [] -> | ||
| stdout.WriteLine "Test Passed" | ||
| System.IO.File.WriteAllText("test.ok","ok") | ||
| exit 0 | ||
| | _ -> | ||
| stdout.WriteLine "Test Failed" | ||
| exit 1 | ||
| #endif | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.