diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets
index 6df5fdfa9c7..1108759d4a2 100644
--- a/tests/Directory.Build.targets
+++ b/tests/Directory.Build.targets
@@ -3,13 +3,11 @@
-
-
diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs
new file mode 100644
index 00000000000..416c62d63f6
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs
@@ -0,0 +1,75 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace FSharp.Compiler.ErrorMessages.ComponentTests
+
+open Xunit
+open FSharp.Test.Utilities
+open FSharp.Compiler.SourceCodeServices
+
+module ``Access Of Type Abbreviation`` =
+
+ []
+ let ``Private type produces warning when trying to export``() =
+ CompilerAssert.TypeCheckSingleError
+ """
+module Library =
+ type private Hidden = Hidden of unit
+ type Exported = Hidden
+ """
+ FSharpErrorSeverity.Warning
+ 44
+ (4, 8, 4, 16)
+ ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
+
+ []
+ let ``Internal type passes when abbrev is internal``() =
+ CompilerAssert.Pass
+ """
+module Library =
+ type internal Hidden = Hidden of unit
+ type internal Exported = Hidden
+ """
+
+ []
+ let ``Internal type produces warning when trying to export``() =
+ CompilerAssert.TypeCheckSingleError
+ """
+module Library =
+ type internal Hidden = Hidden of unit
+ type Exported = Hidden
+ """
+ FSharpErrorSeverity.Warning
+ 44
+ (4, 8, 4, 16)
+ ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
+
+ []
+ let ``Private type produces warning when abbrev is internal``() =
+ CompilerAssert.TypeCheckSingleError
+ """
+module Library =
+ type private Hidden = Hidden of unit
+ type internal Exported = Hidden
+ """
+ FSharpErrorSeverity.Warning
+ 44
+ (4, 17, 4, 25)
+ ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
+
+ []
+ let ``Private type passes when abbrev is private``() =
+ CompilerAssert.Pass
+ """
+module Library =
+ type private Hidden = Hidden of unit
+ type private Exported = Hidden
+ """
+
+ []
+ let ``Default access type passes when abbrev is default``() =
+ CompilerAssert.Pass
+ """
+module Library =
+ type Hidden = Hidden of unit
+ type Exported = Hidden
+ """
diff --git a/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs
similarity index 86%
rename from tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs
index c1226c4ff93..f2f598d9dba 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/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs
new file mode 100644
index 00000000000..b67a75ec601
--- /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\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)
diff --git a/tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs
similarity index 88%
rename from tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs
index be7e5823391..c9636e711a5 100644
--- a/tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs
+++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs
@@ -1,29 +1,27 @@
// 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 ``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}
"""
[|
- 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'."
|]
- []
+ []
let ``Comma In Rec Ctor``() =
CompilerAssert.TypeCheckWithErrors
"""
@@ -31,11 +29,11 @@ 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'"
|]
- []
+ []
let ``Missing Comma In Ctor``() =
CompilerAssert.TypeCheckWithErrors
"""
@@ -48,13 +46,13 @@ 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 (',')."
|]
- []
+ []
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/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs
similarity index 84%
rename from tests/fsharp/Compiler/ErrorMessages/DontSuggestTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs
index f7b3cc2cb05..13a6f6b0dcc 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..54d5c41a68c 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 c6631ab629e..a20dd899762 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.ComponentTests
+namespace FSharp.Compiler.ErrorMessages.ComponentTests
open Xunit
open FSharp.Test.Utilities
open FSharp.Compiler.SourceCodeServices
-module ``Invalid Numeric Literal`` =
+module ``Numeric Literals`` =
[]
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 89%
rename from tests/fsharp/Compiler/ErrorMessages/MissingExpressionTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs
index b00833e418a..802bcfd6750 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 87%
rename from tests/fsharp/Compiler/ErrorMessages/ModuleAbbreviationTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs
index b67bb8ca8b5..5c9647fb070 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 72%
rename from tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs
index 4a94339fe18..c48a5c9113b 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 62%
rename from tests/fsharp/Compiler/ErrorMessages/SuggestionsTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs
index e6f44d2430f..bf26f8a2102 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 84%
rename from tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs
index 58557c82cd4..817e0a588c6 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 91%
rename from tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs
index 3fee1050ef9..11ec30ab19a 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..565e423407b 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 86%
rename from tests/fsharp/Compiler/ErrorMessages/WrongSyntaxInForLoop.fs
rename to tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs
index 9747bbfa6aa..d7cd6068103 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
"""
diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
index 6f9172bf9bc..e78ad8e7725 100644
--- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
+++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
@@ -4,7 +4,10 @@
net472;netcoreapp3.1
+ win-x86;win-x64;linux-x64;osx-x64
netcoreapp3.1
+ linux-x64;osx-x64
+ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81
true
Library
true
@@ -16,7 +19,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs
index 42296116616..ac75e88ee9a 100644
--- a/tests/FSharp.Test.Utilities/CompilerAssert.fs
+++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs
@@ -283,7 +283,11 @@ 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/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
index 8553d2cfd44..5ddfa74eb83 100644
--- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
+++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
@@ -25,8 +25,12 @@
-
+
+
+
+
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/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs
deleted file mode 100644
index f6fc14bbef5..00000000000
--- a/tests/fsharp/Compiler/ErrorMessages/AccessOfTypeAbbreviationTests.fs
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
-
-namespace FSharp.Compiler.UnitTests
-
-open NUnit.Framework
-open FSharp.Test.Utilities
-open FSharp.Compiler.SourceCodeServices
-
-[]
-module ``Access Of Type Abbreviation`` =
-
- []
- let ``Test1``() =
- CompilerAssert.TypeCheckSingleError
- """
-module Library =
- type private Hidden = Hidden of unit
- type Exported = Hidden
- """
- FSharpErrorSeverity.Warning
- 44
- (4, 8, 4, 16)
- "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in.\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``() =
- CompilerAssert.Pass
- """
-module Library =
- type internal Hidden = Hidden of unit
- type internal Exported = Hidden
- """
-
- []
- let ``Test3``() =
- CompilerAssert.TypeCheckSingleError
- """
-module Library =
- type internal Hidden = Hidden of unit
- type Exported = Hidden
- """
- FSharpErrorSeverity.Warning
- 44
- (4, 8, 4, 16)
- "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in.\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``() =
- CompilerAssert.TypeCheckSingleError
- """
-module Library =
- type private Hidden = Hidden of unit
- type internal Exported = Hidden
- """
- FSharpErrorSeverity.Warning
- 44
- (4, 17, 4, 25)
- "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in.\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``() =
- CompilerAssert.Pass
- """
-module Library =
- type private Hidden = Hidden of unit
- type private Exported = Hidden
- """
-
- []
- let ``Test6``() =
- CompilerAssert.Pass
- """
-module Library =
- type Hidden = Hidden of unit
- type Exported = Hidden
- """
diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj
index 91f242d059c..2a7adae3d19 100644
--- a/tests/fsharp/FSharpSuite.Tests.fsproj
+++ b/tests/fsharp/FSharpSuite.Tests.fsproj
@@ -33,24 +33,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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..95afc5893b4 100644
--- a/tests/fsharpqa/Source/test.lst
+++ b/tests/fsharpqa/Source/test.lst
@@ -266,8 +266,6 @@ Misc01 Libraries\Core\Operators
Misc01 Libraries\Core\Reflection
Misc01 Libraries\Core\Unchecked
Misc01 Warnings
-Misc01 ErrorMessages\UnitGenericAbstractType
-Misc01 ErrorMessages\ConfusingTypeName
Misc02 Libraries\Portable
Misc02 Misc