-
Notifications
You must be signed in to change notification settings - Fork 847
Consolidate Compiler ErrorMessage tests under one suite. #9525
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
vzarytovskii
merged 14 commits into
dotnet:master
from
vzarytovskii:move-compiler-tests
Jun 23, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
998f1ee
[WIP] Moving compiler component tests to a separate project
vzarytovskii 50dc437
Merge remote-tracking branch 'upstream/master' into move-compiler-tests
vzarytovskii b30ed4f
[WIP] Migrate tests + make it runnable via 'dotnet test'
vzarytovskii 3584698
[WIP] Moving compiler tests to a component suite
vzarytovskii 33a1e4d
[WIP] Moved some compiler component tests to new suite
vzarytovskii bfebdbe
[WIP] Fix path concatenation in tests
vzarytovskii 8ed3c34
Consolidate ErrorMessages compiler tests under component tests suite
vzarytovskii 89d387e
Merge remote-tracking branch 'upstream/master' into move-compiler-tests
vzarytovskii cbcfdf6
Fixed warning with ms.net.test.sdk
vzarytovskii 17b375b
Fixed indentation
vzarytovskii 92bc463
Removed unnecessary references to fsc/fsi from test utilities.
vzarytovskii 4470387
Fix newlines in the assertion
vzarytovskii cc35c92
Update tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNume…
vzarytovskii 5c45e9b
Cleaned up test list; Make RIDs conditional as well
vzarytovskii 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
75 changes: 75 additions & 0 deletions
75
tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.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,75 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.ErrorMessages.ComponentTests | ||
|
|
||
| open Xunit | ||
| open FSharp.Test.Utilities | ||
| open FSharp.Compiler.SourceCodeServices | ||
|
|
||
| module ``Access Of Type Abbreviation`` = | ||
|
|
||
| [<Fact>] | ||
| let ``Private type produces warning when trying to export``() = | ||
| CompilerAssert.TypeCheckSingleError | ||
| """ | ||
| module Library = | ||
| type private Hidden = Hidden of unit | ||
| type Exported = Hidden | ||
| """ | ||
| FSharpErrorSeverity.Warning | ||
| 44 | ||
| (4, 8, 4, 16) | ||
| ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") | ||
|
|
||
| [<Fact>] | ||
| let ``Internal type passes when abbrev is internal``() = | ||
| CompilerAssert.Pass | ||
| """ | ||
| module Library = | ||
| type internal Hidden = Hidden of unit | ||
| type internal Exported = Hidden | ||
| """ | ||
|
|
||
| [<Fact>] | ||
| let ``Internal type produces warning when trying to export``() = | ||
| CompilerAssert.TypeCheckSingleError | ||
| """ | ||
| module Library = | ||
| type internal Hidden = Hidden of unit | ||
| type Exported = Hidden | ||
| """ | ||
| FSharpErrorSeverity.Warning | ||
| 44 | ||
| (4, 8, 4, 16) | ||
| ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") | ||
|
|
||
| [<Fact>] | ||
| let ``Private type produces warning when abbrev is internal``() = | ||
| CompilerAssert.TypeCheckSingleError | ||
| """ | ||
| module Library = | ||
| type private Hidden = Hidden of unit | ||
| type internal Exported = Hidden | ||
| """ | ||
| FSharpErrorSeverity.Warning | ||
| 44 | ||
| (4, 17, 4, 25) | ||
| ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") | ||
|
|
||
| [<Fact>] | ||
| let ``Private type passes when abbrev is private``() = | ||
| CompilerAssert.Pass | ||
| """ | ||
| module Library = | ||
| type private Hidden = Hidden of unit | ||
| type private Exported = Hidden | ||
| """ | ||
|
|
||
| [<Fact>] | ||
| let ``Default access type passes when abbrev is default``() = | ||
| CompilerAssert.Pass | ||
| """ | ||
| module Library = | ||
| type Hidden = Hidden of unit | ||
| type Exported = Hidden | ||
| """ |
8 changes: 4 additions & 4 deletions
8
...ler/ErrorMessages/AssignmentErrorTests.fs → ...sts/ErrorMessages/AssignmentErrorTests.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
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
67 changes: 67 additions & 0 deletions
67
tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.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,67 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.ErrorMessages.ComponentTests | ||
|
|
||
| open Xunit | ||
| open FSharp.Test.Utilities | ||
| open FSharp.Test.Utilities.Utilities | ||
| open FSharp.Compiler.SourceCodeServices | ||
|
|
||
| module ``Confusing Type Name`` = | ||
|
|
||
| [<Fact>] | ||
| let ``Checks expected types with multiple references``() = | ||
| let csLibAB = """ | ||
| public class A { } | ||
| public class B<T> { } | ||
| """ | ||
| let csLibACmpl = | ||
| CompilationUtil.CreateCSharpCompilation(csLibAB, CSharpLanguageVersion.CSharp8, TargetFramework.NetCoreApp30, name = "libA") | ||
| |> CompilationReference.Create | ||
|
|
||
| let csLibBCmpl = | ||
| CompilationUtil.CreateCSharpCompilation(csLibAB, CSharpLanguageVersion.CSharp8, TargetFramework.NetCoreApp30, name = "libB") | ||
| |> CompilationReference.Create | ||
|
|
||
| let fsLibC = """ | ||
| module AMaker | ||
| let makeA () : A = A() | ||
| let makeB () = B<_>() | ||
| """ | ||
|
|
||
| let fsLibD = """ | ||
| module OtherAMaker | ||
| let makeOtherA () : A = A() | ||
| let makeOtherB () = B<_>() | ||
| """ | ||
|
|
||
| let fsLibCCmpl = | ||
| Compilation.Create(fsLibC, Fs, Library, cmplRefs = [csLibACmpl], name = "libC") | ||
| |> CompilationReference.CreateFSharp | ||
|
|
||
| let fsLibDCmpl = | ||
| Compilation.Create(fsLibD, Fs, Library, cmplRefs = [csLibBCmpl], name = "libD") | ||
| |> CompilationReference.CreateFSharp | ||
|
|
||
| let app = """ | ||
| module ConfusingTypeName | ||
| let a = AMaker.makeA() | ||
| let otherA = OtherAMaker.makeOtherA() | ||
| printfn "%A %A" (a.GetType().AssemblyQualifiedName) (otherA.GetType().AssemblyQualifiedName) | ||
| printfn "%A" (a = otherA) | ||
|
|
||
| let b = AMaker.makeB<int>() | ||
| let otherB = OtherAMaker.makeOtherB<int>() | ||
| printfn "%A %A" (b.GetType().AssemblyQualifiedName) (otherB.GetType().AssemblyQualifiedName) | ||
| printfn "%A" (b = otherB) | ||
| """ | ||
|
|
||
| let appCmpl = | ||
| Compilation.Create(app, Fs, Library, cmplRefs = [csLibACmpl; csLibBCmpl; fsLibCCmpl; fsLibDCmpl]) | ||
|
|
||
| CompilerAssert.CompileWithErrors( | ||
| appCmpl, | ||
| [| | ||
| (FSharpErrorSeverity.Error, 1, (6, 19, 6, 25), ("This expression was expected to have type\n 'A (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' \nbut here has type\n 'A (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) | ||
| (FSharpErrorSeverity.Error, 1, (11, 19, 11, 25), ("This expression was expected to have type\n 'B<Microsoft.FSharp.Core.int> (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' \nbut here has type\n 'B<Microsoft.FSharp.Core.int> (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) | ||
| |], true) |
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
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
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.