From 998f1ee7882fa67e4a6a6c03f064b954fcbac746 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii <1260985+vzarytovskii@users.noreply.github.com> Date: Thu, 18 Jun 2020 15:26:23 +0200 Subject: [PATCH 01/12] [WIP] Moving compiler component tests to a separate project --- .../ErrorMessages/ConstructorTests.fs | 20 +++++++++---------- .../InvalidNumericLiteralTests.fs | 2 +- .../FSharp.Compiler.ComponentTests.fsproj | 3 ++- tests/fsharp/FSharpSuite.Tests.fsproj | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/ConstructorTests.fs (96%) diff --git a/tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs similarity index 96% rename from tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index be7e5823391..dfb6bae36c4 100644 --- a/tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -1,21 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.Constructor.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Constructor`` = - [] + [] let ``Invalid Record``() = CompilerAssert.TypeCheckWithErrors """ type Record = {field1:int; field2:int} let doSomething (xs) = List.map (fun {field1=x} -> x) xs - doSomething {Record.field1=0; field2=0} """ [| @@ -23,7 +21,7 @@ doSomething {Record.field1=0; field2=0} FSharpErrorSeverity.Warning, 20, (5, 1, 5, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] - [] + [] let ``Comma In Rec Ctor``() = CompilerAssert.TypeCheckWithErrors """ @@ -35,7 +33,7 @@ let x = { Name = "Isaac", Age = 21, City = "London" } FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'" |] - [] + [] let ``Missing Comma In Ctor``() = CompilerAssert.TypeCheckWithErrors """ @@ -54,7 +52,7 @@ let p = FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')." |] - [] + [] let ``Missing Ctor Value``() = CompilerAssert.TypeCheckSingleError """ @@ -71,7 +69,7 @@ let p = (7, 5, 8, 21) "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'." - [] + [] let ``Extra Argument In Ctor``() = CompilerAssert.TypeCheckSingleError """ @@ -87,7 +85,7 @@ let p = (7, 5, 7, 14) "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." - [] + [] let ``Extra Argument In Ctor2``() = CompilerAssert.TypeCheckSingleError """ @@ -105,7 +103,7 @@ let p = (9, 5, 9, 16) "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." - [] + [] let ``Valid Comma In Rec Ctor``() = CompilerAssert.Pass """ diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index c6631ab629e..f35c3295b6d 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ComponentTests +namespace FSharp.Compiler.NumericLiterals.ComponentTests open Xunit open FSharp.Test.Utilities diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 6f9172bf9bc..650e2cf9267 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -16,7 +16,8 @@ - + + diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 91f242d059c..bcd8ee8ba34 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -33,7 +33,6 @@ - From b30ed4fc187844e27cd0826e7243aedda155dbb4 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii <1260985+vzarytovskii@users.noreply.github.com> Date: Thu, 18 Jun 2020 15:47:51 +0200 Subject: [PATCH 02/12] [WIP] Migrate tests + make it runnable via 'dotnet test' --- tests/Directory.Build.targets | 2 +- .../FSharp.Compiler.ComponentTests.fsproj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 6df5fdfa9c7..77272699622 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -9,7 +9,7 @@ - + diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 650e2cf9267..136a8d8f1f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -5,6 +5,8 @@ net472;netcoreapp3.1 netcoreapp3.1 + win-x86;win-x64;linux-x64;osx-x64 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 true Library true From 3584698f1fe777c4ba92afed69b424e58c8cdaef Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 18 Jun 2020 17:27:46 +0200 Subject: [PATCH 03/12] [WIP] Moving compiler tests to a component suite --- .../ErrorMessages/ConstructorTests.fs | 8 ++++---- tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index dfb6bae36c4..4e7bb0d5773 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -17,8 +17,8 @@ let doSomething (xs) = List.map (fun {field1=x} -> x) xs doSomething {Record.field1=0; field2=0} """ [| - FSharpErrorSeverity.Error, 1, (5, 13, 5, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' " - FSharpErrorSeverity.Warning, 20, (5, 1, 5, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + FSharpErrorSeverity.Error, 1, (4, 13, 4, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' " + FSharpErrorSeverity.Warning, 20, (4, 1, 4, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] [] @@ -29,7 +29,7 @@ type Person = { Name : string; Age : int; City : string } let x = { Name = "Isaac", Age = 21, City = "London" } """ [| - FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' \r\nA ';' is used to separate field values in records. Consider replacing ',' with ';'." + FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'." FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'" |] @@ -46,7 +46,7 @@ let p = Age = 18) """ [| - FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:\r\n nan" + FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan" FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined." FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')." diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index 8553d2cfd44..674d5d4bbf2 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -25,8 +25,14 @@ - + + + + + + From 33a1e4dc564f86d1bcfb2f57a47ea5fa37ea0fb6 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 12:50:07 +0200 Subject: [PATCH 04/12] [WIP] Moved some compiler component tests to new suite --- .../AccessOfTypeAbbreviationTests.fs | 29 ++++--- .../ErrorMessages/AssignmentErrorTests.fs | 6 +- .../ErrorMessages/ClassesTests.fs | 27 +++---- .../ErrorMessages/ConstructorTests.fs | 2 +- .../ErrorMessages/DontSuggestTests.fs | 13 ++- .../ElseBranchHasWrongTypeTests.fs | 24 +++--- .../InvalidNumericLiteralTests.fs | 4 +- .../ErrorMessages/MissingElseBranch.fs | 11 ++- .../ErrorMessages/MissingExpressionTests.fs | 6 +- .../ErrorMessages/ModuleAbbreviationTests.fs | 6 +- .../ErrorMessages/NameResolutionTests.fs | 13 ++- .../ErrorMessages/SuggestionsTests.fs | 79 +++++++++---------- .../ErrorMessages/TypeMismatchTests.fs | 29 ++++--- .../ErrorMessages/UnitGenericAbstactType.fs | 6 +- .../ErrorMessages/UpcastDowncastTests.fs | 11 ++- .../ErrorMessages/WarnExpressionTests.fs | 28 +++---- .../ErrorMessages/WrongSyntaxInForLoop.fs | 6 +- 17 files changed, 146 insertions(+), 154 deletions(-) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/AccessOfTypeAbbreviationTests.fs (81%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/AssignmentErrorTests.fs (88%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/ClassesTests.fs (82%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/DontSuggestTests.fs (88%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/ElseBranchHasWrongTypeTests.fs (96%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/MissingElseBranch.fs (93%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/MissingExpressionTests.fs (90%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/ModuleAbbreviationTests.fs (88%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/NameResolutionTests.fs (81%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/SuggestionsTests.fs (74%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/TypeMismatchTests.fs (86%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/UnitGenericAbstactType.fs (92%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/UpcastDowncastTests.fs (94%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/WarnExpressionTests.fs (97%) rename tests/{fsharp/Compiler => FSharp.Compiler.ComponentTests}/ErrorMessages/WrongSyntaxInForLoop.fs (87%) diff --git a/tests/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs similarity index 81% rename from tests/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs index f6fc14bbef5..c2c097affbd 100644 --- a/tests/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Access Of Type Abbreviation`` = - [] - let ``Test1``() = + [] + let ``Private type produces warning when trying to export``() = CompilerAssert.TypeCheckSingleError """ module Library = @@ -22,8 +21,8 @@ module Library = (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.\r\nAs 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." - [] - let ``Test2``() = + [] + let ``Internal type passes when abbrev is internal``() = CompilerAssert.Pass """ module Library = @@ -31,8 +30,8 @@ module Library = type internal Exported = Hidden """ - [] - let ``Test3``() = + [] + let ``Internal type produces warning when trying to export``() = CompilerAssert.TypeCheckSingleError """ module Library = @@ -44,8 +43,8 @@ module Library = (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.\r\nAs 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." - [] - let ``Test4``() = + [] + let ``Private type produces warning when abbrev is internal``() = CompilerAssert.TypeCheckSingleError """ module Library = @@ -57,8 +56,8 @@ module Library = (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.\r\nAs 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." - [] - let ``Test5``() = + [] + let ``Private type passes when abbrev is private``() = CompilerAssert.Pass """ module Library = @@ -66,8 +65,8 @@ module Library = type private Exported = Hidden """ - [] - let ``Test6``() = + [] + let ``Default access type passes when abbrev is default``() = CompilerAssert.Pass """ module Library = diff --git a/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs similarity index 88% rename from tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs index c1226c4ff93..9d3254dac09 100644 --- a/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Errors assigning to mutable objects`` = - [] + [] let ``Assign to immutable error``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs similarity index 82% rename from tests/fsharp/Compiler/ErrorMessages/ClassesTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index f02837ef0c3..a51e92ed944 100644 --- a/tests/fsharp/Compiler/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Classes`` = - [] + [] let ``Tuple In Abstract Method``() = CompilerAssert.TypeCheckWithErrors """ @@ -27,7 +26,7 @@ let x = FSharpErrorSeverity.Error, 783, (6, 9, 6, 19), "At least one override did not correctly implement its corresponding abstract member" |] - [] + [] let ``Wrong Arity``() = CompilerAssert.TypeCheckSingleError """ @@ -43,7 +42,7 @@ MyType.MyMember("", 0, 0) (7, 1, 7, 26) "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments." - [] + [] let ``Method Is Not Static``() = CompilerAssert.TypeCheckSingleError """ @@ -57,7 +56,7 @@ let x = Class1.X() (5, 9, 5, 17) "Method or object constructor 'X' is not static" - [] + [] let ``Matching Method With Same Name Is Not Abstract``() = CompilerAssert.TypeCheckWithErrors """ @@ -75,7 +74,7 @@ let foo = FSharpErrorSeverity.Error, 783, (6, 11, 6, 14), "At least one override did not correctly implement its corresponding abstract member" |] - [] + [] let ``No Matching Abstract Method With Same Name``() = CompilerAssert.TypeCheckWithErrors """ @@ -89,13 +88,13 @@ let x = } """ [| - FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:\r\n MyFunction" + FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction" FSharpErrorSeverity.Error, 17, (8, 19, 8, 27), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: \r\n\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'\r\n\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'\r\nNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." + FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." FSharpErrorSeverity.Error, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member" |] - [] + [] let ``Member Has Multiple Possible Dispatch Slots``() = CompilerAssert.TypeCheckWithErrors """ @@ -108,11 +107,11 @@ type Overload = override __.Bar _ = 1 """ [| - FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: \r\n\t'abstract member IOverload.Bar : double -> int'\r\n\t'abstract member IOverload.Bar : int -> int'\r\nNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:\r\n Bar : double -> int\r\n Bar : int -> int." + FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." + FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int." |] - [] + [] let ``Do Cannot Have Visibility Declarations``() = CompilerAssert.ParseWithErrors """ diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index 4e7bb0d5773..c9636e711a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Constructor.ComponentTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests open Xunit open FSharp.Test.Utilities diff --git a/tests/fsharp/Compiler/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs similarity index 88% rename from tests/fsharp/Compiler/ErrorMessages/DontSuggestTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs index f7b3cc2cb05..09f68ae1de1 100644 --- a/tests/fsharp/Compiler/ErrorMessages/DontSuggestTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Don't Suggest`` = - [] + [] let ``Dont Suggest Completely Wrong Stuff``() = CompilerAssert.TypeCheckSingleError """ @@ -18,9 +17,9 @@ let _ = Path.GetFullPath "images" FSharpErrorSeverity.Error 39 (2, 9, 2, 13) - "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:\r\n Math" + "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math" - [] + [] let ``Dont Suggest When Things Are Open``() = CompilerAssert.ParseWithErrors """ @@ -37,7 +36,7 @@ let x = N. FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error." |] - [] + [] let ``Dont Suggest Intentionally Unused Variables``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/ElseBranchHasWrongTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs similarity index 96% rename from tests/fsharp/Compiler/ErrorMessages/ElseBranchHasWrongTypeTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs index ed5b9a44863..188244489a2 100644 --- a/tests/fsharp/Compiler/ErrorMessages/ElseBranchHasWrongTypeTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Else branch has wrong type`` = - [] + [] let ``Else branch is int while if branch is string``() = CompilerAssert.TypeCheckSingleError """ @@ -23,7 +23,7 @@ let y = (5, 10, 5, 13) "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." - [] + [] let ``Else branch is a function that returns int while if branch is string``() = CompilerAssert.TypeCheckSingleError """ @@ -39,7 +39,7 @@ let y = "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." - [] + [] let ``Else branch is a sequence of expressions that returns int while if branch is string``() = CompilerAssert.TypeCheckSingleError """ @@ -58,7 +58,7 @@ let y = "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." - [] + [] let ``Else branch is a longer sequence of expressions that returns int while if branch is string``() = CompilerAssert.TypeCheckSingleError """ @@ -79,7 +79,7 @@ let y = "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." - [] + [] let ``Else branch context doesn't propagate into function application``() = CompilerAssert.TypeCheckSingleError """ @@ -95,7 +95,7 @@ let y = (7, 11, 7, 14) "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " - [] + [] let ``Else branch context doesn't propagate into function application even if not last expr``() = CompilerAssert.TypeCheckSingleError """ @@ -112,7 +112,7 @@ let y = (7, 11, 7, 14) "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " - [] + [] let ``Else branch context doesn't propagate into for loop``() = CompilerAssert.TypeCheckSingleError """ @@ -131,7 +131,7 @@ let y = (7, 14, 7, 22) "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " - [] + [] let ``Else branch context doesn't propagate to lines before last line``() = CompilerAssert.TypeCheckSingleError """ @@ -149,7 +149,7 @@ let y = (7, 22, 7, 23) "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " - [] + [] let ``Else branch should not have wrong context type``() = CompilerAssert.TypeCheckWithErrors """ @@ -162,7 +162,7 @@ let y : bool = FSharpErrorSeverity.Error, 1, (5, 10, 5, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." |] - [] + [] let ``Else branch has wrong type in nested if``() = CompilerAssert.TypeCheckWithErrors """ diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index f35c3295b6d..0a9cd6c62de 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.NumericLiterals.ComponentTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -module ``Invalid Numeric Literal`` = +module ``Numeric Literlas`` = [] let ``1up is invalid Numeric Literal``() = diff --git a/tests/fsharp/Compiler/ErrorMessages/MissingElseBranch.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs similarity index 93% rename from tests/fsharp/Compiler/ErrorMessages/MissingElseBranch.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs index 370b4c24053..9ab09f8a9ea 100644 --- a/tests/fsharp/Compiler/ErrorMessages/MissingElseBranch.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Else branch is missing`` = - [] + [] let ``Fail if else branch is missing``() = CompilerAssert.TypeCheckSingleError """ @@ -22,7 +21,7 @@ let y = (4, 19, 4, 25) "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." - [] + [] let ``Fail on type error in condition``() = CompilerAssert.TypeCheckSingleError """ @@ -37,7 +36,7 @@ let y = (5, 14, 5, 20) "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " - [] + [] let ``Fail if else branch is missing in nesting``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/MissingExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs similarity index 90% rename from tests/fsharp/Compiler/ErrorMessages/MissingExpressionTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs index b00833e418a..96bfa6c40ae 100644 --- a/tests/fsharp/Compiler/ErrorMessages/MissingExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Missing Expression`` = - [] + [] let ``Missing Expression after let``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/ModuleAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs similarity index 88% rename from tests/fsharp/Compiler/ErrorMessages/ModuleAbbreviationTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs index b67bb8ca8b5..b3c09010e90 100644 --- a/tests/fsharp/Compiler/ErrorMessages/ModuleAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Module Abbreviations`` = - [] + [] let ``Public Module Abbreviation``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs similarity index 81% rename from tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs index 4a94339fe18..418bddcb723 100644 --- a/tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module NameResolutionTests = - [] + [] let FieldNotInRecord () = CompilerAssert.TypeCheckSingleError """ @@ -25,9 +24,9 @@ let r:F = { Size=3; Height=4; Wall=1 } FSharpErrorSeverity.Error 1129 (9, 31, 9, 35) - "The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:\r\n Wallis" + "The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis" - [] + [] let RecordFieldProposal () = CompilerAssert.TypeCheckSingleError """ @@ -43,4 +42,4 @@ let r = { Size=3; Height=4; Wall=1 } FSharpErrorSeverity.Error 39 (9, 29, 9, 33) - "The record label 'Wall' is not defined. Maybe you want one of the following:\r\n Walls\r\n Wallis" + "The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis" diff --git a/tests/fsharp/Compiler/ErrorMessages/SuggestionsTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs similarity index 74% rename from tests/fsharp/Compiler/ErrorMessages/SuggestionsTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs index e6f44d2430f..cf38d4a5745 100644 --- a/tests/fsharp/Compiler/ErrorMessages/SuggestionsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module Suggestions = - [] + [] let ``Field Suggestion`` () = CompilerAssert.TypeCheckSingleError """ @@ -20,10 +19,10 @@ let x = { Person.Names = "Isaac" } FSharpErrorSeverity.Error 39 (4, 18, 4, 23) - "The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:\r\n Name" + "The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name" - [] + [] let ``Suggest Array Module Functions`` () = CompilerAssert.TypeCheckSingleError """ @@ -33,10 +32,10 @@ let f = FSharpErrorSeverity.Error 39 (3, 11, 3, 14) - "The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:\r\n blit" + "The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit" - [] + [] let ``Suggest Async Module`` () = CompilerAssert.TypeCheckSingleError """ @@ -46,10 +45,10 @@ let f = FSharpErrorSeverity.Error 39 (3, 5, 3, 9) - "The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:\r\n Async\r\n async\r\n asin\r\n snd" + "The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd" - [] + [] let ``Suggest Attribute`` () = CompilerAssert.TypeCheckSingleError """ @@ -61,10 +60,10 @@ type MyClass<'Bar>() = FSharpErrorSeverity.Error 39 (2, 3, 2, 15) - "The type 'AbstractClas' is not defined. Maybe you want one of the following:\r\n AbstractClass\r\n AbstractClassAttribute" + "The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute" - [] + [] let ``Suggest Double Backtick Identifiers`` () = CompilerAssert.TypeCheckSingleError """ @@ -76,10 +75,10 @@ let x = N.``longe name`` FSharpErrorSeverity.Error 39 (5, 11, 5, 25) - "The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:\r\n longer name" + "The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name" - [] + [] let ``Suggest Double Backtick Unions`` () = CompilerAssert.TypeCheckSingleError """ @@ -95,10 +94,10 @@ let x = N.MyUnion.``My Case2`` FSharpErrorSeverity.Error 39 (9, 19, 9,31) - "The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:\r\n My Case1\r\n Case2" + "The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2" - [] + [] let ``Suggest Fields In Constructor`` () = CompilerAssert.TypeCheckSingleError """ @@ -112,10 +111,10 @@ let c = MyClass(Property = "") FSharpErrorSeverity.Error 495 (7, 17, 7, 25) - "The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:\r\n MyProperty\r\n MyProperty2\r\n ABigProperty" + "The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty" - [] + [] let ``Suggest Generic Type`` () = CompilerAssert.TypeCheckSingleError """ @@ -124,10 +123,10 @@ type T = System.Collections.Generic.Dictionary FSharpErrorSeverity.Error 39 (2, 48, 2, 53) - "The type 'int11' is not defined. Maybe you want one of the following:\r\n int16\r\n int16`1\r\n int8\r\n uint16\r\n int" + "The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int" - [] + [] let ``Suggest Methods`` () = CompilerAssert.TypeCheckSingleError """ @@ -143,10 +142,10 @@ module Test2 = FSharpErrorSeverity.Error 39 (9, 7, 9, 14) - "The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:\r\n Method1" + "The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1" - [] + [] let ``Suggest Modules`` () = CompilerAssert.TypeCheckSingleError """ @@ -159,10 +158,10 @@ open Collectons FSharpErrorSeverity.Error 39 (6, 6, 6, 16) - "The namespace or module 'Collectons' is not defined. Maybe you want one of the following:\r\n Collections" + "The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections" - [] + [] let ``Suggest Namespaces`` () = CompilerAssert.TypeCheckSingleError """ @@ -174,7 +173,7 @@ open System.Collectons "The namespace 'Collectons' is not defined." - [] + [] let ``Suggest Record Labels`` () = CompilerAssert.TypeCheckSingleError """ @@ -187,10 +186,10 @@ let x = r.ello FSharpErrorSeverity.Error 39 (6, 11, 6, 15) - "The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:\r\n Hello" + "The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello" - [] + [] let ``Suggest Record Type for RequireQualifiedAccess Records`` () = CompilerAssert.TypeCheckSingleError """ @@ -205,10 +204,10 @@ let r = { Field1 = "hallo"; Field2 = 1 } FSharpErrorSeverity.Error 39 (8, 11, 8, 17) - "The record label 'Field1' is not defined. Maybe you want one of the following:\r\n MyRecord.Field1" + "The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1" - [] + [] let ``Suggest To Use Indexer`` () = CompilerAssert.TypeCheckWithErrors """ @@ -227,7 +226,7 @@ let a = (f())[1] |] - [] + [] let ``Suggest Type Parameters`` () = CompilerAssert.TypeCheckSingleError """ @@ -243,7 +242,7 @@ type MyClass<'Bar>() = "The type parameter 'B is not defined." - [] + [] let ``Suggest Types in Module`` () = CompilerAssert.TypeCheckSingleError """ @@ -252,9 +251,9 @@ let x : System.Collections.Generic.Lst = ResizeArray() FSharpErrorSeverity.Error 39 (2, 36, 2, 39) - "The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:\r\n List\r\n IList\r\n List`1" + "The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1" - [] + [] let ``Suggest Types in Namespace`` () = CompilerAssert.TypeCheckSingleError """ @@ -263,10 +262,10 @@ let x = System.DateTie.MaxValue FSharpErrorSeverity.Error 39 (2, 16, 2, 23) - "The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:\r\n DateTime\r\n DateTimeKind\r\n DateTimeOffset\r\n Data" + "The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data" - [] + [] let ``Suggest Union Cases`` () = CompilerAssert.TypeCheckSingleError """ @@ -279,10 +278,10 @@ let u = MyUnion.AntherCase FSharpErrorSeverity.Error 39 (6, 17, 6, 27) - "The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:\r\n AnotherCase" + "The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase" - [] + [] let ``Suggest Union Type for RequireQualifiedAccess Unions`` () = CompilerAssert.TypeCheckSingleError """ @@ -296,10 +295,10 @@ let x : MyUnion = MyCase1 FSharpErrorSeverity.Error 39 (7, 19, 7, 26) - "The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:\r\n MyUnion.MyCase1" + "The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1" - [] + [] let ``Suggest Unions in PatternMatch`` () = CompilerAssert.TypeCheckSingleError """ @@ -318,4 +317,4 @@ let x = FSharpErrorSeverity.Error 39 (11, 15, 11, 19) - "The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:\r\n Case1\r\n Case2" + "The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2" diff --git a/tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs similarity index 86% rename from tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs index 58557c82cd4..424c038746f 100644 --- a/tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Type Mismatch`` = - [] + [] let ``return Instead Of return!``() = CompilerAssert.TypeCheckSingleError """ @@ -20,7 +19,7 @@ let rec foo() = async { return foo() } (2, 32, 2, 37) "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'." - [] + [] let ``yield Instead Of yield!``() = CompilerAssert.TypeCheckSingleError """ @@ -34,7 +33,7 @@ let rec f () = Foo() { yield f ()} (5, 30, 5, 34) "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'." - [] + [] let ``Ref Cell Instead Of Not``() = CompilerAssert.TypeCheckSingleError """ @@ -45,9 +44,9 @@ if !x then FSharpErrorSeverity.Error 1 (3, 5, 3, 6) - "This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' \r\nThe '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + "This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here." - [] + [] let ``Ref Cell Instead Of Not 2``() = CompilerAssert.TypeCheckSingleError """ @@ -57,9 +56,9 @@ let y = !x FSharpErrorSeverity.Error 1 (3, 10, 3, 11) - "This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' \r\nThe '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + "This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here." - [] + [] let ``Guard Has Wrong Type``() = CompilerAssert.TypeCheckWithErrors """ @@ -73,7 +72,7 @@ match x with FSharpErrorSeverity.Warning, 20, (3, 1, 5, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] - [] + [] let ``Runtime Type Test In Pattern``() = CompilerAssert.TypeCheckWithErrors """ @@ -91,7 +90,7 @@ let c = FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" |] - [] + [] let ``Runtime Type Test In Pattern 2``() = CompilerAssert.TypeCheckWithErrors """ @@ -109,7 +108,7 @@ let c = FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" |] - [] + [] let ``Override Errors``() = CompilerAssert.TypeCheckWithErrors """ @@ -130,7 +129,7 @@ type Derived3() = override x.Member (s : string, i : int) = sprintf "Hello %s" s """ [| - FSharpErrorSeverity.Error, 856, (8, 16, 8, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:\r\n abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 856, (12, 16, 12, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:\r\n abstract member Base.Member : int * string -> string" + FSharpErrorSeverity.Error, 856, (8, 16, 8, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" + FSharpErrorSeverity.Error, 856, (12, 16, 12, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" FSharpErrorSeverity.Error, 1, (16, 24, 16, 34), "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " |] diff --git a/tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs similarity index 92% rename from tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs index 3fee1050ef9..99e87293d0f 100644 --- a/tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Unit generic abstract Type`` = - [] + [] let ``Unit can not be used as return type of abstract method paramete on return type``() = CompilerAssert.TypeCheckSingleError """ diff --git a/tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs similarity index 94% rename from tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs index 384164bff22..79e32f9e3e0 100644 --- a/tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] module ``Upcast and Downcast`` = - [] + [] let ``Downcast Instead Of Upcast``() = CompilerAssert.TypeCheckSingleError """ @@ -23,7 +22,7 @@ let c = orig :> Dictionary (5, 9, 5, 36) "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - [] + [] let ``Upcast Instead Of Downcast``() = CompilerAssert.TypeCheckWithErrors """ @@ -37,7 +36,7 @@ let c = orig :?> IDictionary FSharpErrorSeverity.Error, 3198, (5, 9, 5, 38), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator." |] - [] + [] let ``Upcast Function Instead Of Downcast``() = CompilerAssert.TypeCheckWithErrors """ diff --git a/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs similarity index 97% rename from tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 1df40553ce7..37d67a61bda 100644 --- a/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Warn Expression`` = - [] + [] let ``Warn If Expression Result Unused``() = CompilerAssert.TypeCheckSingleError """ @@ -21,7 +21,7 @@ printfn "%d" 3 (2, 1, 2, 6) "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - [] + [] let ``Warn If Possible Assignment``() = CompilerAssert.TypeCheckSingleError """ @@ -37,7 +37,7 @@ let changeX() = (6, 5, 6, 11) "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'." - [] + [] let ``Warn If Possible Assignment To Mutable``() = CompilerAssert.TypeCheckSingleError """ @@ -53,7 +53,7 @@ let changeX() = (6, 5, 6, 11) "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'." - [] + [] let ``Warn If Possible dotnet Property Setter``() = CompilerAssert.TypeCheckWithErrors """ @@ -71,7 +71,7 @@ let changeProperty() = FSharpErrorSeverity.Warning, 20, (8, 5, 8, 21), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'." |] - [] + [] let ``Don't Warn If Property Without Setter``() = CompilerAssert.TypeCheckSingleError """ @@ -90,7 +90,7 @@ let changeProperty() = (9, 5, 9, 23) "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." - [] + [] let ``Warn If Implicitly Discarded``() = CompilerAssert.TypeCheckSingleError """ @@ -106,7 +106,7 @@ let changeX() = (6, 5, 6, 15) "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." - [] + [] let ``Warn If Discarded In List``() = CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:4.6" |] @@ -128,7 +128,7 @@ let view model dispatch = "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'." |] - [] + [] let ``Warn If Discarded In List 2``() = CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:4.6" |] @@ -155,7 +155,7 @@ let view model dispatch = "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'." |] - [] + [] let ``Warn If Discarded In List 3``() = CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:4.6" |] @@ -182,7 +182,7 @@ let view model dispatch = "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] - [] + [] let ``Warn Only On Last Expression``() = CompilerAssert.TypeCheckSingleError """ @@ -197,7 +197,7 @@ while x < 1 do (6, 5, 6, 9) "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - [] + [] let ``Warn If Possible Property Setter``() = CompilerAssert.TypeCheckSingleError """ @@ -218,7 +218,7 @@ let changeProperty() = "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'." - [] + [] let ``Dont warn external function as unused``() = CompilerAssert.Pass """ diff --git a/tests/fsharp/Compiler/ErrorMessages/WrongSyntaxInForLoop.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs similarity index 87% rename from tests/fsharp/Compiler/ErrorMessages/WrongSyntaxInForLoop.fs rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs index 9747bbfa6aa..7f40ae77b5b 100644 --- a/tests/fsharp/Compiler/ErrorMessages/WrongSyntaxInForLoop.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.UnitTests +namespace FSharp.Compiler.ErrorMessages.ComponentTests -open NUnit.Framework +open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices [] module ``Wrong syntax in for loop`` = - [] + [] let ``Equals instead of in``() = CompilerAssert.ParseWithErrors """ From bfebdbe3d022402df3b3f04d23fa9da28b6307f3 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 13:51:48 +0200 Subject: [PATCH 05/12] [WIP] Fix path concatenation in tests --- .../AccessOfTypeAbbreviationTests.fs | 6 ++-- .../ErrorMessages/AssignmentErrorTests.fs | 2 +- .../ErrorMessages/DontSuggestTests.fs | 2 +- .../ElseBranchHasWrongTypeTests.fs | 2 +- .../ErrorMessages/MissingExpressionTests.fs | 2 +- .../ErrorMessages/ModuleAbbreviationTests.fs | 2 +- .../ErrorMessages/NameResolutionTests.fs | 4 +-- .../ErrorMessages/SuggestionsTests.fs | 34 +++++++++---------- .../ErrorMessages/TypeMismatchTests.fs | 4 +-- .../ErrorMessages/UnitGenericAbstactType.fs | 2 +- .../ErrorMessages/WarnExpressionTests.fs | 2 +- .../ErrorMessages/WrongSyntaxInForLoop.fs | 2 +- .../FSharp.Compiler.ComponentTests.fsproj | 15 ++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 15 -------- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs index c2c097affbd..416c62d63f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs @@ -19,7 +19,7 @@ module Library = 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.\r\nAs 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." + ("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.") [] let ``Internal type passes when abbrev is internal``() = @@ -41,7 +41,7 @@ module Library = 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.\r\nAs 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." + ("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.") [] let ``Private type produces warning when abbrev is internal``() = @@ -54,7 +54,7 @@ module Library = 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.\r\nAs 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." + ("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.") [] let ``Private type passes when abbrev is private``() = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs index 9d3254dac09..f2f598d9dba 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Errors assigning to mutable objects`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs index 09f68ae1de1..13a6f6b0dcc 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs @@ -17,7 +17,7 @@ let _ = Path.GetFullPath "images" FSharpErrorSeverity.Error 39 (2, 9, 2, 13) - "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math" + ("The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") [] let ``Dont Suggest When Things Are Open``() = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs index 188244489a2..54d5c41a68c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Else branch has wrong type`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs index 96bfa6c40ae..802bcfd6750 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Missing Expression`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs index b3c09010e90..5c9647fb070 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Module Abbreviations`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs index 418bddcb723..c48a5c9113b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs @@ -24,7 +24,7 @@ let r:F = { Size=3; Height=4; Wall=1 } FSharpErrorSeverity.Error 1129 (9, 31, 9, 35) - "The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis" + ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis") [] let RecordFieldProposal () = @@ -42,4 +42,4 @@ let r = { Size=3; Height=4; Wall=1 } FSharpErrorSeverity.Error 39 (9, 29, 9, 33) - "The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis" + ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs index cf38d4a5745..bf26f8a2102 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs @@ -19,7 +19,7 @@ let x = { Person.Names = "Isaac" } FSharpErrorSeverity.Error 39 (4, 18, 4, 23) - "The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name" + ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name") [] @@ -32,7 +32,7 @@ let f = FSharpErrorSeverity.Error 39 (3, 11, 3, 14) - "The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit" + ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit") [] @@ -45,7 +45,7 @@ let f = FSharpErrorSeverity.Error 39 (3, 5, 3, 9) - "The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd" + ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd") [] @@ -60,7 +60,7 @@ type MyClass<'Bar>() = FSharpErrorSeverity.Error 39 (2, 3, 2, 15) - "The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute" + ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute") [] @@ -75,7 +75,7 @@ let x = N.``longe name`` FSharpErrorSeverity.Error 39 (5, 11, 5, 25) - "The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name" + ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name") [] @@ -94,7 +94,7 @@ let x = N.MyUnion.``My Case2`` FSharpErrorSeverity.Error 39 (9, 19, 9,31) - "The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2" + ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2") [] @@ -111,7 +111,7 @@ let c = MyClass(Property = "") FSharpErrorSeverity.Error 495 (7, 17, 7, 25) - "The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty" + ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty") [] @@ -123,7 +123,7 @@ type T = System.Collections.Generic.Dictionary FSharpErrorSeverity.Error 39 (2, 48, 2, 53) - "The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int" + ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int") [] @@ -142,7 +142,7 @@ module Test2 = FSharpErrorSeverity.Error 39 (9, 7, 9, 14) - "The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1" + ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1") [] @@ -158,7 +158,7 @@ open Collectons FSharpErrorSeverity.Error 39 (6, 6, 6, 16) - "The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections" + ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections") [] @@ -186,7 +186,7 @@ let x = r.ello FSharpErrorSeverity.Error 39 (6, 11, 6, 15) - "The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello" + ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello") [] @@ -204,7 +204,7 @@ let r = { Field1 = "hallo"; Field2 = 1 } FSharpErrorSeverity.Error 39 (8, 11, 8, 17) - "The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1" + ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1") [] @@ -251,7 +251,7 @@ let x : System.Collections.Generic.Lst = ResizeArray() FSharpErrorSeverity.Error 39 (2, 36, 2, 39) - "The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1" + ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1") [] let ``Suggest Types in Namespace`` () = @@ -262,7 +262,7 @@ let x = System.DateTie.MaxValue FSharpErrorSeverity.Error 39 (2, 16, 2, 23) - "The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data" + ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data") [] @@ -278,7 +278,7 @@ let u = MyUnion.AntherCase FSharpErrorSeverity.Error 39 (6, 17, 6, 27) - "The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase" + ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase") [] @@ -295,7 +295,7 @@ let x : MyUnion = MyCase1 FSharpErrorSeverity.Error 39 (7, 19, 7, 26) - "The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1" + ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1") [] @@ -317,4 +317,4 @@ let x = FSharpErrorSeverity.Error 39 (11, 15, 11, 19) - "The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2" + ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs index 424c038746f..817e0a588c6 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs @@ -44,7 +44,7 @@ if !x then FSharpErrorSeverity.Error 1 (3, 5, 3, 6) - "This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") [] let ``Ref Cell Instead Of Not 2``() = @@ -56,7 +56,7 @@ let y = !x FSharpErrorSeverity.Error 1 (3, 10, 3, 11) - "This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") [] let ``Guard Has Wrong Type``() = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs index 99e87293d0f..11ec30ab19a 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Unit generic abstract Type`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 37d67a61bda..565e423407b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Warn Expression`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs index 7f40ae77b5b..d7cd6068103 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -[] + module ``Wrong syntax in for loop`` = [] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 136a8d8f1f6..5cdb7b389d3 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -18,8 +18,23 @@ + + + + + + + + + + + + + + + diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index bcd8ee8ba34..2a7adae3d19 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -33,23 +33,8 @@ - - - - - - - - - - - - - - - From 8ed3c3410ff5b850735aae91c2ab2551a5b7f076 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 16:14:16 +0200 Subject: [PATCH 06/12] Consolidate ErrorMessages compiler tests under component tests suite --- .../ErrorMessages/ConfusingTypeName.fs | 67 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + tests/FSharp.Test.Utilities/CompilerAssert.fs | 5 +- tests/FSharp.Test.Utilities/Utilities.fs | 7 +- .../ErrorMessages/ConfusingTypeName/app.fs | 22 ------ .../ConfusingTypeName/compile.bat | 6 -- .../ErrorMessages/ConfusingTypeName/env.lst | 3 - .../ConfusingTypeName/liba-and-b.cs | 2 - .../ErrorMessages/ConfusingTypeName/libc.fs | 3 - .../ErrorMessages/ConfusingTypeName/libd.fs | 3 - tests/fsharpqa/Source/test.lst | 1 - 11 files changed, 77 insertions(+), 43 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/app.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/compile.bat delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/env.lst delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/liba-and-b.cs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libc.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libd.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs new file mode 100644 index 00000000000..2406419132c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -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`` = + + [] + let ``Checks expected types with multiple references``() = + let csLibAB = """ +public class A { } +public class B { } + """ + 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() +let otherB = OtherAMaker.makeOtherB() +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" + System.Environment.NewLine + " 'A (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " '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" + System.Environment.NewLine + " 'B (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " 'B (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) + |], true) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 5cdb7b389d3..ebe0c3d37d8 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -35,6 +35,7 @@ + diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 42296116616..ea8c3d2f549 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -283,7 +283,10 @@ let main argv = 0""" | CompilationReference (cmpl, staticLink) -> compileCompilationAux outputPath disposals ignoreWarnings cmpl, staticLink | TestCompilationReference (cmpl) -> - let tmp = Path.Combine(outputPath, Path.ChangeExtension(Path.GetRandomFileName(), ".dll")) + let filename = match cmpl with + | TestCompilation.CSharp c -> c.AssemblyName + | _ -> Path.GetRandomFileName() + let tmp = Path.Combine(outputPath, Path.ChangeExtension(filename, ".dll")) disposals.Add({ new IDisposable with member _.Dispose() = try File.Delete tmp with | _ -> () }) diff --git a/tests/FSharp.Test.Utilities/Utilities.fs b/tests/FSharp.Test.Utilities/Utilities.fs index f55d1936b5c..1415fee273f 100644 --- a/tests/FSharp.Test.Utilities/Utilities.fs +++ b/tests/FSharp.Test.Utilities/Utilities.fs @@ -60,6 +60,8 @@ module Utilities = | None = 0x0 | InternalsVisibleTo = 0x1 + // TODO: this and Compilation.Compile needs to be merged for sake of consistency. + // TODO: After merging, add new type of FSharp compilation. [] type TestCompilation = | CSharp of CSharpCompilation @@ -96,18 +98,19 @@ module Utilities = [] type CompilationUtil private () = - static member CreateCSharpCompilation (source: string, lv: CSharpLanguageVersion, ?tf, ?additionalReferences) = + static member CreateCSharpCompilation (source: string, lv: CSharpLanguageVersion, ?tf, ?additionalReferences, ?name) = let lv = match lv with | CSharpLanguageVersion.CSharp8 -> LanguageVersion.CSharp8 | _ -> LanguageVersion.Default let tf = defaultArg tf TargetFramework.NetStandard20 + let n = defaultArg name (Guid.NewGuid().ToString ()) let additionalReferences = defaultArg additionalReferences ImmutableArray.Empty let references = TargetFrameworkUtil.getReferences tf let c = CSharpCompilation.Create( - Guid.NewGuid().ToString (), + n, [ CSharpSyntaxTree.ParseText (source, CSharpParseOptions lv) ], references.As().AddRange additionalReferences, CSharpCompilationOptions (OutputKind.DynamicallyLinkedLibrary)) diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/app.fs b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/app.fs deleted file mode 100644 index 130c63a7d55..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/app.fs +++ /dev/null @@ -1,22 +0,0 @@ -//This expression was expected to have type -//'A (liba, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' -//but here has type -//'A (libb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' - - -//This expression was expected to have type -//'B (liba, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' -//but here has type -//'B (libb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' - - -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() -let otherB = OtherAMaker.makeOtherB() -printfn "%A %A" (b.GetType().AssemblyQualifiedName) (otherB.GetType().AssemblyQualifiedName) -printfn "%A" (b = otherB) - \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/compile.bat b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/compile.bat deleted file mode 100644 index abcfa42e592..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/compile.bat +++ /dev/null @@ -1,6 +0,0 @@ -rem if you want to try it out without running the whole suite -csc -t:library -out:liba.dll liba-and-b.cs -csc -t:library -out:libb.dll liba-and-b.cs -fsc --target:library -r:liba.dll --out:libc.dll libc.fs -fsc --target:library -r:libb.dll --out:libd.dll libd.fs -fsc -r:liba.dll -r:libb.dll -r:libc.dll -r:libd.dll app.fs diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/env.lst b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/env.lst deleted file mode 100644 index 8189ed0b1f8..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/env.lst +++ /dev/null @@ -1,3 +0,0 @@ -# see compile.bat for clearer steps, aim is to get message highlighting fix for https://github.com/Microsoft/visualfsharp/issues/2561 - SOURCE="app.fs" SCFLAGS="-r:liba.dll -r:libb.dll -r:libc.dll -r:libd.dll" PRECMD="\$CSC_PIPE -t:library -out:liba.dll liba-and-b.cs && \$CSC_PIPE -t:library -out:libb.dll liba-and-b.cs && fsc --target:library -r:liba.dll --out:libc.dll libc.fs && fsc --target:library -r:libb.dll --out:libd.dll libd.fs" - \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/liba-and-b.cs b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/liba-and-b.cs deleted file mode 100644 index 9e1d2d24b31..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/liba-and-b.cs +++ /dev/null @@ -1,2 +0,0 @@ -public class A { } -public class B { } \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libc.fs b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libc.fs deleted file mode 100644 index 4e1450a4149..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libc.fs +++ /dev/null @@ -1,3 +0,0 @@ -module AMaker -let makeA () : A = A() -let makeB () = B<_>() diff --git a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libd.fs b/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libd.fs deleted file mode 100644 index 5458451d7cb..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/ConfusingTypeName/libd.fs +++ /dev/null @@ -1,3 +0,0 @@ -module OtherAMaker -let makeOtherA () : A = A() -let makeOtherB () = B<_>() \ No newline at end of file diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index 8a3aeac76b2..9f0781dafaa 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -267,7 +267,6 @@ Misc01 Libraries\Core\Reflection Misc01 Libraries\Core\Unchecked Misc01 Warnings Misc01 ErrorMessages\UnitGenericAbstractType -Misc01 ErrorMessages\ConfusingTypeName Misc02 Libraries\Portable Misc02 Misc From cbcfdf61237e6f64ac87421d1a3510718fd0ec8a Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 16:37:52 +0200 Subject: [PATCH 07/12] Fixed warning with ms.net.test.sdk --- tests/Directory.Build.targets | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 77272699622..1108759d4a2 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -3,13 +3,11 @@ - - From 17b375b091c1bb6c6e79bafd4efd43f7bc096d06 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 16:56:30 +0200 Subject: [PATCH 08/12] Fixed indentation --- tests/FSharp.Test.Utilities/CompilerAssert.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index ea8c3d2f549..ac75e88ee9a 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -283,9 +283,10 @@ let main argv = 0""" | CompilationReference (cmpl, staticLink) -> compileCompilationAux outputPath disposals ignoreWarnings cmpl, staticLink | TestCompilationReference (cmpl) -> - let filename = match cmpl with - | TestCompilation.CSharp c -> c.AssemblyName - | _ -> Path.GetRandomFileName() + let filename = + match cmpl with + | TestCompilation.CSharp c -> c.AssemblyName + | _ -> Path.GetRandomFileName() let tmp = Path.Combine(outputPath, Path.ChangeExtension(filename, ".dll")) disposals.Add({ new IDisposable with member _.Dispose() = From 92bc463d2fc5c4cdbd640a63a0f5b21fe99215ea Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 17:36:14 +0200 Subject: [PATCH 09/12] Removed unnecessary references to fsc/fsi from test utilities. --- .../ErrorMessages/ConfusingTypeName.fs | 4 ++-- tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs index 2406419132c..b930eff346a 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -62,6 +62,6 @@ printfn "%A" (b = otherB) CompilerAssert.CompileWithErrors( appCmpl, [| - (FSharpErrorSeverity.Error, 1, (6, 19, 6, 25), ("This expression was expected to have type" + System.Environment.NewLine + " 'A (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " '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" + System.Environment.NewLine + " 'B (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " 'B (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) + (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)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " '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 (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " 'B (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) |], true) diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index 674d5d4bbf2..5ddfa74eb83 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -30,8 +30,6 @@ - - From 4470387af7573706c9c3d29d9928aed5d73f9dc5 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 22 Jun 2020 18:04:32 +0200 Subject: [PATCH 10/12] Fix newlines in the assertion --- .../ErrorMessages/ConfusingTypeName.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs index b930eff346a..b67a75ec601 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -62,6 +62,6 @@ printfn "%A" (b = otherB) 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)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " '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 (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' " + System.Environment.NewLine + "but here has type" + System.Environment.NewLine + " 'B (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) + (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 (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' \nbut here has type\n 'B (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' ")) |], true) From cc35c92fd7f931c21175eed32c9eb91618ed6748 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 23 Jun 2020 10:35:22 +0200 Subject: [PATCH 11/12] Update tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs Co-authored-by: Thorsten Reichert --- .../ErrorMessages/InvalidNumericLiteralTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 0a9cd6c62de..a20dd899762 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -6,7 +6,7 @@ open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices -module ``Numeric Literlas`` = +module ``Numeric Literals`` = [] let ``1up is invalid Numeric Literal``() = From 5c45e9bb3a15272272fedc53a9746c6635a724fe Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 23 Jun 2020 10:47:29 +0200 Subject: [PATCH 12/12] Cleaned up test list; Make RIDs conditional as well --- .../FSharp.Compiler.ComponentTests.fsproj | 3 ++- tests/fsharpqa/Source/test.lst | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index ebe0c3d37d8..e78ad8e7725 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -4,8 +4,9 @@ net472;netcoreapp3.1 - netcoreapp3.1 win-x86;win-x64;linux-x64;osx-x64 + netcoreapp3.1 + linux-x64;osx-x64 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 true Library diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index 9f0781dafaa..95afc5893b4 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -266,7 +266,6 @@ Misc01 Libraries\Core\Operators Misc01 Libraries\Core\Reflection Misc01 Libraries\Core\Unchecked Misc01 Warnings -Misc01 ErrorMessages\UnitGenericAbstractType Misc02 Libraries\Portable Misc02 Misc