Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit e3e5ba5

Browse files
vzarytovskiinosami
authored andcommitted
Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839)
* Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages
1 parent bd33972 commit e3e5ba5

File tree

8 files changed

+97
-282
lines changed

8 files changed

+97
-282
lines changed

tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

3-
namespace FSharp.Compiler.ErrorMessages.ComponentTests
3+
namespace FSharp.Compiler.ComponentTests.ErrorMessages
44

55
open Xunit
6-
open FSharp.Test.Utilities
76
open FSharp.Test.Utilities.Compiler
8-
open FSharp.Test.Utilities.Utilities
9-
open FSharp.Compiler.SourceCodeServices
107

118
module ``Confusing Type Name`` =
129

tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ doSomething {Record.field1=0; field2=0}
1717
|> typecheck
1818
|> shouldFail
1919
|> withDiagnostics [
20-
(Error 1, Line 4, Col 13, Line 4, Col 40, "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' ")
21-
(Warning 20, Line 4, Col 1, Line 4, Col 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'.")]
20+
(Warning 20, Line 4, Col 1, Line 4, Col 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'.")
21+
(Error 1, Line 4, Col 13, Line 4, Col 40, "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' ")]
2222

2323
[<Fact>]
2424
let ``Comma In Rec Ctor``() =
@@ -46,8 +46,8 @@ let p =
4646
|> typecheck
4747
|> shouldFail
4848
|> withDiagnostics [
49-
(Error 39, Line 7, Col 12, Line 7, Col 16, "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan")
5049
(Warning 20, Line 7, Col 12, Line 7, Col 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'.")
50+
(Error 39, Line 7, Col 12, Line 7, Col 16, "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan")
5151
(Error 39, Line 8, Col 12, Line 8, Col 15, "The value or constructor 'Age' is not defined.")
5252
(Error 501, Line 7, Col 5, Line 8, Col 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 (',').")]
5353

tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,6 @@ else
166166
|> typecheck
167167
|> shouldFail
168168
|> withDiagnostics [
169+
(Warning 20, Line 3, Col 1, Line 6, Col 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'.")
169170
(Error 1, Line 5, Col 19, Line 5, Col 22, "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'.")
170-
(Error 1, Line 6, Col 10, Line 6, Col 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'.")
171-
(Warning 20, Line 3, Col 1, Line 6, Col 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'.")]
171+
(Error 1, Line 6, Col 10, Line 6, Col 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'.")]

tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ match x with
6464
|> typecheck
6565
|> shouldFail
6666
|> withDiagnostics [
67-
(Error 1, Line 4, Col 10, Line 4, Col 13, "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'.")
68-
(Warning 20, Line 3, Col 1, Line 5, Col 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'.")]
67+
(Warning 20, Line 3, Col 1, Line 5, Col 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'.")
68+
(Error 1, Line 4, Col 10, Line 4, Col 13, "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'.")]
6969

7070
[<Fact>]
7171
let ``Runtime Type Test In Pattern``() =

tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ let view model dispatch =
113113
div [] []
114114
]
115115
"""
116-
|> withLangVersion46
116+
|> withOptions ["--langversion:4.6"]
117117
|> typecheck
118118
|> shouldFail
119119
|> withSingleDiagnostic (Warning 3221, Line 9, Col 8, Line 9, Col 17,
@@ -137,7 +137,7 @@ let view model dispatch =
137137
]
138138
]
139139
"""
140-
|> withLangVersion46
140+
|> withOptions ["--langversion:4.6"]
141141
|> typecheck
142142
|> shouldFail
143143
|> withSingleDiagnostic (Warning 3222, Line 13, Col 19, Line 13, Col 41,
@@ -161,7 +161,7 @@ let view model dispatch =
161161
]
162162
]
163163
"""
164-
|> withLangVersion46
164+
|> withOptions ["--langversion:4.6"]
165165
|> typecheck
166166
|> shouldFail
167167
|> withSingleDiagnostic (Warning 20, Line 13, Col 19, Line 13, Col 41,

tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

3-
namespace FSharp.Compiler.Interop.ComponentTests
3+
namespace FSharp.Compiler.ComponentTests.Interop
44

55
open Xunit
6-
open FSharp.Test.Utilities
76
open FSharp.Test.Utilities.Compiler
87

98
module ``C# <-> F# basic interop`` =

0 commit comments

Comments
 (0)