Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate suggestions in unit tests and move some tests #7251

Merged
merged 10 commits into from
Aug 2, 2019
Merged
20 changes: 10 additions & 10 deletions tests/fsharp/Compiler/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ILVerifier (dllFilePath: string) =
[<RequireQualifiedAccess>]
module CompilerAssert =

let checker = FSharpChecker.Create()
let checker = FSharpChecker.Create(suggestNamesForErrors=true)

let private config = TestFramework.initializeSuite ()

Expand Down Expand Up @@ -110,7 +110,7 @@ let main argv = 0"""
#if !NETCOREAPP
OtherOptions = [|"--preferreduilang:en-US";|]
#else
OtherOptions =
OtherOptions =
let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x)
Array.append [|"--preferreduilang:en-US"; "--targetprofile:netcore"; "--noframework"|] assemblies
#endif
Expand Down Expand Up @@ -175,12 +175,12 @@ let main argv = 0"""

let TypeCheckWithErrorsAndOptions options (source: string) expectedTypeErrors =
lock gate <| fun () ->
let parseResults, fileAnswer =
let parseResults, fileAnswer =
checker.ParseAndCheckFileInProject(
"test.fs",
0,
SourceText.ofString source,
{ defaultProjectOptions with OtherOptions = Array.append options defaultProjectOptions.OtherOptions})
{ defaultProjectOptions with OtherOptions = Array.append options defaultProjectOptions.OtherOptions})
|> Async.RunSynchronously

Assert.IsEmpty(parseResults.Errors, sprintf "Parse errors: %A" parseResults.Errors)
Expand All @@ -189,7 +189,7 @@ let main argv = 0"""
| FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted")
| FSharpCheckFileAnswer.Succeeded(typeCheckResults) ->

let errors =
let errors =
typeCheckResults.Errors
|> Array.distinctBy (fun e -> e.Severity, e.ErrorNumber, e.StartLineAlternate, e.StartColumn, e.EndLineAlternate, e.EndColumn, e.Message)

Expand Down Expand Up @@ -234,7 +234,7 @@ let main argv = 0"""

pInfo.RedirectStandardError <- true
pInfo.UseShellExecute <- false

let p = Process.Start(pInfo)

p.WaitForExit()
Expand All @@ -247,13 +247,13 @@ let main argv = 0"""
)

let CompileLibraryAndVerifyIL (source: string) (f: ILVerifier -> unit) =
compile false source (fun (errors, outputFilePath) ->
compile false source (fun (errors, outputFilePath) ->
if errors.Length > 0 then
Assert.Fail (sprintf "Compile had warnings and/or errors: %A" errors)

f (ILVerifier outputFilePath)
)

let RunScript (source: string) (expectedErrorMessages: string list) =
lock gate <| fun () ->
// Intialize output and input streams
Expand All @@ -271,7 +271,7 @@ let main argv = 0"""

let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
use fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream, collectible = true)

let ch, errors = fsiSession.EvalInteractionNonThrowing source

let errorMessages = ResizeArray()
Expand All @@ -297,7 +297,7 @@ let main argv = 0"""

Assert.True(parseResults.ParseHadErrors)

let errors =
let errors =
parseResults.Errors
|> Array.distinctBy (fun e -> e.Severity, e.ErrorNumber, e.StartLineAlternate, e.StartColumn, e.EndLineAlternate, e.EndColumn, e.Message)

Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/Compiler/ErrorMessages/ClassesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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."
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, 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, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member"
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let p =
Age = 18)
"""
[|
FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined."
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.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 (',')."
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/Compiler/ErrorMessages/DontSuggestTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
"The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:\r\n Math"

[<Test>]
let ``Dont Suggest When Things Are Open``() =
Expand Down
10 changes: 5 additions & 5 deletions tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ open NUnit.Framework
open FSharp.Compiler.SourceCodeServices

[<TestFixture>]
module NameResolutionTests =
module NameResolutionTests =

[<Test>]
let FieldNotInRecord () =
CompilerAssert.TypeCheckSingleError
Expand All @@ -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'."
"The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:\r\n Wallis"

[<Test>]
let RecordFieldProposal () =
Expand All @@ -36,10 +36,10 @@ type C = { Wheels:int }
type D = { Size:int; Height:int; Walls:int }
type E = { Unknown:string }
type F = { Wallis:int; Size:int; Height:int; }

let r = { Size=3; Height=4; Wall=1 }
"""
FSharpErrorSeverity.Error
39
(9, 29, 9, 33)
"The record label 'Wall' is not defined."
"The record label 'Wall' is not defined. Maybe you want one of the following:\r\n Walls\r\n Wallis"
Loading