Skip to content

Commit

Permalink
Move existing Compiler.ComponentTests to a new Compiler.fs framework (d…
Browse files Browse the repository at this point in the history
…otnet#9839)

* Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function

* Changed some wording in error messages
  • Loading branch information
vzarytovskii authored and nosami committed Feb 22, 2021
1 parent bd33972 commit e3e5ba5
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 282 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ErrorMessages.ComponentTests
namespace FSharp.Compiler.ComponentTests.ErrorMessages

open Xunit
open FSharp.Test.Utilities
open FSharp.Test.Utilities.Compiler
open FSharp.Test.Utilities.Utilities
open FSharp.Compiler.SourceCodeServices

module ``Confusing Type Name`` =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ doSomething {Record.field1=0; field2=0}
|> typecheck
|> shouldFail
|> withDiagnostics [
(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' ")
(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'.")]
(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'.")
(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' ")]

[<Fact>]
let ``Comma In Rec Ctor``() =
Expand Down Expand Up @@ -46,8 +46,8 @@ let p =
|> typecheck
|> shouldFail
|> withDiagnostics [
(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")
(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'.")
(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")
(Error 39, Line 8, Col 12, Line 8, Col 15, "The value or constructor 'Age' is not defined.")
(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 (',').")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ else
|> typecheck
|> shouldFail
|> withDiagnostics [
(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'.")
(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'.")
(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'.")
(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'.")]
(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'.")]
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ match x with
|> typecheck
|> shouldFail
|> withDiagnostics [
(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'.")
(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'.")]
(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'.")
(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'.")]

[<Fact>]
let ``Runtime Type Test In Pattern``() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ let view model dispatch =
div [] []
]
"""
|> withLangVersion46
|> withOptions ["--langversion:4.6"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 3221, Line 9, Col 8, Line 9, Col 17,
Expand All @@ -137,7 +137,7 @@ let view model dispatch =
]
]
"""
|> withLangVersion46
|> withOptions ["--langversion:4.6"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 3222, Line 13, Col 19, Line 13, Col 41,
Expand All @@ -161,7 +161,7 @@ let view model dispatch =
]
]
"""
|> withLangVersion46
|> withOptions ["--langversion:4.6"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 20, Line 13, Col 19, Line 13, Col 41,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.Interop.ComponentTests
namespace FSharp.Compiler.ComponentTests.Interop

open Xunit
open FSharp.Test.Utilities
open FSharp.Test.Utilities.Compiler

module ``C# <-> F# basic interop`` =
Expand Down
Loading

0 comments on commit e3e5ba5

Please sign in to comment.