From 5a04fd4874bb1b54580887c3cc267d52d5d363fa Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 10 Jan 2023 09:15:09 +0100 Subject: [PATCH 01/19] Porting selected fsharpsuite tests to ComponentTests without fsc.exe/ dotnet.exe process invocations --- .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../Miscellaneous/FsharpSuiteMigrated.fs | 536 ++++++++++++++++++ tests/FSharp.Test.Utilities/Compiler.fs | 41 +- tests/FSharp.Test.Utilities/ScriptHelpers.fs | 11 +- tests/fsharp/core/members/ops/test.fsx | 2 +- 5 files changed, 581 insertions(+), 10 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 3a00acd4d02..e3273406110 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -209,6 +209,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs new file mode 100644 index 00000000000..a8cf091283b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -0,0 +1,536 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +module FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated + +open System +open System.IO +open Xunit +open FSharp.Test +open FSharp.Test.Compiler +open FSharp.Test.ScriptHelpers + +module RunnerEngine = + open Internal.Utilities.Library + let private createEngine(args,version) = + let s = getSessionForEval args version + s.Eval """let exit no = if no=0 then 0 else failwith $"Error in running, exit code={no}" """ |> ignore + s + let getOrCreateEngine = Tables.memoize createEngine + + let private definesForExe = + [ "TESTS_AS_APP" +#if NETCOREAPP + "NETCOREAPP" +#endif + ] + + let runExe = + asFs >> withDefines definesForExe >> compileExeAndRun + + let runScriptFile version (cu:CompilationUnit) = + match cu with + | FS fsSource -> + File.Delete("test.ok") + let engine = getOrCreateEngine (fsSource.Options |> Array.ofList,version) + let res = evalScriptFromDiskInSharedSession engine cu + match res with + | CompilationResult.Failure _ -> res + | CompilationResult.Success s -> + if File.Exists("test.ok") then + res + else + failwith $"Results looked correct, but 'test.ok' file was not created. Result: %A{s}" + + | _ -> failwith $"Compilation unit other than fsharp is not supported, cannot process %A{cu}" + + +/// This test file was created by porting over (slower) FsharpSuite.Tests +/// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions +module TestFrameworkAdapter = + type ExecutionMode = FSC_DEBUG | FSC_OPTIMIZED | FSI + let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath + let inline testConfig (relativeFolder:string) = relativeFolder + + let adjustVersion version bonusArgs = + match version with + | LangVersion.V47 -> "4.7",bonusArgs + | LangVersion.V50 -> "5.0",bonusArgs + | LangVersion.Preview -> "preview",bonusArgs + | LangVersion.Latest -> "latest", bonusArgs + | LangVersion.SupportsMl -> "5.0", "--mlcompatibility" :: bonusArgs + + let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion = + let absFolder = Path.Combine(baseFolder,folder) + + let file = Directory.GetFiles(absFolder,"*.fs*") |> Array.exactlyOne + + let version,bonusArgs = adjustVersion langVersion bonusArgs + + FsFromPath file + |> withLangVersion version + |> ignoreWarnings + |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) + |> fun cu -> + match mode with + | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> RunnerEngine.runScriptFile langVersion + | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> RunnerEngine.runScriptFile langVersion + | FSI -> cu |> asFsx |> RunnerEngine.runScriptFile langVersion + |> shouldSucceed + |> ignore + + //checker.CheckExists() + + let singleTestBuildAndRunAux folder bonusArgs mode = singleTestBuildAndRunAuxVersion folder bonusArgs mode LangVersion.Latest + let singleTestBuildAndRunVersion folder mode version = singleTestBuildAndRunAuxVersion folder [] mode version + let singleTestBuildAndRun folder mode = singleTestBuildAndRunVersion folder mode LangVersion.Latest + + let singleVersionedNegTestAux (_folder:string) _bonusArgs (_version:LangVersion) (_testName:string) = () + let singleVersionedNegTest (folder:string) (version:LangVersion) (testName:string) = + singleVersionedNegTestAux folder [] version testName + + + +module CoreTests = + open TestFrameworkAdapter + + + // These tests are enabled for .NET Framework and .NET Core + [] + let ``access-FSC_DEBUG``() = singleTestBuildAndRun "core/access" FSC_DEBUG + + [] + let ``access-FSC_OPTIMIZED``() = singleTestBuildAndRun "core/access" FSC_OPTIMIZED + + [] + let ``access-FSI``() = singleTestBuildAndRun "core/access" FSI + + [] + let ``apporder-FSC_DEBUG`` () = singleTestBuildAndRun "core/apporder" FSC_DEBUG + + [] + let ``apporder-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/apporder" FSC_OPTIMIZED + + [] + let ``apporder-FSI`` () = singleTestBuildAndRun "core/apporder" FSI + + [] + let ``array-FSC_DEBUG-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_DEBUG LangVersion.V50 + + [] + let ``array-FSC_OPTIMIZED-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.V50 + + [] + let ``array-FSI-5.0`` () = singleTestBuildAndRunVersion "core/array" FSI LangVersion.V50 + + [] + let ``array-FSC_OPTIMIZED-preview`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.Preview + + [] + let ``array-no-dot-FSC_DEBUG`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_DEBUG LangVersion.Preview + + [] + let ``array-no-dot-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_OPTIMIZED LangVersion.Preview + + [] + let ``array-no-dot-FSI`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSI LangVersion.Preview + + [] + let ``array-no-dot-warnings-langversion-default`` () = + let cfg = testConfig "core/array-no-dot-warnings" + singleVersionedNegTest cfg LangVersion.Latest "test-langversion-default" + + [] + let ``array-no-dot-warnings-langversion-5_0`` () = + let cfg = testConfig "core/array-no-dot-warnings" + singleVersionedNegTest cfg LangVersion.V50 "test-langversion-5.0" + + [] + let ``ref-ops-deprecation-langversion-preview`` () = + let cfg = testConfig "core/ref-ops-deprecation" + singleVersionedNegTest cfg LangVersion.Preview "test-langversion-preview" + + [] + let ``auto-widen-version-5_0``() = + let cfg = testConfig "core/auto-widen/5.0" + singleVersionedNegTest cfg LangVersion.V50 "test" + + [] + let ``auto-widen-version-FSC_DEBUG-preview``() = + singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_DEBUG LangVersion.Preview + + [] + let ``auto-widen-version-FSC_OPTIMIZED-preview``() = + singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_OPTIMIZED LangVersion.Preview + + [] + let ``auto-widen-version-preview-warns-on``() = + let cfg = testConfig "core/auto-widen/preview" + singleVersionedNegTestAux cfg " --warnon:3388 --warnon:3389 --warnon:3395 --warnaserror+ --define:NEGATIVE" LangVersion.Preview "test" + + [] + let ``auto-widen-version-preview-default-warns``() = + let cfg = testConfig "core/auto-widen/preview-default-warns" + singleVersionedNegTestAux cfg " --warnon:3388 --warnon:3389 --warnon:3395 --warnaserror+ --define:NEGATIVE" LangVersion.Preview "test" + + [] + let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG + + [] + let ``comprehensions-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions" FSC_OPTIMIZED + + [] + let ``comprehensions-FSI`` () = singleTestBuildAndRun "core/comprehensions" FSI + + [] + let ``comprehensionshw-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_DEBUG + + [] + let ``comprehensionshw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_OPTIMIZED + + [] + let ``comprehensionshw-FSI`` () = singleTestBuildAndRun "core/comprehensions-hw" FSI + + [] + let ``genericmeasures-FSC_DEBUG`` () = singleTestBuildAndRun "core/genericmeasures" FSC_DEBUG + + [] + let ``genericmeasures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/genericmeasures" FSC_OPTIMIZED + + [] + let ``genericmeasures-FSI`` () = singleTestBuildAndRun "core/genericmeasures" FSI + + [] + let ``innerpoly-FSC_DEBUG`` () = singleTestBuildAndRun "core/innerpoly" FSC_DEBUG + + [] + let ``innerpoly-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/innerpoly" FSC_OPTIMIZED + + [] + let ``innerpoly-FSI`` () = singleTestBuildAndRun "core/innerpoly" FSI + + [] + let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" FSC_DEBUG + + [] + let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" FSC_OPTIMIZED + + [] + let ``unicode2-FSC_DEBUG`` () = singleTestBuildAndRun "core/unicode" FSC_DEBUG // TODO: fails on coreclr + + [] + let ``unicode2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/unicode" FSC_OPTIMIZED // TODO: fails on coreclr + + [] + let ``unicode2-FSI`` () = singleTestBuildAndRun "core/unicode" FSI + + [] + let ``lazy test-FSC_DEBUG`` () = singleTestBuildAndRun "core/lazy" FSC_DEBUG + + [] + let ``lazy test-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lazy" FSC_OPTIMIZED + + [] + let ``lazy test-FSI`` () = singleTestBuildAndRun "core/lazy" FSI + + [] + let ``letrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec" FSC_DEBUG + + [] + let ``letrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec" FSC_OPTIMIZED + + [] + let ``letrec-FSI`` () = singleTestBuildAndRun "core/letrec" FSI + + [] + let ``letrec (mutrec variations part one) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_DEBUG + + [] + let ``letrec (mutrec variations part one) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_OPTIMIZED + + [] + let ``letrec (mutrec variations part one) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec" FSI + + [] + let ``libtest-FSC_DEBUG`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG + + [] + let ``libtest-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/libtest" FSC_OPTIMIZED + + [] + let ``libtest-FSI`` () = singleTestBuildAndRun "core/libtest" FSI + + [] + let ``lift-FSC_DEBUG`` () = singleTestBuildAndRun "core/lift" FSC_DEBUG + + [] + let ``lift-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lift" FSC_OPTIMIZED + + [] + let ``lift-FSI`` () = singleTestBuildAndRun "core/lift" FSI + + [] + let ``map-FSC_DEBUG`` () = singleTestBuildAndRun "core/map" FSC_DEBUG + + [] + let ``map-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/map" FSC_OPTIMIZED + + [] + let ``map-FSI`` () = singleTestBuildAndRun "core/map" FSI + + [] + let ``measures-FSC_DEBUG`` () = singleTestBuildAndRun "core/measures" FSC_DEBUG + + [] + let ``measures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/measures" FSC_OPTIMIZED + + [] + let ``measures-FSI`` () = singleTestBuildAndRun "core/measures" FSI + + [] + let ``nested-FSC_DEBUG`` () = singleTestBuildAndRun "core/nested" FSC_DEBUG + + [] + let ``nested-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/nested" FSC_OPTIMIZED + + [] + let ``nested-FSI`` () = singleTestBuildAndRun "core/nested" FSI + + [] + let ``members-ops-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops" FSC_OPTIMIZED + + [] + let ``members-ops-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops" FSC_DEBUG + + [] + let ``members-ops-FSI`` () = singleTestBuildAndRun "core/members/ops" FSI + + [] + let ``members-ops-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_DEBUG + + [] + let ``members-ops-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_OPTIMIZED + + [] + let ``members-ops-mutrec-FSI`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSI + + [] + let ``seq-FSC_DEBUG`` () = singleTestBuildAndRun "core/seq" FSC_DEBUG + + [] + let ``seq-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/seq" FSC_OPTIMIZED + + [] + let ``seq-FSI`` () = singleTestBuildAndRun "core/seq" FSI + + [] + let ``math-numbers-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbers" FSC_OPTIMIZED + + [] + let ``math-numbers-FSI`` () = singleTestBuildAndRun "core/math/numbers" FSI + + [] + let ``members-ctree-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ctree" FSC_DEBUG + + [] + let ``members-ctree-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ctree" FSC_OPTIMIZED + + [] + let ``members-ctree-FSI`` () = singleTestBuildAndRun "core/members/ctree" FSI + + [] + let ``members-factors-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors" FSC_DEBUG + + [] + let ``members-factors-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors" FSC_OPTIMIZED + + [] + let ``members-factors-FSI`` () = singleTestBuildAndRun "core/members/factors" FSI + + [] + let ``members-factors-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_DEBUG + + [] + let ``members-factors-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_OPTIMIZED + + [] + let ``members-factors-mutrec-FSI`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSI + + [] + let ``graph-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/graph" FSC_DEBUG LangVersion.SupportsMl + + [] + let ``graph-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/graph" FSC_OPTIMIZED LangVersion.SupportsMl + + [] + let ``graph-FSI`` () = singleTestBuildAndRunVersion "perf/graph" FSI LangVersion.SupportsMl + + [] + let ``nbody-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_DEBUG LangVersion.SupportsMl + + [] + let ``nbody-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_OPTIMIZED LangVersion.SupportsMl + + [] + let ``nbody-FSI`` () = singleTestBuildAndRunVersion "perf/nbody" FSI LangVersion.SupportsMl + + [] + let ``forexpression-FSC_DEBUG`` () = singleTestBuildAndRun "core/forexpression" FSC_DEBUG + + [] + let ``forexpression-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/forexpression" FSC_OPTIMIZED + + [] + let ``forexpression-FSI`` () = singleTestBuildAndRun "core/forexpression" FSI + + [] + let ``letrec (mutrec variations part two) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_DEBUG + + [] + let ``letrec (mutrec variations part two) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_OPTIMIZED + + [] + let ``letrec (mutrec variations part two) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSI + + [] + let ``printf`` () = singleTestBuildAndRunVersion "core/printf" FSC_OPTIMIZED LangVersion.Preview + + [] + let ``printf-interpolated`` () = singleTestBuildAndRunVersion "core/printf-interpolated" FSC_OPTIMIZED LangVersion.Preview + + [] + let ``tlr-FSC_DEBUG`` () = singleTestBuildAndRun "core/tlr" FSC_DEBUG + + [] + let ``tlr-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/tlr" FSC_OPTIMIZED + + [] + let ``tlr-FSI`` () = singleTestBuildAndRun "core/tlr" FSI + + [] + let ``subtype-FSC_DEBUG`` () = singleTestBuildAndRun "core/subtype" FSC_DEBUG + + [] + let ``subtype-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/subtype" FSC_OPTIMIZED + + [] + let ``subtype-FSI`` () = singleTestBuildAndRun "core/subtype" FSI + + [] + let ``syntax-FSC_DEBUG`` () = singleTestBuildAndRun "core/syntax" FSC_DEBUG + + [] + let ``syntax-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/syntax" FSC_OPTIMIZED + + [] + let ``syntax-FSI`` () = singleTestBuildAndRun "core/syntax" FSI + + [] + let ``test int32-FSC_DEBUG`` () = singleTestBuildAndRun "core/int32" FSC_DEBUG + + [] + let ``test int32-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/int32" FSC_OPTIMIZED + + [] + let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI + + [] + let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG + + [] + let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED + + [] + let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI + + [] + let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG + + [] + let ``recordResolution-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/recordResolution" FSC_OPTIMIZED + + [] + let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI + + [] + let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED + + [] + let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI + + [] + let ``control --tailcalls`` () = + let cfg = testConfig "core/control" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + + [] + let ``controlChamenos-FSC_OPTIMIZED`` () = + let cfg = testConfig "core/controlChamenos" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + + [] + let ``controlChamenos-FSI`` () = + let cfg = testConfig "core/controlChamenos" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSI + + [] + let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED + + [] + let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI + + [] + let ``controlMailbox --tailcalls`` () = + let cfg = testConfig "core/controlMailbox" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + + [] + let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED + + [] + let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI + + [] + let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED + + [] + let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI + + [] + let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED + + [] + let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI + + [] + let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED + + [] + let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI + + [] + let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED LangVersion.Preview + +// This requires --multiemit on by default, which is not the case for .NET Framework +#if NETCOREAPP + [] + let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI +#endif + + [] + let ``pinvoke-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED + + [] + let ``pinvoke-FSI`` () = + singleTestBuildAndRun "core/pinvoke" FSI + + [] + let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED + + [] + let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI + + [] + let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED + + [] + let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI \ No newline at end of file diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 8ea26ea602b..d1c7d91760e 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -787,12 +787,7 @@ module rec Compiler = let compileExeAndRun = asExe >> compileAndRun - let private evalFSharp (fs: FSharpCompilationSource) : CompilationResult = - let source = fs.Source.GetSourceText |> Option.defaultValue "" - let options = fs.Options |> Array.ofList - - use script = new FSharpScript(additionalArgs=options) - let (evalResult: Result), (err: FSharpDiagnostic[]) = script.Eval(source) + let private processScriptResults fs (evalResult: Result, err: FSharpDiagnostic[]) = let diagnostics = err |> fromFSharpDiagnostic let result = { OutputPath = None @@ -801,17 +796,43 @@ module rec Compiler = Diagnostics = diagnostics Output = Some (EvalOutput evalResult) Compilation = FS fs } - let (errors, warnings) = partitionErrors diagnostics let evalError = match evalResult with Ok _ -> false | _ -> true if evalError || errors.Length > 0 || (warnings.Length > 0 && not fs.IgnoreWarnings) then CompilationResult.Failure result else CompilationResult.Success result + + + let private evalFSharp (fs: FSharpCompilationSource) (script:FSharpScript) : CompilationResult = + let source = fs.Source.GetSourceText |> Option.defaultValue "" + script.Eval(source) |> (processScriptResults fs) + + let private evalScriptFromDisk (fs: FSharpCompilationSource) (script:FSharpScript) : CompilationResult = + //let cdBefore = Environment.CurrentDirectory + //do Environment.CurrentDirectory <- Path.GetDirectoryName(fs.Source.GetSourceFileName) + //use _ = {new IDisposable with + // member this.Dispose() = do Environment.CurrentDirectory <- cdBefore} + script.EvalScript(fs.Source.GetSourceFileName) |> (processScriptResults fs) let eval (cUnit: CompilationUnit) : CompilationResult = match cUnit with - | FS fs -> evalFSharp fs + | FS fs -> + let options = fs.Options |> Array.ofList + use script = new FSharpScript(additionalArgs=options) + evalFSharp fs script + | _ -> failwith "Script evaluation is only supported for F#." + + let getSessionForEval args version = new FSharpScript(additionalArgs=args,quiet=false,langVersion=version) + + let evalInSharedSession (script:FSharpScript) (cUnit: CompilationUnit) : CompilationResult = + match cUnit with + | FS fs -> evalFSharp fs script + | _ -> failwith "Script evaluation is only supported for F#." + + let evalScriptFromDiskInSharedSession (script:FSharpScript) (cUnit: CompilationUnit) : CompilationResult = + match cUnit with + | FS fs -> evalScriptFromDisk fs script | _ -> failwith "Script evaluation is only supported for F#." let runFsi (cUnit: CompilationUnit) : CompilationResult = @@ -1175,6 +1196,10 @@ module rec Compiler = match r.Output with | Some (ExecutionOutput output) -> sprintf "----output-----\n%s\n----error-------\n%s\n----------" output.StdOut output.StdErr + | Some (EvalOutput (Result.Error exn) ) -> + sprintf "----script error-----\n%s\n----------" (exn.ToString()) + | Some (EvalOutput (Result.Ok fsiVal) ) -> + sprintf "----script output-----\n%A\n----------" (fsiVal) | _ -> () ] |> String.concat "\n" failwith message diff --git a/tests/FSharp.Test.Utilities/ScriptHelpers.fs b/tests/FSharp.Test.Utilities/ScriptHelpers.fs index 012c27c5198..83252dd37f2 100644 --- a/tests/FSharp.Test.Utilities/ScriptHelpers.fs +++ b/tests/FSharp.Test.Utilities/ScriptHelpers.fs @@ -76,6 +76,8 @@ type LangVersion = | V47 | V50 | Preview + | Latest + | SupportsMl type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVersion) = @@ -96,8 +98,9 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer if quiet then "--quiet" match langVersion with | LangVersion.V47 -> "--langversion:4.7" - | LangVersion.V50 -> "--langversion:5.0" + | LangVersion.V50 | LangVersion.SupportsMl -> "--langversion:5.0" | LangVersion.Preview -> "--langversion:preview" + | LangVersion.Latest -> "--langversion:latest" |] let argv = Array.append baseArgs additionalArgs @@ -115,6 +118,12 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer | Choice1Of2 v -> Ok(v), errors | Choice2Of2 ex -> Error(ex), errors + member _.EvalScript(absFilePath: string) = + let ch, errors = fsi.EvalScriptNonThrowing(absFilePath) + match ch with + | Choice1Of2 _ -> Ok(Option.None), errors + | Choice2Of2 ex -> Error(ex), errors + /// Get the available completion items from the code at the specified location. /// /// The input text on which completions will be calculated diff --git a/tests/fsharp/core/members/ops/test.fsx b/tests/fsharp/core/members/ops/test.fsx index 4c0581d42ca..1f76c94ef46 100644 --- a/tests/fsharp/core/members/ops/test.fsx +++ b/tests/fsharp/core/members/ops/test.fsx @@ -415,7 +415,7 @@ let RUN() = !failures let aa = match !failures with | [] -> - stdout.WriteLine "Test Passed" + stdout.WriteLine "Test Passed" System.IO.File.WriteAllText("test.ok","ok") exit 0 | _ -> From ca842bc1aa4690902e650b0ae6f9981a4e5014c2 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 10 Jan 2023 14:33:28 +0100 Subject: [PATCH 02/19] Support for multisource tests (fsi,test2) --- .../Miscellaneous/FsharpSuiteMigrated.fs | 52 ++++++++++++------- tests/FSharp.Test.Utilities/Compiler.fs | 22 +++++--- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index a8cf091283b..c08f08e862a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -9,25 +9,25 @@ open FSharp.Test open FSharp.Test.Compiler open FSharp.Test.ScriptHelpers -module RunnerEngine = +module ScriptRunner = open Internal.Utilities.Library + let private createEngine(args,version) = - let s = getSessionForEval args version - s.Eval """let exit no = if no=0 then 0 else failwith $"Error in running, exit code={no}" """ |> ignore - s + let scriptingEnv = getSessionForEval args version + scriptingEnv.Eval """let exit (code:int) = if code=0 then () else failwith $"Error in running, exit code={code}" """ |> ignore + scriptingEnv + let getOrCreateEngine = Tables.memoize createEngine - let private definesForExe = - [ "TESTS_AS_APP" + let private defaultDefines = + [ #if NETCOREAPP "NETCOREAPP" #endif ] - let runExe = - asFs >> withDefines definesForExe >> compileExeAndRun - - let runScriptFile version (cu:CompilationUnit) = + let runScriptFile version (cu:CompilationUnit) = + let cu = cu |> withDefines defaultDefines match cu with | FS fsSource -> File.Delete("test.ok") @@ -43,13 +43,12 @@ module RunnerEngine = | _ -> failwith $"Compilation unit other than fsharp is not supported, cannot process %A{cu}" - /// This test file was created by porting over (slower) FsharpSuite.Tests /// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions module TestFrameworkAdapter = type ExecutionMode = FSC_DEBUG | FSC_OPTIMIZED | FSI let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath - let inline testConfig (relativeFolder:string) = relativeFolder + let inline testConfig (relativeFolder:string) = relativeFolder let adjustVersion version bonusArgs = match version with @@ -59,26 +58,41 @@ module TestFrameworkAdapter = | LangVersion.Latest -> "latest", bonusArgs | LangVersion.SupportsMl -> "5.0", "--mlcompatibility" :: bonusArgs + let supportedNames = set ["testlib.fsi";"testlib.fs";"test.mli";"test.ml";"test.fsi";"test.fs";"test2.fsi";"test2.fs";"test.fsx";"test2.fsx"] + let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion = let absFolder = Path.Combine(baseFolder,folder) - let file = Directory.GetFiles(absFolder,"*.fs*") |> Array.exactlyOne + let files = Directory.GetFiles(absFolder,"test*.fs*") + let mainFile,otherFiles = + match files.Length with + | 0 -> Directory.GetFiles(absFolder,"*.ml") |> Array.exactlyOne, [||] + | 1 -> files |> Array.exactlyOne, [||] + | _ -> + let dependencies,mainFile = + files + |> Array.filter (fun n -> supportedNames.Contains(Path.GetFileName(n))) + // Convention in older FsharpSuite: test2 goes last, longer names like testlib before test, .fsi before .fs on equal filenames + |> Array.sortBy (fun n -> n.Contains("test2"), -n.IndexOf('.'), n.EndsWith(".fsi") |> not) + |> Array.splitAt (files.Length-1) + mainFile[0],dependencies let version,bonusArgs = adjustVersion langVersion bonusArgs - FsFromPath file + FsFromPath mainFile + |> withAdditionalSourceFiles [for f in otherFiles -> SourceFromPath f] |> withLangVersion version |> ignoreWarnings |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) |> fun cu -> match mode with - | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> RunnerEngine.runScriptFile langVersion - | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> RunnerEngine.runScriptFile langVersion - | FSI -> cu |> asFsx |> RunnerEngine.runScriptFile langVersion + | FSC_DEBUG -> cu |> withDebug |> withNoOptimize + | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug + | FSI -> cu + |> ScriptRunner.runScriptFile langVersion |> shouldSucceed |> ignore - - //checker.CheckExists() + let singleTestBuildAndRunAux folder bonusArgs mode = singleTestBuildAndRunAuxVersion folder bonusArgs mode LangVersion.Latest let singleTestBuildAndRunVersion folder mode version = singleTestBuildAndRunAuxVersion folder [] mode version diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index d1c7d91760e..de31d8c0d23 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -789,16 +789,17 @@ module rec Compiler = let private processScriptResults fs (evalResult: Result, err: FSharpDiagnostic[]) = let diagnostics = err |> fromFSharpDiagnostic + let (errors, warnings) = partitionErrors diagnostics let result = { OutputPath = None Dependencies = [] Adjust = 0 - Diagnostics = diagnostics + Diagnostics = if fs.IgnoreWarnings then errors else diagnostics Output = Some (EvalOutput evalResult) Compilation = FS fs } - let (errors, warnings) = partitionErrors diagnostics + let evalError = match evalResult with Ok _ -> false | _ -> true - if evalError || errors.Length > 0 || (warnings.Length > 0 && not fs.IgnoreWarnings) then + if evalError || errors.Length > 0 || (warnings.Length > 0 && not fs.IgnoreWarnings) then CompilationResult.Failure result else CompilationResult.Success result @@ -809,11 +810,16 @@ module rec Compiler = script.Eval(source) |> (processScriptResults fs) let private evalScriptFromDisk (fs: FSharpCompilationSource) (script:FSharpScript) : CompilationResult = - //let cdBefore = Environment.CurrentDirectory - //do Environment.CurrentDirectory <- Path.GetDirectoryName(fs.Source.GetSourceFileName) - //use _ = {new IDisposable with - // member this.Dispose() = do Environment.CurrentDirectory <- cdBefore} - script.EvalScript(fs.Source.GetSourceFileName) |> (processScriptResults fs) + let fileNames = + [ yield! fs.AdditionalSources + yield fs.Source] + |> List.map (fun x -> x.GetSourceFileName) + |> List.map (sprintf " @\"%s\"") + |> String.Concat + + script.Eval("#load" + fileNames ) + |> (processScriptResults fs) + let eval (cUnit: CompilationUnit) : CompilationResult = match cUnit with From cd04c01aae7b074db63e36a6fc0212015f74bf98 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 11 Jan 2023 17:22:19 +0100 Subject: [PATCH 03/19] Making migrated tests pass --- .../Miscellaneous/FsharpSuiteMigrated.fs | 39 ++-- tests/FSharp.Test.Utilities/Compiler.fs | 4 +- tests/FSharp.Test.Utilities/ScriptHelpers.fs | 6 - tests/fsharp/core/namespaces/test2.fs | 2 +- tests/fsharp/core/subtype/test.fsx | 10 +- tests/fsharp/core/unicode/test.fsx | 8 +- tests/fsharp/tests.fs | 178 ++++++++++-------- 7 files changed, 136 insertions(+), 111 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index c08f08e862a..1e349614c7e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -14,12 +14,12 @@ module ScriptRunner = let private createEngine(args,version) = let scriptingEnv = getSessionForEval args version - scriptingEnv.Eval """let exit (code:int) = if code=0 then () else failwith $"Error in running, exit code={code}" """ |> ignore + scriptingEnv.Eval """let exit (code:int) = if code=0 then () else failwith $"Script called function 'exit' with code={code}" """ |> ignore scriptingEnv - let getOrCreateEngine = Tables.memoize createEngine + //let private getOrCreateEngine = createEngine//Tables.memoize createEngine - let private defaultDefines = + let defaultDefines = [ #if NETCOREAPP "NETCOREAPP" @@ -31,7 +31,7 @@ module ScriptRunner = match cu with | FS fsSource -> File.Delete("test.ok") - let engine = getOrCreateEngine (fsSource.Options |> Array.ofList,version) + let engine = createEngine (fsSource.Options |> Array.ofList,version) let res = evalScriptFromDiskInSharedSession engine cu match res with | CompilationResult.Failure _ -> res @@ -46,7 +46,12 @@ module ScriptRunner = /// This test file was created by porting over (slower) FsharpSuite.Tests /// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions module TestFrameworkAdapter = - type ExecutionMode = FSC_DEBUG | FSC_OPTIMIZED | FSI + type ExecutionMode = + | FSC_DEBUG + | FSC_OPTIMIZED + | FSI + | COMPILED_EXE_APP + let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath let inline testConfig (relativeFolder:string) = relativeFolder @@ -69,12 +74,13 @@ module TestFrameworkAdapter = | 0 -> Directory.GetFiles(absFolder,"*.ml") |> Array.exactlyOne, [||] | 1 -> files |> Array.exactlyOne, [||] | _ -> - let dependencies,mainFile = + let mainFile,dependencies = files |> Array.filter (fun n -> supportedNames.Contains(Path.GetFileName(n))) // Convention in older FsharpSuite: test2 goes last, longer names like testlib before test, .fsi before .fs on equal filenames |> Array.sortBy (fun n -> n.Contains("test2"), -n.IndexOf('.'), n.EndsWith(".fsi") |> not) - |> Array.splitAt (files.Length-1) + |> Array.splitAt 1 + mainFile[0],dependencies let version,bonusArgs = adjustVersion langVersion bonusArgs @@ -86,10 +92,10 @@ module TestFrameworkAdapter = |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) |> fun cu -> match mode with - | FSC_DEBUG -> cu |> withDebug |> withNoOptimize - | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug - | FSI -> cu - |> ScriptRunner.runScriptFile langVersion + | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> ScriptRunner.runScriptFile langVersion + | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> ScriptRunner.runScriptFile langVersion + | FSI -> cu |> ScriptRunner.runScriptFile langVersion + | COMPILED_EXE_APP -> cu |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed |> ignore @@ -223,10 +229,10 @@ module CoreTests = let ``innerpoly-FSI`` () = singleTestBuildAndRun "core/innerpoly" FSI [] - let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" FSC_DEBUG + let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP [] - let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" FSC_OPTIMIZED + let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP [] let ``unicode2-FSC_DEBUG`` () = singleTestBuildAndRun "core/unicode" FSC_DEBUG // TODO: fails on coreclr @@ -447,6 +453,8 @@ module CoreTests = [] let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI + // This test stays in FsharpSuite for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside +#if NETCOREAPP [] let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG @@ -455,6 +463,7 @@ module CoreTests = [] let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI +#endif [] let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG @@ -465,6 +474,9 @@ module CoreTests = [] let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI +#if NETCOREAPP +// This test has hardcoded expectations about current synchronization context +// Will be moved out of FsharpSuite.Tests in a later phase [] let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED @@ -475,6 +487,7 @@ module CoreTests = let ``control --tailcalls`` () = let cfg = testConfig "core/control" singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED +#endif [] let ``controlChamenos-FSC_OPTIMIZED`` () = diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index de31d8c0d23..d498d9b5b21 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -811,15 +811,13 @@ module rec Compiler = let private evalScriptFromDisk (fs: FSharpCompilationSource) (script:FSharpScript) : CompilationResult = let fileNames = - [ yield! fs.AdditionalSources - yield fs.Source] + (fs.Source :: fs.AdditionalSources) |> List.map (fun x -> x.GetSourceFileName) |> List.map (sprintf " @\"%s\"") |> String.Concat script.Eval("#load" + fileNames ) |> (processScriptResults fs) - let eval (cUnit: CompilationUnit) : CompilationResult = match cUnit with diff --git a/tests/FSharp.Test.Utilities/ScriptHelpers.fs b/tests/FSharp.Test.Utilities/ScriptHelpers.fs index 83252dd37f2..ddf4d146ead 100644 --- a/tests/FSharp.Test.Utilities/ScriptHelpers.fs +++ b/tests/FSharp.Test.Utilities/ScriptHelpers.fs @@ -118,12 +118,6 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer | Choice1Of2 v -> Ok(v), errors | Choice2Of2 ex -> Error(ex), errors - member _.EvalScript(absFilePath: string) = - let ch, errors = fsi.EvalScriptNonThrowing(absFilePath) - match ch with - | Choice1Of2 _ -> Ok(Option.None), errors - | Choice2Of2 ex -> Error(ex), errors - /// Get the available completion items from the code at the specified location. /// /// The input text on which completions will be calculated diff --git a/tests/fsharp/core/namespaces/test2.fs b/tests/fsharp/core/namespaces/test2.fs index 19d215d4a00..230ffcca48b 100644 --- a/tests/fsharp/core/namespaces/test2.fs +++ b/tests/fsharp/core/namespaces/test2.fs @@ -13,7 +13,7 @@ module M = #if TESTS_AS_APP - let RUN() = !failures + let RUN() = !Hello.Goodbye.Utils.failures #else let aa = if not (!Hello.Goodbye.Utils.failures).IsEmpty then diff --git a/tests/fsharp/core/subtype/test.fsx b/tests/fsharp/core/subtype/test.fsx index 76de2b2d520..c9aa30a006b 100644 --- a/tests/fsharp/core/subtype/test.fsx +++ b/tests/fsharp/core/subtype/test.fsx @@ -1088,7 +1088,7 @@ module InnerConstrainedClosureTests = printfn "hello, %A" z /// This uses the local type function in another closure that also captures one of the outer arguments let h() = g(3,y) - /// This just returnes the closure to make sure we don't optimize it all away + // This just returnes the closure to make sure we don't optimize it all away h @@ -1099,7 +1099,7 @@ module InnerConstrainedClosureTests = printfn "hello, %A" z /// This uses the local type function in another closure that also captures one of the outer arguments let h() = g(3) - /// This just returnes the closure to make sure we don't optimize it all away + // This just returnes the closure to make sure we don't optimize it all away h let Example3 (y:'b,z:'a) = @@ -1108,7 +1108,7 @@ module InnerConstrainedClosureTests = printfn "hello, %A" z /// This uses the local type function in another closure that also captures one of the outer arguments let h() = g(3,y) - /// This just returnes the closure to make sure we don't optimize it all away + // This just returnes the closure to make sure we don't optimize it all away h let Example4 (y:'b,z:'a) = @@ -1119,7 +1119,7 @@ module InnerConstrainedClosureTests = let h1() = g(3,4,y) /// This uses the local type function in another closure that also captures one of the outer arguments let h2() = g("3","4",y) - /// This just returnes the closure to make sure we don't optimize it all away + // This just returnes the closure to make sure we don't optimize it all away h1,h2 @@ -1132,7 +1132,7 @@ module InnerConstrainedClosureTests = let h1() = g(3,4,y) /// This uses the local type function in another closure that also captures one of the outer arguments let h2() = g("3","4",y) - /// This just returnes the closure to make sure we don't optimize it all away + // This just returnes the closure to make sure we don't optimize it all away h1,h2 let Example6 (y:'b,z:'a) = diff --git a/tests/fsharp/core/unicode/test.fsx b/tests/fsharp/core/unicode/test.fsx index 9b7303c0d32..10089e9dd0b 100644 --- a/tests/fsharp/core/unicode/test.fsx +++ b/tests/fsharp/core/unicode/test.fsx @@ -24,6 +24,8 @@ let input_byte (x : System.IO.FileStream) = let b = x.ReadByte() if b = -1 then raise (System.IO.EndOfStreamException()) else b +let bslFilePath = Path.Combine(__SOURCE_DIRECTORY__,"out.bsl") + let test2925 () = printfn "test2925..."; (* This writes a file in the standard utf8 encoding. Probably needs to be adjusted if default encodings differ *) @@ -32,7 +34,7 @@ let test2925 () = os.Write "\u2260"; (* not equals *) os.Dispose(); use is1 = System.IO.File.OpenRead "out1.txt" in - use is2 = System.IO.File.OpenRead "out.bsl" in + use is2 = System.IO.File.OpenRead bslFilePath in try while true do let c2 = input_byte is2 in @@ -54,7 +56,7 @@ let test2925b () = os.Write "\U00002260"; (* not equals *) os.Dispose(); let is1 = System.IO.File.OpenRead "out1.txt" in - let is2 = System.IO.File.OpenRead "out.bsl" in + let is2 = System.IO.File.OpenRead bslFilePath in try while true do let c2 = input_byte is2 in @@ -77,7 +79,7 @@ let test2926 () = Printf.printf "length s = %d\n" (String.length s); os.Dispose(); let is1 = System.IO.File.OpenRead "out2.txt" in - let is2 = System.IO.File.OpenRead "out.bsl" in + let is2 = System.IO.File.OpenRead bslFilePath in try while true do let c2 = input_byte is2 in diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index c43b1aceabf..0bf7c78a363 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -32,9 +32,11 @@ let singleTestBuildAndRun = getTestsDirectory >> singleTestBuildAndRun let singleTestBuildAndRunVersion = getTestsDirectory >> singleTestBuildAndRunVersion let testConfig = getTestsDirectory >> testConfig - [] -module CoreTests = +module TestsToBeDeletedBecauseTheyHaveMoved = + let x = 42 + + // These tests are enabled for .NET Framework and .NET Core [] let ``access-FSC_DEBUG``() = singleTestBuildAndRun "core/access" FSC_DEBUG @@ -376,6 +378,8 @@ module CoreTests = [] let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI +#if !NETCOREAPP +// This test stays in FsharpSuite for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside [] let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG @@ -384,6 +388,7 @@ module CoreTests = [] let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI +#endif [] let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG @@ -394,6 +399,97 @@ module CoreTests = [] let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI +#if !NETCOREAPP +// This test has hardcoded expectations about current synchronization context +// Will be moved out of FsharpSuite.Tests in a later phase + [] + let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED + + [] + let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI + + [] + let ``control --tailcalls`` () = + let cfg = testConfig "core/control" + singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED +#endif + + [] + let ``controlChamenos-FSC_OPTIMIZED`` () = + let cfg = testConfig "core/controlChamenos" + singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED + + [] + let ``controlChamenos-FSI`` () = + let cfg = testConfig "core/controlChamenos" + singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSI + + [] + let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED + + [] + let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI + + [] + let ``controlMailbox --tailcalls`` () = + let cfg = testConfig "core/controlMailbox" + singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED + + [] + let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED + + [] + let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI + + [] + let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED + + [] + let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI + + [] + let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED + + [] + let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI + + [] + let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED + + [] + let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI + + [] + let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED "preview" + +// This requires --multiemit on by default, which is not the case for .NET Framework +#if NETCOREAPP + [] + let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI +#endif + + [] + let ``pinvoke-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED + + [] + let ``pinvoke-FSI`` () = + singleTestBuildAndRun "core/pinvoke" FSI + + [] + let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED + + [] + let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI + + [] + let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED + + [] + let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI + +[] +module CoreTests = + [] let ``SDKTests`` () = let cfg = testConfig "SDKTests" @@ -647,49 +743,7 @@ module CoreTests = #endif - [] - let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED - - [] - let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI - - [] - let ``control --tailcalls`` () = - let cfg = testConfig "core/control" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED - - [] - let ``controlChamenos-FSC_OPTIMIZED`` () = - let cfg = testConfig "core/controlChamenos" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED - - [] - let ``controlChamenos-FSI`` () = - let cfg = testConfig "core/controlChamenos" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSI - - [] - let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED - - [] - let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI - - [] - let ``controlMailbox --tailcalls`` () = - let cfg = testConfig "core/controlMailbox" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED - - [] - let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED - - [] - let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI - [] - let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED - - [] - let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI #if !NETCOREAPP @@ -1576,39 +1630,7 @@ module CoreTests = | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stderrPath stderrBaseline diffs2) #endif - [] - let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED - - [] - let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI - - [] - let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED - [] - let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI - - [] - let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED "preview" - -// This requires --multiemit on by default, which is not the case for .NET Framework -#if NETCOREAPP - [] - let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI -#endif - - [] - let ``pinvoke-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED - - [] - let ``pinvoke-FSI`` () = - singleTestBuildAndRun "core/pinvoke" FSI - - [] - let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED - - [] - let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI #if !NETCOREAPP [] @@ -1835,11 +1857,7 @@ module CoreTests = testOkFile.CheckExists() #endif - [] - let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED - [] - let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI #if !NETCOREAPP [] From 623eb47271d60978562724474e2da161d6d314cc Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 12 Jan 2023 21:09:08 +0100 Subject: [PATCH 04/19] Pinvoke tests only on windows --- .../Miscellaneous/FsharpSuiteMigrated.fs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 1e349614c7e..6c6093952af 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -543,13 +543,6 @@ module CoreTests = let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI #endif - [] - let ``pinvoke-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED - - [] - let ``pinvoke-FSI`` () = - singleTestBuildAndRun "core/pinvoke" FSI - [] let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED @@ -560,4 +553,18 @@ module CoreTests = let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED [] - let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI \ No newline at end of file + let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI + + module PInvokeTests = + open System.Runtime.InteropServices + let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + + [] + let ``pinvoke-FSC_OPTIMIZED`` () = + if isWindows then + singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED + + [] + let ``pinvoke-FSI`` () = + if isWindows then + singleTestBuildAndRun "core/pinvoke" FSI \ No newline at end of file From 381e1f24d40aec4eece2000c0d1492973dffcfaa Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 13 Jan 2023 11:16:12 +0100 Subject: [PATCH 05/19] negTests -> rendering of errors to match baseline files (to be finished) --- .../Miscellaneous/FsharpSuiteMigrated.fs | 52 ++++++++++++++++--- tests/FSharp.Test.Utilities/Compiler.fs | 51 +++++++++++------- 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 6c6093952af..e84fa6f61e3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -43,6 +43,32 @@ module ScriptRunner = | _ -> failwith $"Compilation unit other than fsharp is not supported, cannot process %A{cu}" +module DiagnosticsComparison = + open FSharp.Compiler.Text.Range + + let messageAndNumber erroryType = + match erroryType with + | ErrorType.Error n -> "error",n + | ErrorType.Warning n-> "warning",n + | ErrorType.Hidden n + | ErrorType.Information n-> "info",n + + let renderToString (cr:CompilationResult) = + [ for (file,err) in cr.Output.PerFileErrors do + let m = err.Range + let file = file.Replace("/", "\\") + + let msg,no = messageAndNumber err.Error + + if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then + "" + else + sprintf "%s(%d,%d,%d,%d): " file m.StartLine m.StartColumn m.EndLine m.EndColumn + + ] + + + /// This test file was created by porting over (slower) FsharpSuite.Tests /// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions module TestFrameworkAdapter = @@ -51,10 +77,18 @@ module TestFrameworkAdapter = | FSC_OPTIMIZED | FSI | COMPILED_EXE_APP + | NEG_TEST_BUILD of testName:string let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath let inline testConfig (relativeFolder:string) = relativeFolder + let diffNegativeBaseline (cr:CompilationUnit) absFolder testName = + let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") + for f in expectedFiles do + match Path.GetExtension(f) with + | "bsl" -> cr |> typecheck + | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] + let adjustVersion version bonusArgs = match version with | LangVersion.V47 -> "4.7",bonusArgs @@ -88,15 +122,19 @@ module TestFrameworkAdapter = FsFromPath mainFile |> withAdditionalSourceFiles [for f in otherFiles -> SourceFromPath f] |> withLangVersion version - |> ignoreWarnings - |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) |> fun cu -> match mode with - | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> ScriptRunner.runScriptFile langVersion - | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> ScriptRunner.runScriptFile langVersion - | FSI -> cu |> ScriptRunner.runScriptFile langVersion - | COMPILED_EXE_APP -> cu |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun - |> shouldSucceed + | FSC_DEBUG | FSC_OPTIMIZED | FSI | COMPILED_EXE_APP -> + cu |> ignoreWarnings |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) + | NEG_TEST_BUILD _ -> cu |> withOptions (["--vserrors";"--maxerrors:10000"] @ bonusArgs) + |> fun cu -> + match mode with + | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> ScriptRunner.runScriptFile langVersion |> shouldSucceed + | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> ScriptRunner.runScriptFile langVersion |> shouldSucceed + | FSI -> cu |> ScriptRunner.runScriptFile langVersion |> shouldSucceed + | COMPILED_EXE_APP -> cu |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed + | NEG_TEST_BUILD testName -> cu |> typecheck |> shouldFail + |> ignore diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index d498d9b5b21..bbcd92924a4 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -155,13 +155,16 @@ module rec Compiler = | EvalOutput of Result | ExecutionOutput of ExecutionOutput + type SourceCodeFileName = string + type CompilationOutput = - { OutputPath: string option - Dependencies: string list - Adjust: int - Diagnostics: ErrorInfo list - Output: RunOutput option - Compilation: CompilationUnit } + { OutputPath: string option + Dependencies: string list + Adjust: int + Diagnostics: ErrorInfo list + PerFileErrors: (SourceCodeFileName * ErrorInfo) list + Output: RunOutput option + Compilation: CompilationUnit } [] type CompilationResult = @@ -217,13 +220,14 @@ module rec Compiler = References = [] } - let private fromFSharpDiagnostic (errors: FSharpDiagnostic[]) : ErrorInfo list = - let toErrorInfo (e: FSharpDiagnostic) : ErrorInfo = + let private fromFSharpDiagnostic (errors: FSharpDiagnostic[]) : (SourceCodeFileName * ErrorInfo) list = + let toErrorInfo (e: FSharpDiagnostic) : SourceCodeFileName * ErrorInfo = let errorNumber = e.ErrorNumber let severity = e.Severity let error = if severity = FSharpDiagnosticSeverity.Warning then Warning errorNumber else Error errorNumber + e.FileName |> Path.GetFileName, { Error = error Range = { StartLine = e.StartLine @@ -234,7 +238,7 @@ module rec Compiler = errors |> List.ofArray - |> List.distinctBy (fun e -> e.Severity, e.ErrorNumber, e.StartLine, e.StartColumn, e.EndLine, e.EndColumn, e.Message) + |> List.distinctBy (fun e -> e.FileName,e.Severity, e.ErrorNumber, e.StartLine, e.StartColumn, e.EndLine, e.EndColumn, e.Message) |> List.map toErrorInfo let private partitionErrors diagnostics = diagnostics |> List.partition (fun e -> match e.Error with Error _ -> true | _ -> false) @@ -556,14 +560,15 @@ module rec Compiler = let diagnostics = err |> fromFSharpDiagnostic let result = - { OutputPath = None - Dependencies = deps - Adjust = 0 - Diagnostics = diagnostics - Output = None - Compilation = cUnit } + { OutputPath = None + Dependencies = deps + Adjust = 0 + PerFileErrors = diagnostics + Diagnostics = diagnostics |> List.map snd + Output = None + Compilation = cUnit } - let (errors, warnings) = partitionErrors diagnostics + let (errors, warnings) = partitionErrors result.Diagnostics // Treat warnings as errors if "IgnoreWarnings" is false if errors.Length > 0 || (warnings.Length > 0 && not ignoreWarnings) then @@ -609,6 +614,7 @@ module rec Compiler = Dependencies = dependencies Adjust = 0 Diagnostics = cmplResult.Diagnostics |> Seq.map toErrorInfo |> Seq.toList + PerFileErrors= List.empty // Not needed for C# testing for now. Implement when needed Output = None Compilation = CS csSource } @@ -708,7 +714,8 @@ module rec Compiler = { OutputPath = None Dependencies = [] Adjust = 0 - Diagnostics = diagnostics + Diagnostics = diagnostics |> List.map snd + PerFileErrors= diagnostics Output = None Compilation = FS fsSource } @@ -738,10 +745,11 @@ module rec Compiler = { OutputPath = None Dependencies = [] Adjust = 0 - Diagnostics = diagnostics + Diagnostics = diagnostics |> List.map snd + PerFileErrors= diagnostics Output = None Compilation = FS fsSource } - let (errors, warnings) = partitionErrors diagnostics + let (errors, warnings) = partitionErrors result.Diagnostics // Treat warnings as errors if "IgnoreWarnings" is false; if errors.Length > 0 || (warnings.Length > 0 && not fsSource.IgnoreWarnings) then @@ -788,13 +796,15 @@ module rec Compiler = let compileExeAndRun = asExe >> compileAndRun let private processScriptResults fs (evalResult: Result, err: FSharpDiagnostic[]) = - let diagnostics = err |> fromFSharpDiagnostic + let perFileDiagnostics = err |> fromFSharpDiagnostic + let diagnostics = perFileDiagnostics |> List.map snd let (errors, warnings) = partitionErrors diagnostics let result = { OutputPath = None Dependencies = [] Adjust = 0 Diagnostics = if fs.IgnoreWarnings then errors else diagnostics + PerFileErrors = perFileDiagnostics Output = Some (EvalOutput evalResult) Compilation = FS fs } @@ -877,6 +887,7 @@ module rec Compiler = Dependencies = [] Adjust = 0 Diagnostics = [] + PerFileErrors= [] Output = None Compilation = cUnit } From d955b2d1ab8ffd18e1c281f2c269255ed4f3eb90 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 24 Jan 2023 21:00:34 +0100 Subject: [PATCH 06/19] negative tests string comparison --- .../OffsideExceptions/OffsideExceptions.fs | 2 ++ .../EmittedIL/Enums.fs | 1 + .../EmittedIL/Literals.fs | 1 + .../ErrorMessages/UnsupportedAttributes.fs | 1 + .../Miscellaneous/FsharpSuiteMigrated.fs | 23 ++++++++++------- tests/FSharp.Test.Utilities/Compiler.fs | 25 ++++++++++++++++--- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs index f00e227c826..144f94c6b6e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs @@ -5,8 +5,10 @@ namespace FSharp.Compiler.ComponentTests.Conformance.LexicalFiltering.Basic open Xunit open FSharp.Test open FSharp.Test.Compiler +open FSharp.Test.Compiler.Assertions.ExactResultAsserts module OffsideExceptions = + type FileAttribute(file) = inherit DirectoryAttribute(__SOURCE_DIRECTORY__, Includes=[|file|]) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs index 33217909d2a..6536b01b858 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL open Xunit open FSharp.Test.Compiler +open FSharp.Test.Compiler.Assertions.ExactResultAsserts module Enums = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs index 570f22d1377..95380460419 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL open Xunit open FSharp.Test.Compiler +open FSharp.Test.Compiler.Assertions.ExactResultAsserts module ``Literals`` = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs index fa981de2a14..a076bb42327 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit open FSharp.Test.Compiler +open FSharp.Test.Compiler.Assertions.ExactResultAsserts module ``Unsupported Attributes`` = diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index e84fa6f61e3..6f49cbc9af4 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -55,15 +55,18 @@ module DiagnosticsComparison = let renderToString (cr:CompilationResult) = [ for (file,err) in cr.Output.PerFileErrors do - let m = err.Range + let m = err.NativeRange let file = file.Replace("/", "\\") - let msg,no = messageAndNumber err.Error + let severity,no = messageAndNumber err.Error - if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then - "" - else - sprintf "%s(%d,%d,%d,%d): " file m.StartLine m.StartColumn m.EndLine m.EndColumn + let location = + if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then + "" + else + sprintf "%s(%d,%d,%d,%d): " file m.StartLine m.StartColumn m.EndLine m.EndColumn + + $"{location} typecheck {severity} FS%04d{no}: {err.Message}" ] @@ -86,8 +89,10 @@ module TestFrameworkAdapter = let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") for f in expectedFiles do match Path.GetExtension(f) with - | "bsl" -> cr |> typecheck - | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] + | "bsl" -> cr |> typecheck |> shouldFail |> ignore + | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] |> typecheck |> shouldFail |> ignore + | _ -> () + let adjustVersion version bonusArgs = match version with @@ -133,7 +138,7 @@ module TestFrameworkAdapter = | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> ScriptRunner.runScriptFile langVersion |> shouldSucceed | FSI -> cu |> ScriptRunner.runScriptFile langVersion |> shouldSucceed | COMPILED_EXE_APP -> cu |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed - | NEG_TEST_BUILD testName -> cu |> typecheck |> shouldFail + | NEG_TEST_BUILD _testName -> cu |> typecheck |> shouldFail |> ignore diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index bbcd92924a4..bae9ca25d63 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -144,6 +144,7 @@ module rec Compiler = type ErrorInfo = { Error: ErrorType Range: Range + NativeRange : FSharp.Compiler.Text.range Message: string } type ExecutionOutput = @@ -229,6 +230,7 @@ module rec Compiler = e.FileName |> Path.GetFileName, { Error = error + NativeRange = e.Range Range = { StartLine = e.StartLine StartColumn = e.StartColumn @@ -605,6 +607,7 @@ module rec Compiler = StartColumn = span.Start.Character EndLine = span.End.Line EndColumn = span.End.Character } + NativeRange = Unchecked.defaultof<_> Message = d.GetMessage() } let private compileCSharpCompilation (compilation: CSharpCompilation) csSource (filePath : string) dependencies : CompilationResult = @@ -1231,11 +1234,11 @@ module rec Compiler = assertErrors what r.Adjust (selector r) expected result - let withResults (expectedResults: ErrorInfo list) result : CompilationResult = + let private withResultsIgnoreNativeRange (expectedResults: ErrorInfo list) result : CompilationResult = assertResultsCategory "Results" (fun r -> r.Diagnostics) expectedResults result - let withResult (expectedResult: ErrorInfo ) (result: CompilationResult) : CompilationResult = - withResults [expectedResult] result + let private withResultIgnoreNativeRange (expectedResult: ErrorInfo ) (result: CompilationResult) : CompilationResult = + withResultsIgnoreNativeRange [expectedResult] result let withDiagnostics (expected: (ErrorType * Line * Col * Line * Col * string) list) (result: CompilationResult) : CompilationResult = let expectedResults: ErrorInfo list = @@ -1247,8 +1250,9 @@ module rec Compiler = StartColumn = startCol EndLine = endLine EndColumn = endCol } + NativeRange = Unchecked.defaultof<_> Message = message } ] - withResults expectedResults result + withResultsIgnoreNativeRange expectedResults result let withSingleDiagnostic (expected: (ErrorType * Line * Col * Line * Col * string)) (result: CompilationResult) : CompilationResult = withDiagnostics [expected] result @@ -1259,6 +1263,19 @@ module rec Compiler = let withError (expectedError: ErrorInfo) (result: CompilationResult) : CompilationResult = withErrors [expectedError] result + module ExactResultAsserts = + type SimpleErrorInfo = + { Error: ErrorType + Range: Range + Message: string } + + let withResults (expectedResults: SimpleErrorInfo list) result : CompilationResult = + let mappedResults = expectedResults |> List.map (fun s -> { Error = s.Error;Range = s.Range; Message = s.Message; NativeRange = Unchecked.defaultof<_>}) + Compiler.Assertions.withResultsIgnoreNativeRange mappedResults result + + let withResult (expectedResult: SimpleErrorInfo ) (result: CompilationResult) : CompilationResult = + withResults [expectedResult] result + let checkCodes (expected: int list) (selector: CompilationOutput -> ErrorInfo list) (result: CompilationResult) : CompilationResult = match result with | CompilationResult.Success r From fd6fb45e3368ec50da9994ff7c7b3bc15cf005f2 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 25 Jan 2023 16:40:17 +0100 Subject: [PATCH 07/19] neg test integration --- .../Miscellaneous/FsharpSuiteMigrated.fs | 53 +++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 6f49cbc9af4..0a034fa154a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -87,11 +87,12 @@ module TestFrameworkAdapter = let diffNegativeBaseline (cr:CompilationUnit) absFolder testName = let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") - for f in expectedFiles do + [ for f in expectedFiles do match Path.GetExtension(f) with - | "bsl" -> cr |> typecheck |> shouldFail |> ignore - | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] |> typecheck |> shouldFail |> ignore - | _ -> () + | "bsl" -> cr |> typecheck |> shouldFail + | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] |> typecheck |> shouldFail + | _ -> () ] + |> List.head let adjustVersion version bonusArgs = @@ -130,16 +131,37 @@ module TestFrameworkAdapter = |> fun cu -> match mode with | FSC_DEBUG | FSC_OPTIMIZED | FSI | COMPILED_EXE_APP -> - cu |> ignoreWarnings |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) - | NEG_TEST_BUILD _ -> cu |> withOptions (["--vserrors";"--maxerrors:10000"] @ bonusArgs) + cu + |> ignoreWarnings + |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) + | NEG_TEST_BUILD _ -> + cu |> + withOptions (["--vserrors";"--maxerrors:10000"] @ bonusArgs) |> fun cu -> match mode with - | FSC_DEBUG -> cu |> withDebug |> withNoOptimize |> ScriptRunner.runScriptFile langVersion |> shouldSucceed - | FSC_OPTIMIZED -> cu |> withOptimize |> withNoDebug |> ScriptRunner.runScriptFile langVersion |> shouldSucceed - | FSI -> cu |> ScriptRunner.runScriptFile langVersion |> shouldSucceed - | COMPILED_EXE_APP -> cu |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed - | NEG_TEST_BUILD _testName -> cu |> typecheck |> shouldFail - + | FSC_DEBUG -> + cu + |> withDebug + |> withNoOptimize + |> ScriptRunner.runScriptFile langVersion + |> shouldSucceed + | FSC_OPTIMIZED -> + cu + |> withOptimize + |> withNoDebug + |> ScriptRunner.runScriptFile langVersion + |> shouldSucceed + | FSI -> + cu + |> ScriptRunner.runScriptFile langVersion + |> shouldSucceed + | COMPILED_EXE_APP -> + cu + |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) + |> compileExeAndRun + |> shouldSucceed + | NEG_TEST_BUILD testName -> diffNegativeBaseline cu absFolder testName + |> ignore @@ -147,7 +169,8 @@ module TestFrameworkAdapter = let singleTestBuildAndRunVersion folder mode version = singleTestBuildAndRunAuxVersion folder [] mode version let singleTestBuildAndRun folder mode = singleTestBuildAndRunVersion folder mode LangVersion.Latest - let singleVersionedNegTestAux (_folder:string) _bonusArgs (_version:LangVersion) (_testName:string) = () + let singleVersionedNegTestAux folder bonusArgs version testName = + singleTestBuildAndRunAuxVersion folder bonusArgs (NEG_TEST_BUILD testName) version let singleVersionedNegTest (folder:string) (version:LangVersion) (testName:string) = singleVersionedNegTestAux folder [] version testName @@ -228,12 +251,12 @@ module CoreTests = [] let ``auto-widen-version-preview-warns-on``() = let cfg = testConfig "core/auto-widen/preview" - singleVersionedNegTestAux cfg " --warnon:3388 --warnon:3389 --warnon:3395 --warnaserror+ --define:NEGATIVE" LangVersion.Preview "test" + singleVersionedNegTestAux cfg ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" [] let ``auto-widen-version-preview-default-warns``() = let cfg = testConfig "core/auto-widen/preview-default-warns" - singleVersionedNegTestAux cfg " --warnon:3388 --warnon:3389 --warnon:3395 --warnaserror+ --define:NEGATIVE" LangVersion.Preview "test" + singleVersionedNegTestAux cfg ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" [] let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG From 64e8b052418cb8ba950e19bf10df07568987ef4a Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 25 Jan 2023 18:45:25 +0100 Subject: [PATCH 08/19] making array negative tests pass --- .../OffsideExceptions/OffsideExceptions.fs | 2 +- .../EmittedIL/Enums.fs | 2 +- .../EmittedIL/Literals.fs | 2 +- .../ErrorMessages/UnsupportedAttributes.fs | 2 +- .../Miscellaneous/FsharpSuiteMigrated.fs | 59 +++++++------------ tests/FSharp.Test.Utilities/Compiler.fs | 45 +++++++++++++- 6 files changed, 66 insertions(+), 46 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs index 144f94c6b6e..ffc44b00032 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs @@ -5,7 +5,7 @@ namespace FSharp.Compiler.ComponentTests.Conformance.LexicalFiltering.Basic open Xunit open FSharp.Test open FSharp.Test.Compiler -open FSharp.Test.Compiler.Assertions.ExactResultAsserts +open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts module OffsideExceptions = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs index 6536b01b858..98df4894328 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs @@ -4,7 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL open Xunit open FSharp.Test.Compiler -open FSharp.Test.Compiler.Assertions.ExactResultAsserts +open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts module Enums = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs index 95380460419..c168d88fba4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Literals.fs @@ -4,7 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL open Xunit open FSharp.Test.Compiler -open FSharp.Test.Compiler.Assertions.ExactResultAsserts +open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts module ``Literals`` = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs index a076bb42327..be59b17509b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs @@ -4,7 +4,7 @@ namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit open FSharp.Test.Compiler -open FSharp.Test.Compiler.Assertions.ExactResultAsserts +open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts module ``Unsupported Attributes`` = diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 0a034fa154a..05958fb5533 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -17,8 +17,6 @@ module ScriptRunner = scriptingEnv.Eval """let exit (code:int) = if code=0 then () else failwith $"Script called function 'exit' with code={code}" """ |> ignore scriptingEnv - //let private getOrCreateEngine = createEngine//Tables.memoize createEngine - let defaultDefines = [ #if NETCOREAPP @@ -43,38 +41,11 @@ module ScriptRunner = | _ -> failwith $"Compilation unit other than fsharp is not supported, cannot process %A{cu}" -module DiagnosticsComparison = - open FSharp.Compiler.Text.Range - - let messageAndNumber erroryType = - match erroryType with - | ErrorType.Error n -> "error",n - | ErrorType.Warning n-> "warning",n - | ErrorType.Hidden n - | ErrorType.Information n-> "info",n - - let renderToString (cr:CompilationResult) = - [ for (file,err) in cr.Output.PerFileErrors do - let m = err.NativeRange - let file = file.Replace("/", "\\") - - let severity,no = messageAndNumber err.Error - - let location = - if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then - "" - else - sprintf "%s(%d,%d,%d,%d): " file m.StartLine m.StartColumn m.EndLine m.EndColumn - - $"{location} typecheck {severity} FS%04d{no}: {err.Message}" - - ] - - - /// This test file was created by porting over (slower) FsharpSuite.Tests /// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions module TestFrameworkAdapter = + open FSharp.Test.Compiler.Assertions.TextBasedDiagnosticAsserts + type ExecutionMode = | FSC_DEBUG | FSC_OPTIMIZED @@ -85,13 +56,19 @@ module TestFrameworkAdapter = let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath let inline testConfig (relativeFolder:string) = relativeFolder - let diffNegativeBaseline (cr:CompilationUnit) absFolder testName = + let diffNegativeBaseline (cr:CompilationUnit) absFolder testName version = let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") - [ for f in expectedFiles do - match Path.GetExtension(f) with - | "bsl" -> cr |> typecheck |> shouldFail - | "vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"] |> typecheck |> shouldFail - | _ -> () ] + let baselines = + [ for f in expectedFiles do + match Path.GetExtension(f) with + | ".bsl" -> cr, f + | ".vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"], f + | _ -> () ] + [ for compilationUnit,baseline in baselines do + compilationUnit + |> withOptions ["--warnaserror+"] + |> ScriptRunner.runScriptFile version + |> withResultsMatchingFile baseline ] |> List.head @@ -107,6 +84,10 @@ module TestFrameworkAdapter = let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion = let absFolder = Path.Combine(baseFolder,folder) + let supportedNames = + match mode with + | NEG_TEST_BUILD testName -> supportedNames.Add(testName+".fsx") + | _ -> supportedNames let files = Directory.GetFiles(absFolder,"test*.fs*") let mainFile,otherFiles = @@ -160,7 +141,7 @@ module TestFrameworkAdapter = |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed - | NEG_TEST_BUILD testName -> diffNegativeBaseline cu absFolder testName + | NEG_TEST_BUILD testName -> diffNegativeBaseline cu absFolder testName langVersion |> ignore @@ -256,7 +237,7 @@ module CoreTests = [] let ``auto-widen-version-preview-default-warns``() = let cfg = testConfig "core/auto-widen/preview-default-warns" - singleVersionedNegTestAux cfg ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" + singleVersionedNegTestAux cfg ["--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" [] let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index bae9ca25d63..a883f9e686d 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -225,8 +225,12 @@ module rec Compiler = let toErrorInfo (e: FSharpDiagnostic) : SourceCodeFileName * ErrorInfo = let errorNumber = e.ErrorNumber let severity = e.Severity - - let error = if severity = FSharpDiagnosticSeverity.Warning then Warning errorNumber else Error errorNumber + let error = + match severity with + | FSharpDiagnosticSeverity.Warning -> Warning errorNumber + | FSharpDiagnosticSeverity.Error -> Error errorNumber + | FSharpDiagnosticSeverity.Info -> Information errorNumber + | FSharpDiagnosticSeverity.Hidden -> Hidden errorNumber e.FileName |> Path.GetFileName, { Error = error @@ -1263,7 +1267,7 @@ module rec Compiler = let withError (expectedError: ErrorInfo) (result: CompilationResult) : CompilationResult = withErrors [expectedError] result - module ExactResultAsserts = + module StructuredResultsAsserts = type SimpleErrorInfo = { Error: ErrorType Range: Range @@ -1276,6 +1280,41 @@ module rec Compiler = let withResult (expectedResult: SimpleErrorInfo ) (result: CompilationResult) : CompilationResult = withResults [expectedResult] result + + + module TextBasedDiagnosticAsserts = + open FSharp.Compiler.Text.Range + + let private messageAndNumber erroryType = + match erroryType with + | ErrorType.Error n -> "error",n + | ErrorType.Warning n-> "warning",n + | ErrorType.Hidden n + | ErrorType.Information n-> "info",n + + let private renderToString (cr:CompilationResult) = + [ for (file,err) in cr.Output.PerFileErrors do + let m = err.NativeRange + let file = file.Replace("/", "\\") + let severity,no = messageAndNumber err.Error + let adjustedMessage = err.Message.Replace("\r\n","\n").Replace("\n","\r\n") + let location = + if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then + "" + else + // The baseline .bsl files use 1-based notation for columns, hence the +1's + sprintf "%s(%d,%d,%d,%d):" file m.StartLine (m.StartColumn+1) m.EndLine (m.EndColumn+1) + Environment.NewLine + $"{location} typecheck {severity} FS%04d{no}: {adjustedMessage}" + Environment.NewLine + ] + |> String.Concat + + let withResultsMatchingFile (path:string) (result:CompilationResult) = + let expectedContent = File.ReadAllText(path) + let actualErrors = renderToString result + Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip) + result + + let checkCodes (expected: int list) (selector: CompilationOutput -> ErrorInfo list) (result: CompilationResult) : CompilationResult = match result with | CompilationResult.Success r From d4992900d0683b7dd39037c8931941c3043afa7e Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 26 Jan 2023 12:18:57 +0100 Subject: [PATCH 09/19] TEST_UPDATE_BSL support --- tests/FSharp.Test.Utilities/Assert.fs | 40 ++++++++++++++++ tests/FSharp.Test.Utilities/Compiler.fs | 13 ++++-- tests/FSharp.Test.Utilities/SurfaceArea.fs | 46 +------------------ tests/fsharp/core/auto-widen/5.0/test.bsl | 17 +------ .../auto-widen/preview-default-warns/test.bsl | 4 -- 5 files changed, 53 insertions(+), 67 deletions(-) diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index 41af78c735d..dfed4bf123e 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -3,6 +3,8 @@ namespace FSharp.Test module Assert = open FluentAssertions open System.Collections + open System.Text + open System.IO let inline shouldBeEqualWith (expected : ^T) (message: string) (actual: ^U) = actual.Should().BeEquivalentTo(expected, message) |> ignore @@ -24,3 +26,41 @@ module Assert = let shouldBeTrue (actual: bool) = actual.Should().BeTrue("") |> ignore + + let shouldBeSameMultilineStringSets expectedText actualText = + + let getLines text = + use reader = new StringReader(text) + Seq.initInfinite (fun _ -> reader.ReadLine()) + |> Seq.takeWhile (not << isNull) + |> set + let actual = getLines actualText + let expected = getLines expectedText + + let unexpectedlyMissing = Set.difference expected actual + let unexpectedlyPresent = Set.difference actual expected + + // If both sets are empty, the surface areas match so allow the test to pass. + if Set.isEmpty unexpectedlyMissing + && Set.isEmpty unexpectedlyPresent then + None + else + let msg = + let inline newLine (sb : System.Text.StringBuilder) = sb.AppendLine () |> ignore + let sb = System.Text.StringBuilder () + sb.Append "Unexpectedly missing (expected, not actual):" |> ignore + for s in unexpectedlyMissing do + newLine sb + sb.Append " " |> ignore + sb.Append s |> ignore + newLine sb + newLine sb + sb.Append "Unexpectedly present (actual, not expected):" |> ignore + for s in unexpectedlyPresent do + newLine sb + sb.Append " " |> ignore + sb.Append s |> ignore + newLine sb + sb.ToString () + + Some msg diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index a883f9e686d..bab16ce5ee0 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1310,10 +1310,17 @@ module rec Compiler = let withResultsMatchingFile (path:string) (result:CompilationResult) = let expectedContent = File.ReadAllText(path) - let actualErrors = renderToString result - Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip) - result + let actualErrors = renderToString result + + match Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") with + | null -> () + | _ -> File.WriteAllText(path, actualErrors) + match Assert.shouldBeSameMultilineStringSets expectedContent actualErrors with + | None -> Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip) + | Some diff -> Assert.That(diff, Is.Empty) + + result let checkCodes (expected: int list) (selector: CompilationOutput -> ErrorInfo list) (result: CompilationResult) : CompilationResult = match result with diff --git a/tests/FSharp.Test.Utilities/SurfaceArea.fs b/tests/FSharp.Test.Utilities/SurfaceArea.fs index ca3a3570d16..8dcd2b92970 100644 --- a/tests/FSharp.Test.Utilities/SurfaceArea.fs +++ b/tests/FSharp.Test.Utilities/SurfaceArea.fs @@ -4,49 +4,7 @@ module FSharp.Test.SurfaceArea open System open System.IO open System.Reflection - open System.Text.RegularExpressions - - let private assembleDiffMessage actual expected = - - let getLines text = - use reader = new StringReader(text) - Seq.initInfinite (fun _ -> reader.ReadLine()) - |> Seq.takeWhile (not << isNull) - |> set - let actual = getLines actual - let expected = getLines expected - - /// Surface area types/members which were expected to be found but missing from the actual surface area. - let unexpectedlyMissing = Set.difference expected actual - - /// Surface area types/members present in the actual surface area but weren't expected to be. - let unexpectedlyPresent = Set.difference actual expected - - // If both sets are empty, the surface areas match so allow the test to pass. - if Set.isEmpty unexpectedlyMissing - && Set.isEmpty unexpectedlyPresent then - None - else - // The surface areas don't match; prepare an easily-readable output message. - let msg = - let inline newLine (sb : System.Text.StringBuilder) = sb.AppendLine () |> ignore - let sb = System.Text.StringBuilder () - sb.Append "Unexpectedly missing (expected, not actual):" |> ignore - for s in unexpectedlyMissing do - newLine sb - sb.Append " " |> ignore - sb.Append s |> ignore - newLine sb - newLine sb - sb.Append "Unexpectedly present (actual, not expected):" |> ignore - for s in unexpectedlyPresent do - newLine sb - sb.Append " " |> ignore - sb.Append s |> ignore - newLine sb - sb.ToString () - - Some msg + open System.Text.RegularExpressions // Gets string form of public surface area for the currently-loaded assembly let private getSurfaceAreaForAssembly (assembly: Assembly) = @@ -109,7 +67,7 @@ module FSharp.Test.SurfaceArea File.WriteAllText(logFile, actual) - match assembleDiffMessage expected actual with + match Assert.shouldBeSameMultilineStringSets expected actual with | None -> () | Some diff -> // Update baselines here diff --git a/tests/fsharp/core/auto-widen/5.0/test.bsl b/tests/fsharp/core/auto-widen/5.0/test.bsl index d5b3e596509..0c91e40c599 100644 --- a/tests/fsharp/core/auto-widen/5.0/test.bsl +++ b/tests/fsharp/core/auto-widen/5.0/test.bsl @@ -139,25 +139,10 @@ test.fsx(67,20,67,23): typecheck error FS0001: This expression was expected to h but here has type 'int' -test.fsx(67,20,67,23): typecheck error FS0001: This expression was expected to have type - 'obj' -but here has type - 'int' - -test.fsx(68,22,68,25): typecheck error FS0001: This expression was expected to have type - 'int64' -but here has type - 'int' - test.fsx(68,22,68,25): typecheck error FS0001: This expression was expected to have type 'int64' but here has type - 'int' - -test.fsx(69,26,69,29): typecheck error FS0001: This expression was expected to have type - 'int64' -but here has type - 'int' + 'int' test.fsx(69,26,69,29): typecheck error FS0001: This expression was expected to have type 'int64' diff --git a/tests/fsharp/core/auto-widen/preview-default-warns/test.bsl b/tests/fsharp/core/auto-widen/preview-default-warns/test.bsl index fc365207280..0e6a2d51844 100644 --- a/tests/fsharp/core/auto-widen/preview-default-warns/test.bsl +++ b/tests/fsharp/core/auto-widen/preview-default-warns/test.bsl @@ -18,10 +18,6 @@ but here has type test.fsx(471,18,471,19): typecheck error FS0044: This construct is deprecated. nope -test.fsx(482,18,482,21): typecheck error FS3387: This expression has type 'B' and is only made compatible with type 'C' through an ambiguous implicit conversion. Consider using an explicit call to 'op_Implicit'. The applicable implicit conversions are: - static member B.op_Implicit: x: B -> C - static member C.op_Implicit: x: B -> C - test.fsx(482,18,482,21): typecheck error FS3387: This expression has type 'B' and is only made compatible with type 'C' through an ambiguous implicit conversion. Consider using an explicit call to 'op_Implicit'. The applicable implicit conversions are: static member B.op_Implicit: x: B -> C static member C.op_Implicit: x: B -> C From fe2ad0b42910e8bf6b38056e5d2dd55c84f615f5 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 26 Jan 2023 12:23:39 +0100 Subject: [PATCH 10/19] Removing wrong duplicate definitions from old .bsl files --- tests/FSharp.Test.Utilities/Compiler.fs | 1 + tests/fsharp/core/auto-widen/5.0/test.bsl | 7 +--- tests/fsharp/core/auto-widen/preview/test.bsl | 38 ------------------- 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index bab16ce5ee0..089bafc03ee 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1314,6 +1314,7 @@ module rec Compiler = match Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") with | null -> () + | _ when expectedContent = actualErrors -> () | _ -> File.WriteAllText(path, actualErrors) match Assert.shouldBeSameMultilineStringSets expectedContent actualErrors with diff --git a/tests/fsharp/core/auto-widen/5.0/test.bsl b/tests/fsharp/core/auto-widen/5.0/test.bsl index 0c91e40c599..f16d2696867 100644 --- a/tests/fsharp/core/auto-widen/5.0/test.bsl +++ b/tests/fsharp/core/auto-widen/5.0/test.bsl @@ -142,7 +142,7 @@ but here has type test.fsx(68,22,68,25): typecheck error FS0001: This expression was expected to have type 'int64' but here has type - 'int' + 'int' test.fsx(69,26,69,29): typecheck error FS0001: This expression was expected to have type 'int64' @@ -558,11 +558,6 @@ test.fsx(291,21,291,30): typecheck error FS0001: This expression was expected to but here has type 'string' -test.fsx(291,21,291,30): typecheck error FS0001: This expression was expected to have type - 'obj' -but here has type - 'string' - test.fsx(292,24,292,26): typecheck error FS0001: This expression was expected to have type 'obj' but here has type diff --git a/tests/fsharp/core/auto-widen/preview/test.bsl b/tests/fsharp/core/auto-widen/preview/test.bsl index f449e09a610..24fa4a641cd 100644 --- a/tests/fsharp/core/auto-widen/preview/test.bsl +++ b/tests/fsharp/core/auto-widen/preview/test.bsl @@ -79,12 +79,6 @@ test.fsx(64,50,64,71): typecheck error FS3388: This expression implicitly conver test.fsx(67,20,67,23): typecheck error FS3388: This expression implicitly converts type 'int' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(67,20,67,23): typecheck error FS3388: This expression implicitly converts type 'int' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. - -test.fsx(68,22,68,25): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - -test.fsx(68,22,68,25): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(68,22,68,25): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. test.fsx(68,22,68,25): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. @@ -93,26 +87,16 @@ test.fsx(69,26,69,29): typecheck error FS3389: This expression uses a built-in i test.fsx(69,26,69,29): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(69,26,69,29): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - -test.fsx(69,26,69,29): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - -test.fsx(93,18,93,19): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(93,18,93,19): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. test.fsx(99,20,99,21): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(99,20,99,21): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(116,20,116,21): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. test.fsx(116,20,116,21): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. test.fsx(121,19,121,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(121,19,121,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(122,19,122,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. test.fsx(122,19,122,20): typecheck error FS3388: This expression implicitly converts type 'int' to type 'int64'. See https://aka.ms/fsharp-implicit-convs. @@ -123,8 +107,6 @@ test.fsx(122,22,122,23): typecheck error FS3388: This expression implicitly conv test.fsx(127,19,127,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'double'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(127,19,127,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'double'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(128,19,128,20): typecheck error FS3389: This expression uses a built-in implicit conversion to convert type 'int' to type 'double'. See https://aka.ms/fsharp-implicit-convs. test.fsx(128,19,128,20): typecheck error FS3388: This expression implicitly converts type 'int' to type 'double'. See https://aka.ms/fsharp-implicit-convs. @@ -167,8 +149,6 @@ test.fsx(165,18,165,19): typecheck error FS3388: This expression implicitly conv test.fsx(172,18,172,21): typecheck error FS3395: This expression uses the implicit conversion 'static member Y.op_Implicit: y: Y -> X' to convert type 'Y' to type 'X'. -test.fsx(172,18,172,21): typecheck error FS3395: This expression uses the implicit conversion 'static member Y.op_Implicit: y: Y -> X' to convert type 'Y' to type 'X'. - test.fsx(178,20,178,21): typecheck error FS3391: This expression uses the implicit conversion 'static member C.op_Implicit: x: 'T -> C<'T>' to convert type 'int' to type 'C'. See https://aka.ms/fsharp-implicit-convs. This warning may be disabled using '#nowarn "3391". test.fsx(178,20,178,21): typecheck error FS3388: This expression implicitly converts type 'int' to type 'C'. See https://aka.ms/fsharp-implicit-convs. @@ -233,16 +213,12 @@ test.fsx(216,34,216,35): typecheck error FS3388: This expression implicitly conv test.fsx(219,20,219,33): typecheck error FS3388: This expression implicitly converts type 'U' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(219,20,219,33): typecheck error FS3388: This expression implicitly converts type 'U' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(222,21,222,31): typecheck error FS3388: This expression implicitly converts type 'U' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. test.fsx(225,21,225,31): typecheck error FS3388: This expression implicitly converts type 'int -> U' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. test.fsx(228,21,228,40): typecheck error FS3388: This expression implicitly converts type 'SU' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(228,21,228,40): typecheck error FS3388: This expression implicitly converts type 'SU' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(231,21,231,37): typecheck error FS3388: This expression implicitly converts type 'SU' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. test.fsx(234,21,234,37): typecheck error FS3388: This expression implicitly converts type 'int -> SU' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. @@ -317,8 +293,6 @@ test.fsx(290,21,290,23): typecheck error FS3388: This expression implicitly conv test.fsx(291,21,291,30): typecheck error FS3388: This expression implicitly converts type 'string' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. -test.fsx(291,21,291,30): typecheck error FS3388: This expression implicitly converts type 'string' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. - test.fsx(292,24,292,26): typecheck error FS3388: This expression implicitly converts type 'string' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. test.fsx(295,34,295,35): typecheck error FS3388: This expression implicitly converts type 'int' to type 'obj'. See https://aka.ms/fsharp-implicit-convs. @@ -604,22 +578,10 @@ test.fsx(482,18,482,21): typecheck error FS3387: This expression has type 'B' an test.fsx(482,18,482,21): typecheck error FS3395: This expression uses the implicit conversion 'static member B.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. -test.fsx(482,18,482,21): typecheck error FS3387: This expression has type 'B' and is only made compatible with type 'C' through an ambiguous implicit conversion. Consider using an explicit call to 'op_Implicit'. The applicable implicit conversions are: - static member B.op_Implicit: x: B -> C - static member C.op_Implicit: x: B -> C - -test.fsx(482,18,482,21): typecheck error FS3395: This expression uses the implicit conversion 'static member B.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. - -test.fsx(507,18,507,21): typecheck error FS3395: This expression uses the implicit conversion 'static member C.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. - test.fsx(507,18,507,21): typecheck error FS3395: This expression uses the implicit conversion 'static member C.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. test.fsx(519,18,519,21): typecheck error FS3395: This expression uses the implicit conversion 'static member B.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. -test.fsx(519,18,519,21): typecheck error FS3395: This expression uses the implicit conversion 'static member B.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. - -test.fsx(538,18,538,21): typecheck error FS3395: This expression uses the implicit conversion 'static member C.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. - test.fsx(538,18,538,21): typecheck error FS3395: This expression uses the implicit conversion 'static member C.op_Implicit: x: B -> C' to convert type 'B' to type 'C'. test.fsx(543,30,543,31): typecheck error FS0001: This expression was expected to have type From 3b638f6adf889897b0626b32b6fcf135b9047545 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 26 Jan 2023 13:44:21 +0100 Subject: [PATCH 11/19] Putting stderr output of .fsx tests into test output window --- .../Miscellaneous/FsharpSuiteMigrated.fs | 36 ++++++++++--------- tests/fsharp/core/printf/test.fsx | 3 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 05958fb5533..baed0ce6e3c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -9,12 +9,22 @@ open FSharp.Test open FSharp.Test.Compiler open FSharp.Test.ScriptHelpers + + module ScriptRunner = open Internal.Utilities.Library let private createEngine(args,version) = let scriptingEnv = getSessionForEval args version - scriptingEnv.Eval """let exit (code:int) = if code=0 then () else failwith $"Script called function 'exit' with code={code}" """ |> ignore + scriptingEnv.Eval """ +let errorStringWriter = new System.IO.StringWriter() +let oldConsoleError = System.Console.Error +System.Console.SetError(errorStringWriter) +let exit (code:int) = + System.Console.SetError(oldConsoleError) + if code=0 then + () + else failwith $"Script called function 'exit' with code={code} and collected in stderr: {errorStringWriter.ToString()}" """ |> ignore scriptingEnv let defaultDefines = @@ -500,17 +510,15 @@ module CoreTests = [] let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI - // This test stays in FsharpSuite for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside -#if NETCOREAPP - [] + // This test stays in FsharpSuite for desktop framework for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside + [] let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG - [] + [] let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED - [] + [] let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI -#endif [] let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG @@ -521,20 +529,18 @@ module CoreTests = [] let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI -#if NETCOREAPP // This test has hardcoded expectations about current synchronization context -// Will be moved out of FsharpSuite.Tests in a later phase - [] +// Will be moved out of FsharpSuite.Tests in a later phase for desktop framework + [] let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED - [] + [] let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI - [] + [] let ``control --tailcalls`` () = let cfg = testConfig "core/control" singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED -#endif [] let ``controlChamenos-FSC_OPTIMIZED`` () = @@ -585,10 +591,8 @@ module CoreTests = let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED LangVersion.Preview // This requires --multiemit on by default, which is not the case for .NET Framework -#if NETCOREAPP - [] + [] let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI -#endif [] let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED diff --git a/tests/fsharp/core/printf/test.fsx b/tests/fsharp/core/printf/test.fsx index 8ea722c9ee4..cf78d1a8cbd 100644 --- a/tests/fsharp/core/printf/test.fsx +++ b/tests/fsharp/core/printf/test.fsx @@ -447,8 +447,9 @@ module CheckDisplayAttributes12 = member internal x.Hello = "Hello" override x.ToString() = "x" + let tName = typeof.FullName // this should produce an error - test "cenwoiwe12" (lazy(sprintf "%A" (Foo()))) "" + test "cenwoiwe12" (lazy(sprintf "%A" (Foo()))) ("") // Check one with an unmatched closing bracket module CheckDisplayAttributes13 = From 34e26e9d1df813015f9a7b714cfb75f66eb695ea Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 26 Jan 2023 14:04:34 +0100 Subject: [PATCH 12/19] Overload resolution tests migrated over --- .../Miscellaneous/FsharpSuiteMigrated.fs | 81 +++++++++++++------ tests/fsharp/tests.fs | 2 +- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index baed0ce6e3c..b634ec4afc8 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -63,8 +63,7 @@ module TestFrameworkAdapter = | COMPILED_EXE_APP | NEG_TEST_BUILD of testName:string - let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath - let inline testConfig (relativeFolder:string) = relativeFolder + let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath let diffNegativeBaseline (cr:CompilationUnit) absFolder testName version = let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") @@ -94,12 +93,14 @@ module TestFrameworkAdapter = let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion = let absFolder = Path.Combine(baseFolder,folder) - let supportedNames = + let supportedNames, files = match mode with - | NEG_TEST_BUILD testName -> supportedNames.Add(testName+".fsx") - | _ -> supportedNames + | NEG_TEST_BUILD testName -> + let nameSet = supportedNames.Add(testName+".fsx") + let files = Directory.GetFiles(absFolder,"*.fs*") |> Array.filter(fun n -> nameSet.Contains(Path.GetFileName(n))) + nameSet, files + | _ -> supportedNames, Directory.GetFiles(absFolder,"test*.fs*") - let files = Directory.GetFiles(absFolder,"test*.fs*") let mainFile,otherFiles = match files.Length with | 0 -> Directory.GetFiles(absFolder,"*.ml") |> Array.exactlyOne, [||] @@ -164,6 +165,7 @@ module TestFrameworkAdapter = singleTestBuildAndRunAuxVersion folder bonusArgs (NEG_TEST_BUILD testName) version let singleVersionedNegTest (folder:string) (version:LangVersion) (testName:string) = singleVersionedNegTestAux folder [] version testName + let singleNegTest folder testName = singleVersionedNegTest folder LangVersion.Latest testName @@ -212,24 +214,20 @@ module CoreTests = let ``array-no-dot-FSI`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSI LangVersion.Preview [] - let ``array-no-dot-warnings-langversion-default`` () = - let cfg = testConfig "core/array-no-dot-warnings" - singleVersionedNegTest cfg LangVersion.Latest "test-langversion-default" + let ``array-no-dot-warnings-langversion-default`` () = + singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.Latest "test-langversion-default" [] - let ``array-no-dot-warnings-langversion-5_0`` () = - let cfg = testConfig "core/array-no-dot-warnings" - singleVersionedNegTest cfg LangVersion.V50 "test-langversion-5.0" + let ``array-no-dot-warnings-langversion-5_0`` () = + singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.V50 "test-langversion-5.0" [] let ``ref-ops-deprecation-langversion-preview`` () = - let cfg = testConfig "core/ref-ops-deprecation" - singleVersionedNegTest cfg LangVersion.Preview "test-langversion-preview" + singleVersionedNegTest "core/ref-ops-deprecation" LangVersion.Preview "test-langversion-preview" [] let ``auto-widen-version-5_0``() = - let cfg = testConfig "core/auto-widen/5.0" - singleVersionedNegTest cfg LangVersion.V50 "test" + singleVersionedNegTest "core/auto-widen/5.0" LangVersion.V50 "test" [] let ``auto-widen-version-FSC_DEBUG-preview``() = @@ -241,13 +239,11 @@ module CoreTests = [] let ``auto-widen-version-preview-warns-on``() = - let cfg = testConfig "core/auto-widen/preview" - singleVersionedNegTestAux cfg ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" + singleVersionedNegTestAux "core/auto-widen/preview" ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" [] let ``auto-widen-version-preview-default-warns``() = - let cfg = testConfig "core/auto-widen/preview-default-warns" - singleVersionedNegTestAux cfg ["--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" + singleVersionedNegTestAux "core/auto-widen/preview-default-warns" ["--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" [] let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG @@ -539,17 +535,17 @@ module CoreTests = [] let ``control --tailcalls`` () = - let cfg = testConfig "core/control" + let cfg = "core/control" singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED [] let ``controlChamenos-FSC_OPTIMIZED`` () = - let cfg = testConfig "core/controlChamenos" + let cfg = "core/controlChamenos" singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED [] let ``controlChamenos-FSI`` () = - let cfg = testConfig "core/controlChamenos" + let cfg = "core/controlChamenos" singleTestBuildAndRunAux cfg ["--tailcalls"] FSI [] @@ -560,7 +556,7 @@ module CoreTests = [] let ``controlMailbox --tailcalls`` () = - let cfg = testConfig "core/controlMailbox" + let cfg = "core/controlMailbox" singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED [] @@ -618,4 +614,39 @@ module CoreTests = [] let ``pinvoke-FSI`` () = if isWindows then - singleTestBuildAndRun "core/pinvoke" FSI \ No newline at end of file + singleTestBuildAndRun "core/pinvoke" FSI + + +module OverloadResolution = + open TestFrameworkAdapter + module ``fsharpqa migrated tests`` = + let [] ``Conformance\Expressions\SyntacticSugar (E_Slices01_fs)`` () = singleNegTest ( "conformance/expressions/syntacticsugar") "E_Slices01" + let [] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03_fsx)`` () = singleNegTest ( "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03" + let [] ``Conformance\Inference (E_OneTypeVariable03_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03" + let [] ``Conformance\Inference (E_OneTypeVariable03rec_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03rec" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01rec" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00rec" + let [] ``Conformance\Inference (E_TwoEqualTypeVariables02_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualTypeVariables02" + let [] ``Conformance\Inference (E_TwoEqualYypeVariables02rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualYypeVariables02rec" + let [] ``Conformance\Inference (E_LeftToRightOverloadResolution01_fs)`` () = singleNegTest ( "conformance/inference") "E_LeftToRightOverloadResolution01" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04" + // note: this test still exist in fsharpqa to assert the compiler doesn't crash + // the part of the code generating a flaky error due to https://github.com/dotnet/fsharp/issues/6725 + // is elided here to focus on overload resolution error messages + let [] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001_fs)`` () = singleNegTest ( "conformance/lexicalanalysis") "E_LessThanDotOpenParen001" + + module ``error messages using BCL``= + let [] ``neg_System_Convert_ToString_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Convert.ToString.OverloadList" + let [] ``neg_System_Threading_Tasks_Task_Run_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Threading.Tasks.Task.Run.OverloadList" + let [] ``neg_System_Drawing_Graphics_DrawRectangleOverloadList_fsx``() = singleNegTest ( "typecheck/overloads") "neg_System.Drawing.Graphics.DrawRectangleOverloadList" + + module ``ad hoc code overload error messages``= + let [] ``neg_many_many_overloads`` () = singleNegTest ( "typecheck/overloads") "neg_many_many_overloads" + let [] ``neg_interface_generics`` () = singleNegTest ( "typecheck/overloads") "neg_interface_generics" + let [] ``neg_known_return_type_and_known_type_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_known_return_type_and_known_type_arguments" + let [] ``neg_generic_known_argument_types`` () = singleNegTest ( "typecheck/overloads") "neg_generic_known_argument_types" + let [] ``neg_tupled_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_tupled_arguments" \ No newline at end of file diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index 0bf7c78a363..f4a9cad2cef 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -3386,7 +3386,7 @@ namespace CST.RI.Anshun #if !NETCOREAPP [] -module OverloadResolution = +module OverloadResolution__MigratedAlready_FeelFreeToDelete = module ``fsharpqa migrated tests`` = let [] ``Conformance\Expressions\SyntacticSugar (E_Slices01_fs)`` () = singleNegTest (testConfig "conformance/expressions/syntacticsugar") "E_Slices01" let [] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03_fsx)`` () = singleNegTest (testConfig "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03" From 25dbb25fdd09bf84854b008d4d703ba4889dc512 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 26 Jan 2023 17:51:14 +0100 Subject: [PATCH 13/19] Separating migrated tests into files, removing them from old tests.fs --- .../FSharp.Compiler.ComponentTests.fsproj | 3 + .../Miscellaneous/FsharpSuiteMigrated.fs | 510 +-- .../Miscellaneous/MigratedCoreTests.fs | 473 ++ .../Miscellaneous/MigratedOverloadTests.fs | 38 + .../Miscellaneous/MigratedTypeCheckTests.fs | 501 +++ tests/FSharp.Test.Utilities/Compiler.fs | 20 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 7 +- tests/FSharp.Test.Utilities/ScriptHelpers.fs | 4 + tests/fsharp/tests.fs | 3821 +++++++---------- 9 files changed, 2506 insertions(+), 2871 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedCoreTests.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedOverloadTests.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedTypeCheckTests.fs diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index f057306176f..42a7ed9f867 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -211,6 +211,9 @@ + + + diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index b634ec4afc8..1ef1d1df2ad 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated +namespace FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated open System open System.IO @@ -65,7 +65,7 @@ module TestFrameworkAdapter = let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath - let diffNegativeBaseline (cr:CompilationUnit) absFolder testName version = + let diffNegativeBaseline (cr:CompilationUnit) absFolder testName _version = let expectedFiles = Directory.GetFiles(absFolder, testName + ".*") let baselines = [ for f in expectedFiles do @@ -74,9 +74,8 @@ module TestFrameworkAdapter = | ".vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"], f | _ -> () ] [ for compilationUnit,baseline in baselines do - compilationUnit - |> withOptions ["--warnaserror+"] - |> ScriptRunner.runScriptFile version + compilationUnit + |> typecheck |> withResultsMatchingFile baseline ] |> List.head @@ -85,6 +84,8 @@ module TestFrameworkAdapter = match version with | LangVersion.V47 -> "4.7",bonusArgs | LangVersion.V50 -> "5.0",bonusArgs + | LangVersion.V60 -> "6.0",bonusArgs + | LangVersion.V70 -> "7.0",bonusArgs | LangVersion.Preview -> "preview",bonusArgs | LangVersion.Latest -> "latest", bonusArgs | LangVersion.SupportsMl -> "5.0", "--mlcompatibility" :: bonusArgs @@ -96,7 +97,12 @@ module TestFrameworkAdapter = let supportedNames, files = match mode with | NEG_TEST_BUILD testName -> - let nameSet = supportedNames.Add(testName+".fsx") + let nameSet = + supportedNames + .Add(testName+".fsx") + .Add(testName+".fs") + .Add(testName+".fsi") + .Add(testName+"-pre.fs") let files = Directory.GetFiles(absFolder,"*.fs*") |> Array.filter(fun n -> nameSet.Contains(Path.GetFileName(n))) nameSet, files | _ -> supportedNames, Directory.GetFiles(absFolder,"test*.fs*") @@ -119,7 +125,7 @@ module TestFrameworkAdapter = FsFromPath mainFile |> withAdditionalSourceFiles [for f in otherFiles -> SourceFromPath f] - |> withLangVersion version + |> withLangVersion version |> fun cu -> match mode with | FSC_DEBUG | FSC_OPTIMIZED | FSI | COMPILED_EXE_APP -> @@ -128,7 +134,7 @@ module TestFrameworkAdapter = |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) | NEG_TEST_BUILD _ -> cu |> - withOptions (["--vserrors";"--maxerrors:10000"] @ bonusArgs) + withOptions (["--vserrors";"--maxerrors:10000";"--warnaserror";"--warn:3";"--nowarn:20;1178;52"] @ bonusArgs) |> fun cu -> match mode with | FSC_DEBUG -> @@ -152,7 +158,7 @@ module TestFrameworkAdapter = |> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines) |> compileExeAndRun |> shouldSucceed - | NEG_TEST_BUILD testName -> diffNegativeBaseline cu absFolder testName langVersion + | NEG_TEST_BUILD testName -> diffNegativeBaseline (cu |> withName mainFile) absFolder testName langVersion |> ignore @@ -165,488 +171,4 @@ module TestFrameworkAdapter = singleTestBuildAndRunAuxVersion folder bonusArgs (NEG_TEST_BUILD testName) version let singleVersionedNegTest (folder:string) (version:LangVersion) (testName:string) = singleVersionedNegTestAux folder [] version testName - let singleNegTest folder testName = singleVersionedNegTest folder LangVersion.Latest testName - - - -module CoreTests = - open TestFrameworkAdapter - - - // These tests are enabled for .NET Framework and .NET Core - [] - let ``access-FSC_DEBUG``() = singleTestBuildAndRun "core/access" FSC_DEBUG - - [] - let ``access-FSC_OPTIMIZED``() = singleTestBuildAndRun "core/access" FSC_OPTIMIZED - - [] - let ``access-FSI``() = singleTestBuildAndRun "core/access" FSI - - [] - let ``apporder-FSC_DEBUG`` () = singleTestBuildAndRun "core/apporder" FSC_DEBUG - - [] - let ``apporder-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/apporder" FSC_OPTIMIZED - - [] - let ``apporder-FSI`` () = singleTestBuildAndRun "core/apporder" FSI - - [] - let ``array-FSC_DEBUG-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_DEBUG LangVersion.V50 - - [] - let ``array-FSC_OPTIMIZED-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.V50 - - [] - let ``array-FSI-5.0`` () = singleTestBuildAndRunVersion "core/array" FSI LangVersion.V50 - - [] - let ``array-FSC_OPTIMIZED-preview`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.Preview - - [] - let ``array-no-dot-FSC_DEBUG`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_DEBUG LangVersion.Preview - - [] - let ``array-no-dot-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_OPTIMIZED LangVersion.Preview - - [] - let ``array-no-dot-FSI`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSI LangVersion.Preview - - [] - let ``array-no-dot-warnings-langversion-default`` () = - singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.Latest "test-langversion-default" - - [] - let ``array-no-dot-warnings-langversion-5_0`` () = - singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.V50 "test-langversion-5.0" - - [] - let ``ref-ops-deprecation-langversion-preview`` () = - singleVersionedNegTest "core/ref-ops-deprecation" LangVersion.Preview "test-langversion-preview" - - [] - let ``auto-widen-version-5_0``() = - singleVersionedNegTest "core/auto-widen/5.0" LangVersion.V50 "test" - - [] - let ``auto-widen-version-FSC_DEBUG-preview``() = - singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_DEBUG LangVersion.Preview - - [] - let ``auto-widen-version-FSC_OPTIMIZED-preview``() = - singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_OPTIMIZED LangVersion.Preview - - [] - let ``auto-widen-version-preview-warns-on``() = - singleVersionedNegTestAux "core/auto-widen/preview" ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" - - [] - let ``auto-widen-version-preview-default-warns``() = - singleVersionedNegTestAux "core/auto-widen/preview-default-warns" ["--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" - - [] - let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG - - [] - let ``comprehensions-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions" FSC_OPTIMIZED - - [] - let ``comprehensions-FSI`` () = singleTestBuildAndRun "core/comprehensions" FSI - - [] - let ``comprehensionshw-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_DEBUG - - [] - let ``comprehensionshw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_OPTIMIZED - - [] - let ``comprehensionshw-FSI`` () = singleTestBuildAndRun "core/comprehensions-hw" FSI - - [] - let ``genericmeasures-FSC_DEBUG`` () = singleTestBuildAndRun "core/genericmeasures" FSC_DEBUG - - [] - let ``genericmeasures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/genericmeasures" FSC_OPTIMIZED - - [] - let ``genericmeasures-FSI`` () = singleTestBuildAndRun "core/genericmeasures" FSI - - [] - let ``innerpoly-FSC_DEBUG`` () = singleTestBuildAndRun "core/innerpoly" FSC_DEBUG - - [] - let ``innerpoly-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/innerpoly" FSC_OPTIMIZED - - [] - let ``innerpoly-FSI`` () = singleTestBuildAndRun "core/innerpoly" FSI - - [] - let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP - - [] - let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP - - [] - let ``unicode2-FSC_DEBUG`` () = singleTestBuildAndRun "core/unicode" FSC_DEBUG // TODO: fails on coreclr - - [] - let ``unicode2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/unicode" FSC_OPTIMIZED // TODO: fails on coreclr - - [] - let ``unicode2-FSI`` () = singleTestBuildAndRun "core/unicode" FSI - - [] - let ``lazy test-FSC_DEBUG`` () = singleTestBuildAndRun "core/lazy" FSC_DEBUG - - [] - let ``lazy test-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lazy" FSC_OPTIMIZED - - [] - let ``lazy test-FSI`` () = singleTestBuildAndRun "core/lazy" FSI - - [] - let ``letrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec" FSC_DEBUG - - [] - let ``letrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec" FSC_OPTIMIZED - - [] - let ``letrec-FSI`` () = singleTestBuildAndRun "core/letrec" FSI - - [] - let ``letrec (mutrec variations part one) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_DEBUG - - [] - let ``letrec (mutrec variations part one) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_OPTIMIZED - - [] - let ``letrec (mutrec variations part one) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec" FSI - - [] - let ``libtest-FSC_DEBUG`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG - - [] - let ``libtest-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/libtest" FSC_OPTIMIZED - - [] - let ``libtest-FSI`` () = singleTestBuildAndRun "core/libtest" FSI - - [] - let ``lift-FSC_DEBUG`` () = singleTestBuildAndRun "core/lift" FSC_DEBUG - - [] - let ``lift-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lift" FSC_OPTIMIZED - - [] - let ``lift-FSI`` () = singleTestBuildAndRun "core/lift" FSI - - [] - let ``map-FSC_DEBUG`` () = singleTestBuildAndRun "core/map" FSC_DEBUG - - [] - let ``map-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/map" FSC_OPTIMIZED - - [] - let ``map-FSI`` () = singleTestBuildAndRun "core/map" FSI - - [] - let ``measures-FSC_DEBUG`` () = singleTestBuildAndRun "core/measures" FSC_DEBUG - - [] - let ``measures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/measures" FSC_OPTIMIZED - - [] - let ``measures-FSI`` () = singleTestBuildAndRun "core/measures" FSI - - [] - let ``nested-FSC_DEBUG`` () = singleTestBuildAndRun "core/nested" FSC_DEBUG - - [] - let ``nested-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/nested" FSC_OPTIMIZED - - [] - let ``nested-FSI`` () = singleTestBuildAndRun "core/nested" FSI - - [] - let ``members-ops-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops" FSC_OPTIMIZED - - [] - let ``members-ops-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops" FSC_DEBUG - - [] - let ``members-ops-FSI`` () = singleTestBuildAndRun "core/members/ops" FSI - - [] - let ``members-ops-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_DEBUG - - [] - let ``members-ops-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_OPTIMIZED - - [] - let ``members-ops-mutrec-FSI`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSI - - [] - let ``seq-FSC_DEBUG`` () = singleTestBuildAndRun "core/seq" FSC_DEBUG - - [] - let ``seq-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/seq" FSC_OPTIMIZED - - [] - let ``seq-FSI`` () = singleTestBuildAndRun "core/seq" FSI - - [] - let ``math-numbers-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbers" FSC_OPTIMIZED - - [] - let ``math-numbers-FSI`` () = singleTestBuildAndRun "core/math/numbers" FSI - - [] - let ``members-ctree-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ctree" FSC_DEBUG - - [] - let ``members-ctree-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ctree" FSC_OPTIMIZED - - [] - let ``members-ctree-FSI`` () = singleTestBuildAndRun "core/members/ctree" FSI - - [] - let ``members-factors-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors" FSC_DEBUG - - [] - let ``members-factors-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors" FSC_OPTIMIZED - - [] - let ``members-factors-FSI`` () = singleTestBuildAndRun "core/members/factors" FSI - - [] - let ``members-factors-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_DEBUG - - [] - let ``members-factors-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_OPTIMIZED - - [] - let ``members-factors-mutrec-FSI`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSI - - [] - let ``graph-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/graph" FSC_DEBUG LangVersion.SupportsMl - - [] - let ``graph-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/graph" FSC_OPTIMIZED LangVersion.SupportsMl - - [] - let ``graph-FSI`` () = singleTestBuildAndRunVersion "perf/graph" FSI LangVersion.SupportsMl - - [] - let ``nbody-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_DEBUG LangVersion.SupportsMl - - [] - let ``nbody-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_OPTIMIZED LangVersion.SupportsMl - - [] - let ``nbody-FSI`` () = singleTestBuildAndRunVersion "perf/nbody" FSI LangVersion.SupportsMl - - [] - let ``forexpression-FSC_DEBUG`` () = singleTestBuildAndRun "core/forexpression" FSC_DEBUG - - [] - let ``forexpression-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/forexpression" FSC_OPTIMIZED - - [] - let ``forexpression-FSI`` () = singleTestBuildAndRun "core/forexpression" FSI - - [] - let ``letrec (mutrec variations part two) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_DEBUG - - [] - let ``letrec (mutrec variations part two) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_OPTIMIZED - - [] - let ``letrec (mutrec variations part two) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSI - - [] - let ``printf`` () = singleTestBuildAndRunVersion "core/printf" FSC_OPTIMIZED LangVersion.Preview - - [] - let ``printf-interpolated`` () = singleTestBuildAndRunVersion "core/printf-interpolated" FSC_OPTIMIZED LangVersion.Preview - - [] - let ``tlr-FSC_DEBUG`` () = singleTestBuildAndRun "core/tlr" FSC_DEBUG - - [] - let ``tlr-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/tlr" FSC_OPTIMIZED - - [] - let ``tlr-FSI`` () = singleTestBuildAndRun "core/tlr" FSI - - [] - let ``subtype-FSC_DEBUG`` () = singleTestBuildAndRun "core/subtype" FSC_DEBUG - - [] - let ``subtype-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/subtype" FSC_OPTIMIZED - - [] - let ``subtype-FSI`` () = singleTestBuildAndRun "core/subtype" FSI - - [] - let ``syntax-FSC_DEBUG`` () = singleTestBuildAndRun "core/syntax" FSC_DEBUG - - [] - let ``syntax-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/syntax" FSC_OPTIMIZED - - [] - let ``syntax-FSI`` () = singleTestBuildAndRun "core/syntax" FSI - - [] - let ``test int32-FSC_DEBUG`` () = singleTestBuildAndRun "core/int32" FSC_DEBUG - - [] - let ``test int32-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/int32" FSC_OPTIMIZED - - [] - let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI - - // This test stays in FsharpSuite for desktop framework for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside - [] - let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG - - [] - let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED - - [] - let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI - - [] - let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG - - [] - let ``recordResolution-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/recordResolution" FSC_OPTIMIZED - - [] - let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI - -// This test has hardcoded expectations about current synchronization context -// Will be moved out of FsharpSuite.Tests in a later phase for desktop framework - [] - let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED - - [] - let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI - - [] - let ``control --tailcalls`` () = - let cfg = "core/control" - singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED - - [] - let ``controlChamenos-FSC_OPTIMIZED`` () = - let cfg = "core/controlChamenos" - singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED - - [] - let ``controlChamenos-FSI`` () = - let cfg = "core/controlChamenos" - singleTestBuildAndRunAux cfg ["--tailcalls"] FSI - - [] - let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED - - [] - let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI - - [] - let ``controlMailbox --tailcalls`` () = - let cfg = "core/controlMailbox" - singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED - - [] - let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED - - [] - let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI - - [] - let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED - - [] - let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI - - [] - let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED - - [] - let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI - - [] - let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED - - [] - let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI - - [] - let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED LangVersion.Preview - -// This requires --multiemit on by default, which is not the case for .NET Framework - [] - let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI - - [] - let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED - - [] - let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI - - [] - let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED - - [] - let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI - - module PInvokeTests = - open System.Runtime.InteropServices - let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - - [] - let ``pinvoke-FSC_OPTIMIZED`` () = - if isWindows then - singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED - - [] - let ``pinvoke-FSI`` () = - if isWindows then - singleTestBuildAndRun "core/pinvoke" FSI - - -module OverloadResolution = - open TestFrameworkAdapter - module ``fsharpqa migrated tests`` = - let [] ``Conformance\Expressions\SyntacticSugar (E_Slices01_fs)`` () = singleNegTest ( "conformance/expressions/syntacticsugar") "E_Slices01" - let [] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03_fsx)`` () = singleNegTest ( "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03" - let [] ``Conformance\Inference (E_OneTypeVariable03_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03" - let [] ``Conformance\Inference (E_OneTypeVariable03rec_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03rec" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01rec" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00rec" - let [] ``Conformance\Inference (E_TwoEqualTypeVariables02_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualTypeVariables02" - let [] ``Conformance\Inference (E_TwoEqualYypeVariables02rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualYypeVariables02rec" - let [] ``Conformance\Inference (E_LeftToRightOverloadResolution01_fs)`` () = singleNegTest ( "conformance/inference") "E_LeftToRightOverloadResolution01" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04" - // note: this test still exist in fsharpqa to assert the compiler doesn't crash - // the part of the code generating a flaky error due to https://github.com/dotnet/fsharp/issues/6725 - // is elided here to focus on overload resolution error messages - let [] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001_fs)`` () = singleNegTest ( "conformance/lexicalanalysis") "E_LessThanDotOpenParen001" - - module ``error messages using BCL``= - let [] ``neg_System_Convert_ToString_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Convert.ToString.OverloadList" - let [] ``neg_System_Threading_Tasks_Task_Run_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Threading.Tasks.Task.Run.OverloadList" - let [] ``neg_System_Drawing_Graphics_DrawRectangleOverloadList_fsx``() = singleNegTest ( "typecheck/overloads") "neg_System.Drawing.Graphics.DrawRectangleOverloadList" - - module ``ad hoc code overload error messages``= - let [] ``neg_many_many_overloads`` () = singleNegTest ( "typecheck/overloads") "neg_many_many_overloads" - let [] ``neg_interface_generics`` () = singleNegTest ( "typecheck/overloads") "neg_interface_generics" - let [] ``neg_known_return_type_and_known_type_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_known_return_type_and_known_type_arguments" - let [] ``neg_generic_known_argument_types`` () = singleNegTest ( "typecheck/overloads") "neg_generic_known_argument_types" - let [] ``neg_tupled_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_tupled_arguments" \ No newline at end of file + let singleNegTest folder testName = singleVersionedNegTest folder LangVersion.Latest testName \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedCoreTests.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedCoreTests.fs new file mode 100644 index 00000000000..562391f2b92 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedCoreTests.fs @@ -0,0 +1,473 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +module FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated.CoreTests + +open Xunit +open FSharp.Test +open FSharp.Test.ScriptHelpers +open TestFrameworkAdapter + + +// These tests are enabled for .NET Framework and .NET Core +[] +let ``access-FSC_DEBUG``() = singleTestBuildAndRun "core/access" FSC_DEBUG + +[] +let ``access-FSC_OPTIMIZED``() = singleTestBuildAndRun "core/access" FSC_OPTIMIZED + +[] +let ``access-FSI``() = singleTestBuildAndRun "core/access" FSI + +[] +let ``apporder-FSC_DEBUG`` () = singleTestBuildAndRun "core/apporder" FSC_DEBUG + +[] +let ``apporder-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/apporder" FSC_OPTIMIZED + +[] +let ``apporder-FSI`` () = singleTestBuildAndRun "core/apporder" FSI + +[] +let ``array-FSC_DEBUG-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_DEBUG LangVersion.V50 + +[] +let ``array-FSC_OPTIMIZED-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.V50 + +[] +let ``array-FSI-5.0`` () = singleTestBuildAndRunVersion "core/array" FSI LangVersion.V50 + +[] +let ``array-FSC_OPTIMIZED-preview`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED LangVersion.Preview + +[] +let ``array-no-dot-FSC_DEBUG`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_DEBUG LangVersion.Preview + +[] +let ``array-no-dot-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_OPTIMIZED LangVersion.Preview + +[] +let ``array-no-dot-FSI`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSI LangVersion.Preview + +[] +let ``array-no-dot-warnings-langversion-default`` () = + singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.Latest "test-langversion-default" + +[] +let ``array-no-dot-warnings-langversion-5_0`` () = + singleVersionedNegTest "core/array-no-dot-warnings" LangVersion.V50 "test-langversion-5.0" + +[] +let ``ref-ops-deprecation-langversion-preview`` () = + singleVersionedNegTest "core/ref-ops-deprecation" LangVersion.Preview "test-langversion-preview" + +[] +let ``auto-widen-version-5_0``() = + singleVersionedNegTest "core/auto-widen/5.0" LangVersion.V50 "test" + +[] +let ``auto-widen-version-FSC_DEBUG-preview``() = + singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_DEBUG LangVersion.Preview + +[] +let ``auto-widen-version-FSC_OPTIMIZED-preview``() = + singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_OPTIMIZED LangVersion.Preview + +[] +let ``auto-widen-version-preview-warns-on``() = + singleVersionedNegTestAux "core/auto-widen/preview" ["--warnon:3388";"--warnon:3389";"--warnon:3395";"--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" + +[] +let ``auto-widen-version-preview-default-warns``() = + singleVersionedNegTestAux "core/auto-widen/preview-default-warns" ["--warnaserror+";"--define:NEGATIVE"] LangVersion.Preview "test" + +[] +let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG + +[] +let ``comprehensions-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions" FSC_OPTIMIZED + +[] +let ``comprehensions-FSI`` () = singleTestBuildAndRun "core/comprehensions" FSI + +[] +let ``comprehensionshw-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_DEBUG + +[] +let ``comprehensionshw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_OPTIMIZED + +[] +let ``comprehensionshw-FSI`` () = singleTestBuildAndRun "core/comprehensions-hw" FSI + +[] +let ``genericmeasures-FSC_DEBUG`` () = singleTestBuildAndRun "core/genericmeasures" FSC_DEBUG + +[] +let ``genericmeasures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/genericmeasures" FSC_OPTIMIZED + +[] +let ``genericmeasures-FSI`` () = singleTestBuildAndRun "core/genericmeasures" FSI + +[] +let ``innerpoly-FSC_DEBUG`` () = singleTestBuildAndRun "core/innerpoly" FSC_DEBUG + +[] +let ``innerpoly-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/innerpoly" FSC_OPTIMIZED + +[] +let ``innerpoly-FSI`` () = singleTestBuildAndRun "core/innerpoly" FSI + +[] +let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP + +[] +let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" COMPILED_EXE_APP + +[] +let ``unicode2-FSC_DEBUG`` () = singleTestBuildAndRun "core/unicode" FSC_DEBUG // TODO: fails on coreclr + +[] +let ``unicode2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/unicode" FSC_OPTIMIZED // TODO: fails on coreclr + +[] +let ``unicode2-FSI`` () = singleTestBuildAndRun "core/unicode" FSI + +[] +let ``lazy test-FSC_DEBUG`` () = singleTestBuildAndRun "core/lazy" FSC_DEBUG + +[] +let ``lazy test-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lazy" FSC_OPTIMIZED + +[] +let ``lazy test-FSI`` () = singleTestBuildAndRun "core/lazy" FSI + +[] +let ``letrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec" FSC_DEBUG + +[] +let ``letrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec" FSC_OPTIMIZED + +[] +let ``letrec-FSI`` () = singleTestBuildAndRun "core/letrec" FSI + +[] +let ``letrec (mutrec variations part one) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_DEBUG + +[] +let ``letrec (mutrec variations part one) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_OPTIMIZED + +[] +let ``letrec (mutrec variations part one) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec" FSI + +[] +let ``libtest-FSC_DEBUG`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG + +[] +let ``libtest-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/libtest" FSC_OPTIMIZED + +[] +let ``libtest-FSI`` () = singleTestBuildAndRun "core/libtest" FSI + +[] +let ``lift-FSC_DEBUG`` () = singleTestBuildAndRun "core/lift" FSC_DEBUG + +[] +let ``lift-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lift" FSC_OPTIMIZED + +[] +let ``lift-FSI`` () = singleTestBuildAndRun "core/lift" FSI + +[] +let ``map-FSC_DEBUG`` () = singleTestBuildAndRun "core/map" FSC_DEBUG + +[] +let ``map-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/map" FSC_OPTIMIZED + +[] +let ``map-FSI`` () = singleTestBuildAndRun "core/map" FSI + +[] +let ``measures-FSC_DEBUG`` () = singleTestBuildAndRun "core/measures" FSC_DEBUG + +[] +let ``measures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/measures" FSC_OPTIMIZED + +[] +let ``measures-FSI`` () = singleTestBuildAndRun "core/measures" FSI + +[] +let ``nested-FSC_DEBUG`` () = singleTestBuildAndRun "core/nested" FSC_DEBUG + +[] +let ``nested-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/nested" FSC_OPTIMIZED + +[] +let ``nested-FSI`` () = singleTestBuildAndRun "core/nested" FSI + +[] +let ``members-basics-hw`` () = singleTestBuildAndRun "core/members/basics-hw" FSC_OPTIMIZED + +[] +let ``members-basics-hw-mutrec`` () = singleTestBuildAndRun "core/members/basics-hw-mutrec" FSC_OPTIMIZED + +[] +let ``members-incremental-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental" FSC_OPTIMIZED + +[] +let ``members-incremental-FSI`` () = singleTestBuildAndRun "core/members/incremental" FSI + +[] +let ``members-incremental-hw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental-hw" FSC_OPTIMIZED + +[] +let ``members-incremental-hw-FSI`` () = singleTestBuildAndRun "core/members/incremental-hw" FSI + +[] +let ``members-incremental-hw-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental-hw-mutrec" FSC_OPTIMIZED + +[] +let ``members-ops-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops" FSC_OPTIMIZED + +[] +let ``members-ops-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops" FSC_DEBUG + +[] +let ``members-ops-FSI`` () = singleTestBuildAndRun "core/members/ops" FSI + +[] +let ``members-ops-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_DEBUG + +[] +let ``members-ops-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_OPTIMIZED + +[] +let ``members-ops-mutrec-FSI`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSI + +[] +let ``seq-FSC_DEBUG`` () = singleTestBuildAndRun "core/seq" FSC_DEBUG + +[] +let ``seq-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/seq" FSC_OPTIMIZED + +[] +let ``seq-FSI`` () = singleTestBuildAndRun "core/seq" FSI + +[] +let ``math-numbers-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbers" FSC_OPTIMIZED + +[] +let ``math-numbers-FSI`` () = singleTestBuildAndRun "core/math/numbers" FSI + +[] +let ``members-ctree-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ctree" FSC_DEBUG + +[] +let ``members-ctree-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ctree" FSC_OPTIMIZED + +[] +let ``members-ctree-FSI`` () = singleTestBuildAndRun "core/members/ctree" FSI + +[] +let ``members-factors-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors" FSC_DEBUG + +[] +let ``members-factors-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors" FSC_OPTIMIZED + +[] +let ``members-factors-FSI`` () = singleTestBuildAndRun "core/members/factors" FSI + +[] +let ``members-factors-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_DEBUG + +[] +let ``members-factors-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_OPTIMIZED + +[] +let ``members-factors-mutrec-FSI`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSI + +[] +let ``graph-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/graph" FSC_DEBUG LangVersion.SupportsMl + +[] +let ``graph-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/graph" FSC_OPTIMIZED LangVersion.SupportsMl + +[] +let ``graph-FSI`` () = singleTestBuildAndRunVersion "perf/graph" FSI LangVersion.SupportsMl + +[] +let ``nbody-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_DEBUG LangVersion.SupportsMl + +[] +let ``nbody-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_OPTIMIZED LangVersion.SupportsMl + +[] +let ``nbody-FSI`` () = singleTestBuildAndRunVersion "perf/nbody" FSI LangVersion.SupportsMl + +[] +let ``forexpression-FSC_DEBUG`` () = singleTestBuildAndRun "core/forexpression" FSC_DEBUG + +[] +let ``forexpression-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/forexpression" FSC_OPTIMIZED + +[] +let ``forexpression-FSI`` () = singleTestBuildAndRun "core/forexpression" FSI + +[] +let ``letrec (mutrec variations part two) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_DEBUG + +[] +let ``letrec (mutrec variations part two) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_OPTIMIZED + +[] +let ``letrec (mutrec variations part two) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSI + +[] +let ``printf`` () = singleTestBuildAndRunVersion "core/printf" FSC_OPTIMIZED LangVersion.Preview + +[] +let ``printf-interpolated`` () = singleTestBuildAndRunVersion "core/printf-interpolated" FSC_OPTIMIZED LangVersion.Preview + +[] +let ``tlr-FSC_DEBUG`` () = singleTestBuildAndRun "core/tlr" FSC_DEBUG + +[] +let ``tlr-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/tlr" FSC_OPTIMIZED + +[] +let ``tlr-FSI`` () = singleTestBuildAndRun "core/tlr" FSI + +[] +let ``subtype-FSC_DEBUG`` () = singleTestBuildAndRun "core/subtype" FSC_DEBUG + +[] +let ``subtype-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/subtype" FSC_OPTIMIZED + +[] +let ``subtype-FSI`` () = singleTestBuildAndRun "core/subtype" FSI + +[] +let ``syntax-FSC_DEBUG`` () = singleTestBuildAndRun "core/syntax" FSC_DEBUG + +[] +let ``syntax-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/syntax" FSC_OPTIMIZED + +[] +let ``syntax-FSI`` () = singleTestBuildAndRun "core/syntax" FSI + +[] +let ``test int32-FSC_DEBUG`` () = singleTestBuildAndRun "core/int32" FSC_DEBUG + +[] +let ``test int32-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/int32" FSC_OPTIMIZED + +[] +let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI + +// This test stays in FsharpSuite for desktop framework for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside +[] +let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG + +[] +let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED + +[] +let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI + +[] +let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG + +[] +let ``recordResolution-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/recordResolution" FSC_OPTIMIZED + +[] +let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI + +// This test has hardcoded expectations about current synchronization context +// Will be moved out of FsharpSuite.Tests in a later phase for desktop framework +[] +let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED + +[] +let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI + +[] +let ``control --tailcalls`` () = + let cfg = "core/control" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + +[] +let ``controlChamenos-FSC_OPTIMIZED`` () = + let cfg = "core/controlChamenos" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + +[] +let ``controlChamenos-FSI`` () = + let cfg = "core/controlChamenos" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSI + +[] +let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED + +[] +let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI + +[] +let ``controlMailbox --tailcalls`` () = + let cfg = "core/controlMailbox" + singleTestBuildAndRunAux cfg ["--tailcalls"] FSC_OPTIMIZED + +[] +let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED + +[] +let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI + +[] +let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED + +[] +let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI + +[] +let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED + +[] +let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI + +[] +let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED + +[] +let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI + +[] +let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED LangVersion.Preview + +// This requires --multiemit on by default, which is not the case for .NET Framework +[] +let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI + +[] +let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED + +[] +let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI + +[] +let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED + +[] +let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI + +module PInvokeTests = + open System.Runtime.InteropServices + let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + + [] + let ``pinvoke-FSC_OPTIMIZED`` () = + if isWindows then + singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED + + [] + let ``pinvoke-FSI`` () = + if isWindows then + singleTestBuildAndRun "core/pinvoke" FSI \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedOverloadTests.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedOverloadTests.fs new file mode 100644 index 00000000000..55286a6a656 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedOverloadTests.fs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. +module FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated.OverloadResolution + +open Xunit +open FSharp.Test +open TestFrameworkAdapter + +module ``fsharpqa migrated tests`` = + let [] ``Conformance\Expressions\SyntacticSugar (E_Slices01_fs)`` () = singleNegTest ( "conformance/expressions/syntacticsugar") "E_Slices01" + let [] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03_fsx)`` () = singleNegTest ( "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03" + let [] ``Conformance\Inference (E_OneTypeVariable03_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03" + let [] ``Conformance\Inference (E_OneTypeVariable03rec_fs)`` () = singleNegTest ( "conformance/inference") "E_OneTypeVariable03rec" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariables01rec" + let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoDifferentTypeVariablesGen00rec" + let [] ``Conformance\Inference (E_TwoEqualTypeVariables02_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualTypeVariables02" + let [] ``Conformance\Inference (E_TwoEqualYypeVariables02rec_fs)`` () = singleNegTest ( "conformance/inference") "E_TwoEqualYypeVariables02rec" + let [] ``Conformance\Inference (E_LeftToRightOverloadResolution01_fs)`` () = singleNegTest ( "conformance/inference") "E_LeftToRightOverloadResolution01" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03" + let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04_fs)`` () = singleNegTest ( "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04" + // note: this test still exist in fsharpqa to assert the compiler doesn't crash + // the part of the code generating a flaky error due to https://github.com/dotnet/fsharp/issues/6725 + // is elided here to focus on overload resolution error messages + let [] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001_fs)`` () = singleNegTest ( "conformance/lexicalanalysis") "E_LessThanDotOpenParen001" + +module ``error messages using BCL``= + let [] ``neg_System_Convert_ToString_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Convert.ToString.OverloadList" + let [] ``neg_System_Threading_Tasks_Task_Run_OverloadList``() = singleNegTest ( "typecheck/overloads") "neg_System.Threading.Tasks.Task.Run.OverloadList" + let [] ``neg_System_Drawing_Graphics_DrawRectangleOverloadList_fsx``() = singleNegTest ( "typecheck/overloads") "neg_System.Drawing.Graphics.DrawRectangleOverloadList" + +module ``ad hoc code overload error messages``= + let [] ``neg_many_many_overloads`` () = singleNegTest ( "typecheck/overloads") "neg_many_many_overloads" + let [] ``neg_interface_generics`` () = singleNegTest ( "typecheck/overloads") "neg_interface_generics" + let [] ``neg_known_return_type_and_known_type_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_known_return_type_and_known_type_arguments" + let [] ``neg_generic_known_argument_types`` () = singleNegTest ( "typecheck/overloads") "neg_generic_known_argument_types" + let [] ``neg_tupled_arguments`` () = singleNegTest ( "typecheck/overloads") "neg_tupled_arguments" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedTypeCheckTests.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedTypeCheckTests.fs new file mode 100644 index 00000000000..09a287838b3 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/MigratedTypeCheckTests.fs @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. +module FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated.TypeCheckTests + +open Xunit +open FSharp.Test +open FSharp.Test.ScriptHelpers +open TestFrameworkAdapter + +[] +let misc () = singleTestBuildAndRunVersion "typecheck/misc" FSC_OPTIMIZED LangVersion.SupportsMl + +[] +let ``type check neg01`` () = singleNegTest ( "typecheck/sigs") "neg01" + +[] +let ``type check neg02`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.V60 "neg02" + +[] +let ``type check neg03`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.SupportsMl "neg03" + +[] +let ``type check neg04`` () = singleNegTest ( "typecheck/sigs") "neg04" + +[] +let ``type check neg05`` () = singleNegTest ( "typecheck/sigs") "neg05" + +[] +let ``type check neg06`` () = singleNegTest ( "typecheck/sigs") "neg06" + +[] +let ``type check neg06_a`` () = singleNegTest ( "typecheck/sigs") "neg06_a" + +[] +let ``type check neg06_b`` () = singleNegTest ( "typecheck/sigs") "neg06_b" + +[] +let ``type check neg07`` () = singleNegTest ( "typecheck/sigs") "neg07" + +[] +let ``type check neg08`` () = singleNegTest ( "typecheck/sigs") "neg08" + +[] +let ``type check neg09`` () = singleNegTest ( "typecheck/sigs") "neg09" + +[] +let ``type check neg10`` () = singleNegTest ( "typecheck/sigs") "neg10" + +[] +let ``type check neg10_a`` () = singleNegTest ( "typecheck/sigs") "neg10_a" + +[] +let ``type check neg11`` () = singleNegTest ( "typecheck/sigs") "neg11" + +[] +let ``type check neg12`` () = singleNegTest ( "typecheck/sigs") "neg12" + +[] +let ``type check neg13`` () = singleNegTest ( "typecheck/sigs") "neg13" + +[] +let ``type check neg14`` () = singleNegTest ( "typecheck/sigs") "neg14" + +[] +let ``type check neg15`` () = singleNegTest ( "typecheck/sigs") "neg15" + +[] +let ``type check neg16`` () = singleNegTest ( "typecheck/sigs") "neg16" + +[] +let ``type check neg17`` () = singleNegTest ( "typecheck/sigs") "neg17" + +[] +let ``type check neg18`` () = singleNegTest ( "typecheck/sigs") "neg18" + +[] +let ``type check neg19`` () = singleNegTest ( "typecheck/sigs") "neg19" + +[] +let ``type check neg20`` () = singleNegTest ( "typecheck/sigs") "neg20" + +[] +let ``type check neg20 version 5_0`` () = + let cfg = "typecheck/sigs/version50" + singleVersionedNegTest cfg LangVersion.V50 "neg20" + +[] +let ``type check neg21`` () = singleNegTest ( "typecheck/sigs") "neg21" + +[] +let ``type check neg23`` () = singleNegTest ( "typecheck/sigs") "neg23" + + +[] +let ``type check neg25`` () = singleNegTest ( "typecheck/sigs") "neg25" + +[] +let ``type check neg26`` () = singleNegTest ( "typecheck/sigs") "neg26" + +[] +let ``type check neg27`` () = singleNegTest ( "typecheck/sigs") "neg27" + +[] +let ``type check neg28`` () = singleNegTest ( "typecheck/sigs") "neg28" + +[] +let ``type check neg29`` () = singleNegTest ( "typecheck/sigs") "neg29" + +[] +let ``type check neg30`` () = singleNegTest ( "typecheck/sigs") "neg30" + +[] +let ``type check neg31`` () = singleNegTest ( "typecheck/sigs") "neg31" + +[] +let ``type check neg32`` () = singleNegTest ( "typecheck/sigs") "neg32" + +[] +let ``type check neg33`` () = singleNegTest ( "typecheck/sigs") "neg33" + +[] +let ``type check neg34`` () = singleNegTest ( "typecheck/sigs") "neg34" + +[] +let ``type check neg35`` () = singleNegTest ( "typecheck/sigs") "neg35" + +[] +let ``type check neg36`` () = singleNegTest ( "typecheck/sigs") "neg36" + +[] +let ``type check neg37`` () = singleNegTest ( "typecheck/sigs") "neg37" + +[] +let ``type check neg37_a`` () = singleNegTest ( "typecheck/sigs") "neg37_a" + +[] +let ``type check neg38`` () = singleNegTest ( "typecheck/sigs") "neg38" + +[] +let ``type check neg39`` () = singleNegTest ( "typecheck/sigs") "neg39" + +[] +let ``type check neg40`` () = singleNegTest ( "typecheck/sigs") "neg40" + +[] +let ``type check neg41`` () = singleNegTest ( "typecheck/sigs") "neg41" + +[] +let ``type check neg42`` () = singleNegTest ( "typecheck/sigs") "neg42" + +[] +let ``type check neg43`` () = singleNegTest ( "typecheck/sigs") "neg43" + +[] +let ``type check neg44`` () = singleNegTest ( "typecheck/sigs") "neg44" + +#if !DEBUG // requires release version of compiler to avoid very deep stacks +[] +let ``type check neg45`` () = singleNegTest ( "typecheck/sigs") "neg45" +#endif + +[] +let ``type check neg46`` () = singleNegTest ( "typecheck/sigs") "neg46" + +[] +let ``type check neg47`` () = singleNegTest ( "typecheck/sigs") "neg47" + +[] +let ``type check neg48`` () = singleNegTest ( "typecheck/sigs") "neg48" + +[] +let ``type check neg49`` () = singleNegTest ( "typecheck/sigs") "neg49" + +[] +let ``type check neg50`` () = singleNegTest ( "typecheck/sigs") "neg50" + +[] +let ``type check neg51`` () = singleNegTest ( "typecheck/sigs") "neg51" + +[] +let ``type check neg52`` () = singleNegTest ( "typecheck/sigs") "neg52" + +[] +let ``type check neg53`` () = singleNegTest ( "typecheck/sigs") "neg53" + +[] +let ``type check neg54`` () = singleNegTest ( "typecheck/sigs") "neg54" + +[] +let ``type check neg55`` () = singleNegTest ( "typecheck/sigs") "neg55" + +[] +let ``type check neg56`` () = singleNegTest ( "typecheck/sigs") "neg56" + +[] +let ``type check neg56_a`` () = singleNegTest ( "typecheck/sigs") "neg56_a" + +[] +let ``type check neg56_b`` () = singleNegTest ( "typecheck/sigs") "neg56_b" + +[] +let ``type check neg57`` () = singleNegTest ( "typecheck/sigs") "neg57" + +[] +let ``type check neg58`` () = singleNegTest ( "typecheck/sigs") "neg58" + +[] +let ``type check neg59`` () = singleNegTest ( "typecheck/sigs") "neg59" + +[] +let ``type check neg60`` () = singleNegTest ( "typecheck/sigs") "neg60" + +[] +let ``type check neg61`` () = singleNegTest ( "typecheck/sigs") "neg61" + +[] +let ``type check neg62`` () = singleNegTest ( "typecheck/sigs") "neg62" + +[] +let ``type check neg63`` () = singleNegTest ( "typecheck/sigs") "neg63" + +[] +let ``type check neg64`` () = singleNegTest ( "typecheck/sigs") "neg64" + +[] +let ``type check neg65`` () = singleNegTest ( "typecheck/sigs") "neg65" + +[] +let ``type check neg66`` () = singleNegTest ( "typecheck/sigs") "neg66" + +[] +let ``type check neg67`` () = singleNegTest ( "typecheck/sigs") "neg67" + +[] +let ``type check neg68`` () = singleNegTest ( "typecheck/sigs") "neg68" + +[] +let ``type check neg69`` () = singleNegTest ( "typecheck/sigs") "neg69" + +[] +let ``type check neg70`` () = singleNegTest ( "typecheck/sigs") "neg70" + +[] +let ``type check neg71`` () = singleNegTest ( "typecheck/sigs") "neg71" + +[] +let ``type check neg72`` () = singleNegTest ( "typecheck/sigs") "neg72" + +[] +let ``type check neg73`` () = singleNegTest ( "typecheck/sigs") "neg73" + +[] +let ``type check neg74`` () = singleNegTest ( "typecheck/sigs") "neg74" + +[] +let ``type check neg75`` () = singleNegTest ( "typecheck/sigs") "neg75" + +[] +let ``type check neg76`` () = singleNegTest ( "typecheck/sigs") "neg76" + +[] +let ``type check neg77`` () = singleNegTest ( "typecheck/sigs") "neg77" + +[] +let ``type check neg78`` () = singleNegTest ( "typecheck/sigs") "neg78" + +[] +let ``type check neg79`` () = singleNegTest ( "typecheck/sigs") "neg79" + +[] +let ``type check neg80`` () = singleNegTest ( "typecheck/sigs") "neg80" + +[] +let ``type check neg81`` () = singleNegTest ( "typecheck/sigs") "neg81" + +[] +let ``type check neg82`` () = singleNegTest ( "typecheck/sigs") "neg82" + +[] +let ``type check neg83`` () = singleNegTest ( "typecheck/sigs") "neg83" + +[] +let ``type check neg84`` () = singleNegTest ( "typecheck/sigs") "neg84" + +[] +let ``type check neg85`` () = singleNegTest ( "typecheck/sigs") "neg85" + +[] +let ``type check neg86`` () = singleNegTest ( "typecheck/sigs") "neg86" + +[] +let ``type check neg88`` () = singleNegTest ( "typecheck/sigs") "neg88" + +[] +let ``type check neg89`` () = singleNegTest ( "typecheck/sigs") "neg89" + +[] +let ``type check neg90`` () = singleNegTest ( "typecheck/sigs") "neg90" + +[] +let ``type check neg91`` () = singleNegTest ( "typecheck/sigs") "neg91" + +[] +let ``type check neg92`` () = singleNegTest ( "typecheck/sigs") "neg92" + +[] +let ``type check neg93`` () = singleNegTest ( "typecheck/sigs") "neg93" + +[] +let ``type check neg94`` () = singleNegTest ( "typecheck/sigs") "neg94" + +[] +let ``type check neg95`` () = singleNegTest ( "typecheck/sigs") "neg95" + +[] +let ``type check neg96`` () = singleNegTest ( "typecheck/sigs") "neg96" + +[] +let ``type check neg97`` () = singleNegTest ( "typecheck/sigs") "neg97" + +[] +let ``type check neg98`` () = singleNegTest ( "typecheck/sigs") "neg98" + +[] +let ``type check neg99`` () = singleNegTest ( "typecheck/sigs") "neg99" + +[] +let ``type check neg100`` () = singleVersionedNegTestAux "typecheck/sigs" ["--warnon:3218" ] LangVersion.Latest "neg100" + +[] +let ``type check neg101`` () = singleNegTest ( "typecheck/sigs") "neg101" + +[] +let ``type check neg102`` () = singleNegTest ( "typecheck/sigs") "neg102" + +[] +let ``type check neg103`` () = singleNegTest ( "typecheck/sigs") "neg103" + +[] +let ``type check neg104`` () = singleNegTest ( "typecheck/sigs") "neg104" + +[] +let ``type check neg106`` () = singleNegTest ( "typecheck/sigs") "neg106" + +[] +let ``type check neg107`` () = singleNegTest ( "typecheck/sigs") "neg107" + +[] +let ``type check neg108`` () = singleNegTest ( "typecheck/sigs") "neg108" + +[] +let ``type check neg109`` () = singleNegTest ( "typecheck/sigs") "neg109" + +[] +let ``type check neg110`` () = singleNegTest ( "typecheck/sigs") "neg110" + +[] +let ``type check neg111`` () = singleNegTest ( "typecheck/sigs") "neg111" + +[] +let ``type check neg112`` () = singleNegTest ( "typecheck/sigs") "neg112" + +[] +let ``type check neg113`` () = singleNegTest ( "typecheck/sigs") "neg113" + +[] +let ``type check neg114`` () = singleNegTest ( "typecheck/sigs") "neg114" + +[] +let ``type check neg115`` () = singleNegTest ( "typecheck/sigs") "neg115" + +[] +let ``type check neg116`` () = singleNegTest ( "typecheck/sigs") "neg116" + +[] +let ``type check neg117`` () = singleNegTest ( "typecheck/sigs") "neg117" + +[] +let ``type check neg118`` () = singleNegTest ( "typecheck/sigs") "neg118" + +[] +let ``type check neg119a`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.V60 "neg119a" + +[] +let ``type check neg119b`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.V70 "neg119b" + +[] +let ``type check neg120`` () = singleNegTest ( "typecheck/sigs") "neg120" + +[] +let ``type check neg121`` () = singleNegTest ( "typecheck/sigs") "neg121" + +[] +let ``type check neg122`` () = singleNegTest ( "typecheck/sigs") "neg122" + +[] +let ``type check neg123`` () = singleNegTest ( "typecheck/sigs") "neg123" + +[] +let ``type check neg124`` () = singleNegTest ( "typecheck/sigs") "neg124" + +[] +let ``type check neg125`` () = singleNegTest ( "typecheck/sigs") "neg125" + +[] +let ``type check neg126`` () = singleNegTest ( "typecheck/sigs") "neg126" + +[] +let ``type check neg127`` () = singleNegTest ( "typecheck/sigs") "neg127" + +[] +let ``type check neg128`` () = singleNegTest ( "typecheck/sigs") "neg128" + +[] +let ``type check neg129`` () = singleNegTest ( "typecheck/sigs") "neg129" + +[] +let ``type check neg130`` () = singleNegTest ( "typecheck/sigs") "neg130" + +[] +let ``type check neg131`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.V60 "neg131" + +[] +let ``type check neg132`` () = singleVersionedNegTest ( "typecheck/sigs") LangVersion.V50 "neg132" + +[] +let ``type check neg133`` () = singleNegTest ( "typecheck/sigs") "neg133" + +[] +let ``type check neg_anon_1`` () = singleNegTest ( "typecheck/sigs") "neg_anon_1" + +[] +let ``type check neg_anon_2`` () = singleNegTest ( "typecheck/sigs") "neg_anon_2" + +[] +let ``type check neg_issue_3752`` () = singleNegTest ( "typecheck/sigs") "neg_issue_3752" + +[] +let ``type check neg_byref_1`` () = singleNegTest ( "typecheck/sigs") "neg_byref_1" + +[] +let ``type check neg_byref_2`` () = singleNegTest ( "typecheck/sigs") "neg_byref_2" + +[] +let ``type check neg_byref_3`` () = singleNegTest ( "typecheck/sigs") "neg_byref_3" + +[] +let ``type check neg_byref_4`` () = singleNegTest ( "typecheck/sigs") "neg_byref_4" + +[] +let ``type check neg_byref_5`` () = singleNegTest ( "typecheck/sigs") "neg_byref_5" + +[] +let ``type check neg_byref_6`` () = singleNegTest ( "typecheck/sigs") "neg_byref_6" + +[] +let ``type check neg_byref_7`` () = singleNegTest ( "typecheck/sigs") "neg_byref_7" + +[] +let ``type check neg_byref_8`` () = singleNegTest ( "typecheck/sigs") "neg_byref_8" + +[] +let ``type check neg_byref_10`` () = singleNegTest ( "typecheck/sigs") "neg_byref_10" + +[] +let ``type check neg_byref_11`` () = singleNegTest ( "typecheck/sigs") "neg_byref_11" + +[] +let ``type check neg_byref_12`` () = singleNegTest ( "typecheck/sigs") "neg_byref_12" + +[] +let ``type check neg_byref_13`` () = singleNegTest ( "typecheck/sigs") "neg_byref_13" + +[] +let ``type check neg_byref_14`` () = singleNegTest ( "typecheck/sigs") "neg_byref_14" + +[] +let ``type check neg_byref_15`` () = singleNegTest ( "typecheck/sigs") "neg_byref_15" + +[] +let ``type check neg_byref_16`` () = singleNegTest ( "typecheck/sigs") "neg_byref_16" + +[] +let ``type check neg_byref_17`` () = singleNegTest ( "typecheck/sigs") "neg_byref_17" + +[] +let ``type check neg_byref_18`` () = singleNegTest ( "typecheck/sigs") "neg_byref_18" + +[] +let ``type check neg_byref_19`` () = singleNegTest ( "typecheck/sigs") "neg_byref_19" + +[] +let ``type check neg_byref_20`` () = singleNegTest ( "typecheck/sigs") "neg_byref_20" + +[] +let ``type check neg_byref_21`` () = singleNegTest ( "typecheck/sigs") "neg_byref_21" + +[] +let ``type check neg_byref_22`` () = singleNegTest ( "typecheck/sigs") "neg_byref_22" + +[] +let ``type check neg_byref_23`` () = singleNegTest ( "typecheck/sigs") "neg_byref_23" \ No newline at end of file diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 089bafc03ee..32be989438f 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -145,7 +145,8 @@ module rec Compiler = { Error: ErrorType Range: Range NativeRange : FSharp.Compiler.Text.range - Message: string } + Message: string + SubCategory: string } type ExecutionOutput = { ExitCode: int @@ -235,6 +236,7 @@ module rec Compiler = e.FileName |> Path.GetFileName, { Error = error NativeRange = e.Range + SubCategory = e.Subcategory Range = { StartLine = e.StartLine StartColumn = e.StartColumn @@ -612,6 +614,7 @@ module rec Compiler = EndLine = span.End.Line EndColumn = span.End.Character } NativeRange = Unchecked.defaultof<_> + SubCategory = "" Message = d.GetMessage() } let private compileCSharpCompilation (compilation: CSharpCompilation) csSource (filePath : string) dependencies : CompilationResult = @@ -1255,6 +1258,7 @@ module rec Compiler = EndLine = endLine EndColumn = endCol } NativeRange = Unchecked.defaultof<_> + SubCategory = "" Message = message } ] withResultsIgnoreNativeRange expectedResults result @@ -1274,7 +1278,7 @@ module rec Compiler = Message: string } let withResults (expectedResults: SimpleErrorInfo list) result : CompilationResult = - let mappedResults = expectedResults |> List.map (fun s -> { Error = s.Error;Range = s.Range; Message = s.Message; NativeRange = Unchecked.defaultof<_>}) + let mappedResults = expectedResults |> List.map (fun s -> { Error = s.Error;Range = s.Range; Message = s.Message; NativeRange = Unchecked.defaultof<_>; SubCategory = ""}) Compiler.Assertions.withResultsIgnoreNativeRange mappedResults result let withResult (expectedResult: SimpleErrorInfo ) (result: CompilationResult) : CompilationResult = @@ -1292,24 +1296,26 @@ module rec Compiler = | ErrorType.Hidden n | ErrorType.Information n-> "info",n + let normalizeNewLines (s:string) = s.Replace("\r\n","\n").Replace("\n",Environment.NewLine) + let private renderToString (cr:CompilationResult) = [ for (file,err) in cr.Output.PerFileErrors do let m = err.NativeRange let file = file.Replace("/", "\\") let severity,no = messageAndNumber err.Error - let adjustedMessage = err.Message.Replace("\r\n","\n").Replace("\n","\r\n") + let adjustedMessage = err.Message |> normalizeNewLines let location = if (equals m range0) || (equals m rangeStartup) || (equals m rangeCmdArgs) then "" else // The baseline .bsl files use 1-based notation for columns, hence the +1's sprintf "%s(%d,%d,%d,%d):" file m.StartLine (m.StartColumn+1) m.EndLine (m.EndColumn+1) - Environment.NewLine + $"{location} typecheck {severity} FS%04d{no}: {adjustedMessage}" + Environment.NewLine + Environment.NewLine + $"{location} {err.SubCategory} {severity} FS%04d{no}: {adjustedMessage}" + Environment.NewLine ] |> String.Concat let withResultsMatchingFile (path:string) (result:CompilationResult) = - let expectedContent = File.ReadAllText(path) + let expectedContent = File.ReadAllText(path) |> normalizeNewLines let actualErrors = renderToString result match Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") with @@ -1318,8 +1324,8 @@ module rec Compiler = | _ -> File.WriteAllText(path, actualErrors) match Assert.shouldBeSameMultilineStringSets expectedContent actualErrors with - | None -> Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip) - | Some diff -> Assert.That(diff, Is.Empty) + | None -> () // Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip,path) + | Some diff -> Assert.That(diff, Is.Empty, path) result diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index eb9ea5d3a36..caa78b5a808 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -750,7 +750,12 @@ Updated automatically, please check diffs in your pull request, changes must be |> Async.RunImmediate if parseResults.Diagnostics.Length > 0 then - parseResults.Diagnostics + if options |> Array.contains "--test:ContinueAfterParseFailure" then + [| yield! parseResults.Diagnostics + match fileAnswer with + | FSharpCheckFileAnswer.Succeeded(tcResults) -> yield! tcResults.Diagnostics + | _ -> () |] + else parseResults.Diagnostics else match fileAnswer with diff --git a/tests/FSharp.Test.Utilities/ScriptHelpers.fs b/tests/FSharp.Test.Utilities/ScriptHelpers.fs index ddf4d146ead..98b70604878 100644 --- a/tests/FSharp.Test.Utilities/ScriptHelpers.fs +++ b/tests/FSharp.Test.Utilities/ScriptHelpers.fs @@ -75,6 +75,8 @@ type RedirectConsoleOutput() = type LangVersion = | V47 | V50 + | V60 + | V70 | Preview | Latest | SupportsMl @@ -101,6 +103,8 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer | LangVersion.V50 | LangVersion.SupportsMl -> "--langversion:5.0" | LangVersion.Preview -> "--langversion:preview" | LangVersion.Latest -> "--langversion:latest" + | LangVersion.V60 -> "--langversion:6.0" + | LangVersion.V70 -> "--langversion:7.0" |] let argv = Array.append baseArgs additionalArgs diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index f4a9cad2cef..35700a83aea 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -32,3237 +32,2356 @@ let singleTestBuildAndRun = getTestsDirectory >> singleTestBuildAndRun let singleTestBuildAndRunVersion = getTestsDirectory >> singleTestBuildAndRunVersion let testConfig = getTestsDirectory >> testConfig -[] -module TestsToBeDeletedBecauseTheyHaveMoved = - let x = 42 +[] +module CoreTests = - // These tests are enabled for .NET Framework and .NET Core +#if !NETCOREAPP +// This test stays in FsharpSuite for a later migration phases, it uses hardcoded #r to a C# compiled cslib.dll inside [] - let ``access-FSC_DEBUG``() = singleTestBuildAndRun "core/access" FSC_DEBUG + let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG [] - let ``access-FSC_OPTIMIZED``() = singleTestBuildAndRun "core/access" FSC_OPTIMIZED + let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED [] - let ``access-FSI``() = singleTestBuildAndRun "core/access" FSI + let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI +#endif - [] - let ``apporder-FSC_DEBUG`` () = singleTestBuildAndRun "core/apporder" FSC_DEBUG +#if !NETCOREAPP +// This test has hardcoded expectations about current synchronization context +// Will be moved out of FsharpSuite.Tests in a later phase for desktop framework [] - let ``apporder-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/apporder" FSC_OPTIMIZED + let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED [] - let ``apporder-FSI`` () = singleTestBuildAndRun "core/apporder" FSI + let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI [] - let ``array-FSC_DEBUG-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_DEBUG "5.0" + let ``control --tailcalls`` () = + let cfg = testConfig "core/control" + singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED +#endif [] - let ``array-FSC_OPTIMIZED-5.0`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED "5.0" + let ``SDKTests`` () = + let cfg = testConfig "SDKTests" + exec cfg cfg.DotNetExe ("msbuild " + Path.Combine(cfg.Directory, "AllSdkTargetsTests.proj") + " /p:Configuration=" + cfg.BUILD_CONFIG) +#if !NETCOREAPP [] - let ``array-FSI-5.0`` () = singleTestBuildAndRunVersion "core/array" FSI "5.0" + let ``attributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/attributes" FSC_OPTIMIZED [] - let ``array-FSC_OPTIMIZED-preview`` () = singleTestBuildAndRunVersion "core/array" FSC_OPTIMIZED "preview" + let ``attributes-FSI`` () = singleTestBuildAndRun "core/attributes" FSI [] - let ``array-no-dot-FSC_DEBUG`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_DEBUG "preview" + let byrefs () = - [] - let ``array-no-dot-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSC_OPTIMIZED "preview" + let cfg = testConfig "core/byrefs" - [] - let ``array-no-dot-FSI`` () = singleTestBuildAndRunVersion "core/array-no-dot" FSI "preview" + begin + use testOkFile = fileguard cfg "test.ok" - [] - let ``array-no-dot-warnings-langversion-default`` () = - let cfg = testConfig "core/array-no-dot-warnings" - singleVersionedNegTest cfg "default" "test-langversion-default" + fsc cfg "%s -o:test.exe -g --langversion:4.7" cfg.fsc_flags ["test.fsx"] - [] - let ``array-no-dot-warnings-langversion-5_0`` () = - let cfg = testConfig "core/array-no-dot-warnings" - singleVersionedNegTest cfg "5.0" "test-langversion-5.0" + singleVersionedNegTest cfg "4.7" "test" + exec cfg ("." ++ "test.exe") "" - [] - let ``ref-ops-deprecation-langversion-preview`` () = - let cfg = testConfig "core/ref-ops-deprecation" - singleVersionedNegTest cfg "preview" "test-langversion-preview" + testOkFile.CheckExists() + end - [] - let ``auto-widen-version-5_0``() = - let cfg = testConfig "core/auto-widen/5.0" - singleVersionedNegTest cfg "5.0" "test" + begin + use testOkFile = fileguard cfg "test.ok" - [] - let ``auto-widen-version-FSC_DEBUG-preview``() = - singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_DEBUG "preview" + fsc cfg "%s -o:test.exe -g --langversion:5.0" cfg.fsc_flags ["test.fsx"] - [] - let ``auto-widen-version-FSC_OPTIMIZED-preview``() = - singleTestBuildAndRunVersion "core/auto-widen/preview" FSC_OPTIMIZED "preview" + singleVersionedNegTest cfg "5.0" "test" - [] - let ``auto-widen-version-preview-warns-on``() = - let cfg = testConfig "core/auto-widen/preview" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --warnon:3388 --warnon:3389 --warnon:3395 --warnaserror+ --define:NEGATIVE" } - singleVersionedNegTest cfg "preview" "test" + exec cfg ("." ++ "test.exe") "" - [] - let ``auto-widen-version-preview-default-warns``() = - let cfg = testConfig "core/auto-widen/preview-default-warns" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --warnaserror+ --define:NEGATIVE" } - singleVersionedNegTest cfg "preview" "test" + testOkFile.CheckExists() + end - [] - let ``comprehensions-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions" FSC_DEBUG + begin + use testOkFile = fileguard cfg "test2.ok" - [] - let ``comprehensions-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions" FSC_OPTIMIZED + fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"] - [] - let ``comprehensions-FSI`` () = singleTestBuildAndRun "core/comprehensions" FSI + singleNegTest { cfg with fsc_flags = sprintf "%s --warnaserror-" cfg.fsc_flags } "test2" - [] - let ``comprehensionshw-FSC_DEBUG`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_DEBUG + exec cfg ("." ++ "test2.exe") "" - [] - let ``comprehensionshw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/comprehensions-hw" FSC_OPTIMIZED + testOkFile.CheckExists() + end - [] - let ``comprehensionshw-FSI`` () = singleTestBuildAndRun "core/comprehensions-hw" FSI + begin + csc cfg """/langversion:7.2 /nologo /target:library /out:cslib3.dll""" ["cslib3.cs"] - [] - let ``genericmeasures-FSC_DEBUG`` () = singleTestBuildAndRun "core/genericmeasures" FSC_DEBUG + use testOkFile = fileguard cfg "test3.ok" - [] - let ``genericmeasures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/genericmeasures" FSC_OPTIMIZED + fsc cfg "%s -r:cslib3.dll -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"] - [] - let ``genericmeasures-FSI`` () = singleTestBuildAndRun "core/genericmeasures" FSI + singleNegTest { cfg with fsc_flags = sprintf "%s -r:cslib3.dll" cfg.fsc_flags } "test3" - [] - let ``innerpoly-FSC_DEBUG`` () = singleTestBuildAndRun "core/innerpoly" FSC_DEBUG + exec cfg ("." ++ "test3.exe") "" - [] - let ``innerpoly-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/innerpoly" FSC_OPTIMIZED + testOkFile.CheckExists() + end [] - let ``innerpoly-FSI`` () = singleTestBuildAndRun "core/innerpoly" FSI + let span () = - [] - let ``namespaceAttributes-FSC_DEBUG`` () = singleTestBuildAndRun "core/namespaces" FSC_DEBUG + let cfg = testConfig "core/span" - [] - let ``namespaceAttributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/namespaces" FSC_OPTIMIZED + let cfg = { cfg with fsc_flags = sprintf "%s --preferreduilang:en-US --test:StackSpan" cfg.fsc_flags} - [] - let ``unicode2-FSC_DEBUG`` () = singleTestBuildAndRun "core/unicode" FSC_DEBUG // TODO: fails on coreclr + begin + use testOkFile = fileguard cfg "test.ok" - [] - let ``unicode2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/unicode" FSC_OPTIMIZED // TODO: fails on coreclr + singleNegTest cfg "test" - [] - let ``unicode2-FSI`` () = singleTestBuildAndRun "core/unicode" FSI + fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - [] - let ``lazy test-FSC_DEBUG`` () = singleTestBuildAndRun "core/lazy" FSC_DEBUG + // Execution is disabled until we can be sure .NET 4.7.2 is on the machine + //exec cfg ("." ++ "test.exe") "" - [] - let ``lazy test-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lazy" FSC_OPTIMIZED + //testOkFile.CheckExists() + end - [] - let ``lazy test-FSI`` () = singleTestBuildAndRun "core/lazy" FSI + begin + use testOkFile = fileguard cfg "test2.ok" - [] - let ``letrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec" FSC_DEBUG + singleNegTest cfg "test2" - [] - let ``letrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec" FSC_OPTIMIZED + fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"] - [] - let ``letrec-FSI`` () = singleTestBuildAndRun "core/letrec" FSI + // Execution is disabled until we can be sure .NET 4.7.2 is on the machine + //exec cfg ("." ++ "test.exe") "" - [] - let ``letrec (mutrec variations part one) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_DEBUG + //testOkFile.CheckExists() + end - [] - let ``letrec (mutrec variations part one) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec" FSC_OPTIMIZED + begin + use testOkFile = fileguard cfg "test3.ok" - [] - let ``letrec (mutrec variations part one) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec" FSI + singleNegTest cfg "test3" - [] - let ``libtest-FSC_DEBUG`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG + fsc cfg "%s -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"] - [] - let ``libtest-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/libtest" FSC_OPTIMIZED + // Execution is disabled until we can be sure .NET 4.7.2 is on the machine + //exec cfg ("." ++ "test.exe") "" - [] - let ``libtest-FSI`` () = singleTestBuildAndRun "core/libtest" FSI + //testOkFile.CheckExists() + end [] - let ``lift-FSC_DEBUG`` () = singleTestBuildAndRun "core/lift" FSC_DEBUG + let asyncStackTraces () = + let cfg = testConfig "core/asyncStackTraces" - [] - let ``lift-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/lift" FSC_OPTIMIZED + use testOkFile = fileguard cfg "test.ok" - [] - let ``lift-FSI`` () = singleTestBuildAndRun "core/lift" FSI + fsc cfg "%s -o:test.exe -g --tailcalls- --optimize-" cfg.fsc_flags ["test.fsx"] - [] - let ``map-FSC_DEBUG`` () = singleTestBuildAndRun "core/map" FSC_DEBUG + exec cfg ("." ++ "test.exe") "" - [] - let ``map-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/map" FSC_OPTIMIZED + testOkFile.CheckExists() [] - let ``map-FSI`` () = singleTestBuildAndRun "core/map" FSI + let ``state-machines-non-optimized`` () = + let cfg = testConfig "core/state-machines" - [] - let ``measures-FSC_DEBUG`` () = singleTestBuildAndRun "core/measures" FSC_DEBUG + use testOkFile = fileguard cfg "test.ok" - [] - let ``measures-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/measures" FSC_OPTIMIZED + fsc cfg "%s -o:test.exe -g --tailcalls- --optimize- --langversion:preview" cfg.fsc_flags ["test.fsx"] - [] - let ``measures-FSI`` () = singleTestBuildAndRun "core/measures" FSI + peverify cfg "test.exe" - [] - let ``nested-FSC_DEBUG`` () = singleTestBuildAndRun "core/nested" FSC_DEBUG + exec cfg ("." ++ "test.exe") "" - [] - let ``nested-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/nested" FSC_OPTIMIZED + testOkFile.CheckExists() [] - let ``nested-FSI`` () = singleTestBuildAndRun "core/nested" FSI + let ``state-machines-optimized`` () = + let cfg = testConfig "core/state-machines" - [] - let ``members-ops-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops" FSC_OPTIMIZED + use testOkFile = fileguard cfg "test.ok" - [] - let ``members-ops-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops" FSC_DEBUG + fsc cfg "%s -o:test.exe -g --tailcalls+ --optimize+ --langversion:preview" cfg.fsc_flags ["test.fsx"] - [] - let ``members-ops-FSI`` () = singleTestBuildAndRun "core/members/ops" FSI + peverify cfg "test.exe" - [] - let ``members-ops-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_DEBUG + exec cfg ("." ++ "test.exe") "" - [] - let ``members-ops-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSC_OPTIMIZED + testOkFile.CheckExists() [] - let ``members-ops-mutrec-FSI`` () = singleTestBuildAndRun "core/members/ops-mutrec" FSI + let ``state-machines neg-resumable-01`` () = + let cfg = testConfig "core/state-machines" + singleVersionedNegTest cfg "preview" "neg-resumable-01" - [] - let ``seq-FSC_DEBUG`` () = singleTestBuildAndRun "core/seq" FSC_DEBUG [] - let ``seq-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/seq" FSC_OPTIMIZED + let ``state-machines neg-resumable-02`` () = + let cfg = testConfig "core/state-machines" + singleVersionedNegTest cfg "preview" "neg-resumable-02" [] - let ``seq-FSI`` () = singleTestBuildAndRun "core/seq" FSI + let ``lots-of-conditionals``() = + let cfg = testConfig "core/large/conditionals" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-200.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``math-numbers-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbers" FSC_OPTIMIZED + let ``lots-of-conditionals-maxtested``() = + let cfg = testConfig "core/large/conditionals" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-maxtested.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``math-numbers-FSI`` () = singleTestBuildAndRun "core/math/numbers" FSI + let ``lots-of-lets``() = + let cfg = testConfig "core/large/lets" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-500.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-ctree-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/ctree" FSC_DEBUG + let ``lots-of-lets-maxtested``() = + let cfg = testConfig "core/large/lets" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-maxtested.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-ctree-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/ctree" FSC_OPTIMIZED + let ``lots-of-lists``() = + let cfg = testConfig "core/large/lists" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test-500.exe " cfg.fsc_flags ["LargeList-500.fs"] + exec cfg ("." ++ "test-500.exe") "" + testOkFile.CheckExists() [] - let ``members-ctree-FSI`` () = singleTestBuildAndRun "core/members/ctree" FSI + let ``lots-of-matches``() = + let cfg = testConfig "core/large/matches" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-200.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-factors-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors" FSC_DEBUG + let ``lots-of-matches-maxtested``() = + let cfg = testConfig "core/large/matches" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-maxtested.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-factors-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors" FSC_OPTIMIZED + let ``lots-of-sequential-and-let``() = + let cfg = testConfig "core/large/mixed" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-500.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-factors-FSI`` () = singleTestBuildAndRun "core/members/factors" FSI + let ``lots-of-sequential-and-let-maxtested``() = + let cfg = testConfig "core/large/mixed" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-maxtested.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-factors-mutrec-FSC_DEBUG`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_DEBUG + let ``lots-of-sequential``() = + let cfg = testConfig "core/large/sequential" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-500.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() [] - let ``members-factors-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSC_OPTIMIZED + let ``lots-of-sequential-maxtested``() = + let cfg = testConfig "core/large/sequential" + use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-maxtested.fs"] + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() - [] - let ``members-factors-mutrec-FSI`` () = singleTestBuildAndRun "core/members/factors-mutrec" FSI +#endif - [] - let ``graph-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/graph" FSC_DEBUG "supports-ml" - [] - let ``graph-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/graph" FSC_OPTIMIZED "supports-ml" - [] - let ``graph-FSI`` () = singleTestBuildAndRunVersion "perf/graph" FSI "supports-ml" +#if !NETCOREAPP + // Requires winforms will not run on coreclr [] - let ``nbody-FSC_DEBUG`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_DEBUG "supports-ml" + let controlWpf () = singleTestBuildAndRun "core/controlwpf" FSC_OPTIMIZED + // These tests are enabled for .NET Framework [] - let ``nbody-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "perf/nbody" FSC_OPTIMIZED "supports-ml" + let ``anon-FSC_OPTIMIZED``() = + let cfg = testConfig "core/anon" - [] - let ``nbody-FSI`` () = singleTestBuildAndRunVersion "perf/nbody" FSI "supports-ml" + fsc cfg "%s -a -o:lib.dll" cfg.fsc_flags ["lib.fs"] - [] - let ``forexpression-FSC_DEBUG`` () = singleTestBuildAndRun "core/forexpression" FSC_DEBUG + peverify cfg "lib.dll" - [] - let ``forexpression-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/forexpression" FSC_OPTIMIZED + fsc cfg "%s -r:lib.dll" cfg.fsc_flags ["test.fsx"] - [] - let ``forexpression-FSI`` () = singleTestBuildAndRun "core/forexpression" FSI + peverify cfg "test.exe" - [] - let ``letrec (mutrec variations part two) FSC_DEBUG`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_DEBUG + begin + use testOkFile = fileguard cfg "test.ok" - [] - let ``letrec (mutrec variations part two) FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSC_OPTIMIZED + exec cfg ("." ++ "test.exe") "" - [] - let ``letrec (mutrec variations part two) FSI`` () = singleTestBuildAndRun "core/letrec-mutrec2" FSI + testOkFile.CheckExists() + end - [] - let ``printf`` () = singleTestBuildAndRunVersion "core/printf" FSC_OPTIMIZED "preview" + begin + use testOkFile = fileguard cfg "test.ok" - [] - let ``printf-interpolated`` () = singleTestBuildAndRunVersion "core/printf-interpolated" FSC_OPTIMIZED "preview" + fsi cfg "-r:lib.dll" ["test.fsx"] - [] - let ``tlr-FSC_DEBUG`` () = singleTestBuildAndRun "core/tlr" FSC_DEBUG + testOkFile.CheckExists() + end [] - let ``tlr-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/tlr" FSC_OPTIMIZED + let events () = + let cfg = testConfig "core/events" - [] - let ``tlr-FSI`` () = singleTestBuildAndRun "core/tlr" FSI + fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"] - [] - let ``subtype-FSC_DEBUG`` () = singleTestBuildAndRun "core/subtype" FSC_DEBUG + peverify cfg "test.dll" - [] - let ``subtype-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/subtype" FSC_OPTIMIZED + csc cfg """/r:"%s" /reference:test.dll /debug+""" cfg.FSCOREDLLPATH ["testcs.cs"] - [] - let ``subtype-FSI`` () = singleTestBuildAndRun "core/subtype" FSI + peverify cfg "testcs.exe" - [] - let ``syntax-FSC_DEBUG`` () = singleTestBuildAndRun "core/syntax" FSC_DEBUG + use testOkFile = fileguard cfg "test.ok" - [] - let ``syntax-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/syntax" FSC_OPTIMIZED + fsi cfg "" ["test.fs"] - [] - let ``syntax-FSI`` () = singleTestBuildAndRun "core/syntax" FSI + testOkFile.CheckExists() - [] - let ``test int32-FSC_DEBUG`` () = singleTestBuildAndRun "core/int32" FSC_DEBUG + exec cfg ("." ++ "testcs.exe") "" - [] - let ``test int32-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/int32" FSC_OPTIMIZED - [] - let ``test int32-FSI`` () = singleTestBuildAndRun "core/int32" FSI + // + // Shadowcopy does not work for public signed assemblies + // ===================================================== + // + //module ``FSI-Shadowcopy`` = + // + // [] + // // "%FSI%" %fsi_flags% < test1.fsx + // [] + // // "%FSI%" %fsi_flags% /shadowcopyreferences+ < test2.fsx + // [] - let ``quotes-FSC-FSC_DEBUG`` () = singleTestBuildAndRun "core/quotes" FSC_DEBUG [] - let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_OPTIMIZED + let forwarders () = + let cfg = testConfig "core/forwarders" - [] - let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI -#endif + mkdir cfg "orig" + mkdir cfg "split" - [] - let ``recordResolution-FSC_DEBUG`` () = singleTestBuildAndRun "core/recordResolution" FSC_DEBUG + csc cfg """/nologo /target:library /out:orig\a.dll /define:PART1;PART2""" ["a.cs"] - [] - let ``recordResolution-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/recordResolution" FSC_OPTIMIZED + csc cfg """/nologo /target:library /out:orig\b.dll /r:orig\a.dll""" ["b.cs"] - [] - let ``recordResolution-FSI`` () = singleTestBuildAndRun "core/recordResolution" FSI + fsc cfg """-a -o:orig\c.dll -r:orig\b.dll -r:orig\a.dll""" ["c.fs"] -#if !NETCOREAPP -// This test has hardcoded expectations about current synchronization context -// Will be moved out of FsharpSuite.Tests in a later phase - [] - let ``control-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/control" FSC_OPTIMIZED + csc cfg """/nologo /target:library /out:split\a-part1.dll /define:PART1;SPLIT""" ["a.cs"] - [] - let ``control-FSI`` () = singleTestBuildAndRun "core/control" FSI + csc cfg """/nologo /target:library /r:split\a-part1.dll /out:split\a.dll /define:PART2;SPLIT""" ["a.cs"] - [] - let ``control --tailcalls`` () = - let cfg = testConfig "core/control" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED -#endif + copy cfg ("orig" ++ "b.dll") ("split" ++ "b.dll") - [] - let ``controlChamenos-FSC_OPTIMIZED`` () = - let cfg = testConfig "core/controlChamenos" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED + copy cfg ("orig" ++ "c.dll") ("split" ++ "c.dll") - [] - let ``controlChamenos-FSI`` () = - let cfg = testConfig "core/controlChamenos" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSI + fsc cfg """-o:orig\test.exe -r:orig\b.dll -r:orig\a.dll""" ["test.fs"] - [] - let ``controlMailbox-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/controlMailbox" FSC_OPTIMIZED + fsc cfg """-o:split\test.exe -r:split\b.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"] - [] - let ``controlMailbox-FSI`` () = singleTestBuildAndRun "core/controlMailbox" FSI + fsc cfg """-o:split\test-against-c.exe -r:split\c.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"] - [] - let ``controlMailbox --tailcalls`` () = - let cfg = testConfig "core/controlMailbox" - singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_OPTIMIZED + peverify cfg ("split" ++ "a-part1.dll") - [] - let ``csext-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/csext" FSC_OPTIMIZED + peverify cfg ("split" ++ "b.dll") - [] - let ``csext-FSI`` () = singleTestBuildAndRun "core/csext" FSI + peverify cfg ("split" ++ "c.dll") [] - let ``enum-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/enum" FSC_OPTIMIZED + let xmldoc () = + let cfg = testConfig "core/xmldoc" - [] - let ``enum-FSI`` () = singleTestBuildAndRun "core/enum" FSI + fsc cfg "%s -a --doc:lib.xml -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] + let outFile = "lib.xml" + let expectedFile = "lib.xml.bsl" - [] - let ``longnames-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/longnames" FSC_OPTIMIZED + if not (fileExists cfg expectedFile) then + copy cfg outFile expectedFile - [] - let ``longnames-FSI`` () = singleTestBuildAndRun "core/longnames" FSI + let diffs = fsdiff cfg outFile expectedFile + match diffs with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) [] - let ``math-numbersVS2008-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSC_OPTIMIZED + let fsfromcs () = + let cfg = testConfig "core/fsfromcs" - [] - let ``math-numbersVS2008-FSI`` () = singleTestBuildAndRun "core/math/numbersVS2008" FSI + fsc cfg "%s -a --doc:lib.xml -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] - [] - let ``patterns-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "core/patterns" FSC_OPTIMIZED "preview" + peverify cfg "lib.dll" -// This requires --multiemit on by default, which is not the case for .NET Framework -#if NETCOREAPP - [] - let ``patterns-FSI`` () = singleTestBuildAndRun "core/patterns" FSI -#endif + csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib.dll /out:test.exe""" cfg.FSCOREDLLPATH ["test.cs"] - [] - let ``pinvoke-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/pinvoke" FSC_OPTIMIZED + fsc cfg """%s -a --doc:lib--optimize.xml -o:lib--optimize.dll -g""" cfg.fsc_flags ["lib.fs"] - [] - let ``pinvoke-FSI`` () = - singleTestBuildAndRun "core/pinvoke" FSI + peverify cfg "lib--optimize.dll" - [] - let ``fsi_load-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/fsi-load" FSC_OPTIMIZED + csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"] - [] - let ``fsi_load-FSI`` () = singleTestBuildAndRun "core/fsi-load" FSI + exec cfg ("." ++ "test.exe") "" - [] - let ``reflect-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/reflect" FSC_OPTIMIZED + exec cfg ("." ++ "test--optimize.exe") "" [] - let ``reflect-FSI`` () = singleTestBuildAndRun "core/reflect" FSI - -[] -module CoreTests = + let fsfromfsviacs () = + let cfg = testConfig "core/fsfromfsviacs" - [] - let ``SDKTests`` () = - let cfg = testConfig "SDKTests" - exec cfg cfg.DotNetExe ("msbuild " + Path.Combine(cfg.Directory, "AllSdkTargetsTests.proj") + " /p:Configuration=" + cfg.BUILD_CONFIG) + fsc cfg "%s -a -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] -#if !NETCOREAPP - [] - let ``attributes-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/attributes" FSC_OPTIMIZED + peverify cfg "lib.dll" - [] - let ``attributes-FSI`` () = singleTestBuildAndRun "core/attributes" FSI + csc cfg """/nologo /target:library /r:"%s" /r:lib.dll /out:lib2.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib2.cs"] - [] - let byrefs () = + csc cfg """/nologo /target:library /r:"%s" /out:lib3.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib3.cs"] - let cfg = testConfig "core/byrefs" + // all features available in preview + fsc cfg "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - begin - use testOkFile = fileguard cfg "test.ok" + peverify cfg "test.exe" - fsc cfg "%s -o:test.exe -g --langversion:4.7" cfg.fsc_flags ["test.fsx"] + exec cfg ("." ++ "test.exe") "" - singleVersionedNegTest cfg "4.7" "test" - exec cfg ("." ++ "test.exe") "" + // Same with library references the other way around + fsc cfg "%s -r:lib.dll -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - testOkFile.CheckExists() - end + peverify cfg "test.exe" - begin - use testOkFile = fileguard cfg "test.ok" + exec cfg ("." ++ "test.exe") "" - fsc cfg "%s -o:test.exe -g --langversion:5.0" cfg.fsc_flags ["test.fsx"] + // Same without the reference to lib.dll - testing an incomplete reference set, but only compiling a subset of the code + fsc cfg "%s --define:NO_LIB_REFERENCE -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - singleVersionedNegTest cfg "5.0" "test" + peverify cfg "test.exe" - exec cfg ("." ++ "test.exe") "" + exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - end + // some features missing in 4.7 + for version in ["4.7"] do + let outFile = "compilation.langversion.old.output.txt" + let expectedFile = "compilation.langversion.old.output.bsl" + fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --langversion:%s" cfg.fsc_flags version ["test.fsx"] - begin - use testOkFile = fileguard cfg "test2.ok" + let diffs = fsdiff cfg outFile expectedFile + match diffs with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) - fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"] + // check error messages for some cases + let outFile = "compilation.errors.output.txt" + let expectedFile = "compilation.errors.output.bsl" + fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --define:CHECK_ERRORS" cfg.fsc_flags ["test.fsx"] - singleNegTest { cfg with fsc_flags = sprintf "%s --warnaserror-" cfg.fsc_flags } "test2" + let diffs = fsdiff cfg outFile expectedFile + match diffs with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) - exec cfg ("." ++ "test2.exe") "" + [] + let ``fsi-reference`` () = - testOkFile.CheckExists() - end + let cfg = testConfig "core/fsi-reference" begin - csc cfg """/langversion:7.2 /nologo /target:library /out:cslib3.dll""" ["cslib3.cs"] - - use testOkFile = fileguard cfg "test3.ok" - - fsc cfg "%s -r:cslib3.dll -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"] - - singleNegTest { cfg with fsc_flags = sprintf "%s -r:cslib3.dll" cfg.fsc_flags } "test3" - - exec cfg ("." ++ "test3.exe") "" - + use testOkFile = fileguard cfg "test.ok" + fsc cfg @"--target:library -o:ImplementationAssembly\ReferenceAssemblyExample.dll" ["ImplementationAssembly.fs"] + fsc cfg @"--target:library -o:ReferenceAssembly\ReferenceAssemblyExample.dll" ["ReferenceAssembly.fs"] + fsiStdin cfg "test.fsx" "" [] testOkFile.CheckExists() end [] - let span () = - - let cfg = testConfig "core/span" - - let cfg = { cfg with fsc_flags = sprintf "%s --preferreduilang:en-US --test:StackSpan" cfg.fsc_flags} + let ``fsi-reload`` () = + let cfg = testConfig "core/fsi-reload" begin use testOkFile = fileguard cfg "test.ok" - - singleNegTest cfg "test" - - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - - // Execution is disabled until we can be sure .NET 4.7.2 is on the machine - //exec cfg ("." ++ "test.exe") "" - - //testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test2.ok" - - singleNegTest cfg "test2" - - fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"] - - // Execution is disabled until we can be sure .NET 4.7.2 is on the machine - //exec cfg ("." ++ "test.exe") "" - - //testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test3.ok" - - singleNegTest cfg "test3" - - fsc cfg "%s -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"] - - // Execution is disabled until we can be sure .NET 4.7.2 is on the machine - //exec cfg ("." ++ "test.exe") "" - - //testOkFile.CheckExists() - end - - [] - let asyncStackTraces () = - let cfg = testConfig "core/asyncStackTraces" - - use testOkFile = fileguard cfg "test.ok" - - fsc cfg "%s -o:test.exe -g --tailcalls- --optimize-" cfg.fsc_flags ["test.fsx"] - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() - - [] - let ``state-machines-non-optimized`` () = - let cfg = testConfig "core/state-machines" - - use testOkFile = fileguard cfg "test.ok" - - fsc cfg "%s -o:test.exe -g --tailcalls- --optimize- --langversion:preview" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() - - [] - let ``state-machines-optimized`` () = - let cfg = testConfig "core/state-machines" - - use testOkFile = fileguard cfg "test.ok" - - fsc cfg "%s -o:test.exe -g --tailcalls+ --optimize+ --langversion:preview" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() - - [] - let ``state-machines neg-resumable-01`` () = - let cfg = testConfig "core/state-machines" - singleVersionedNegTest cfg "preview" "neg-resumable-01" - - - [] - let ``state-machines neg-resumable-02`` () = - let cfg = testConfig "core/state-machines" - singleVersionedNegTest cfg "preview" "neg-resumable-02" - - [] - let ``lots-of-conditionals``() = - let cfg = testConfig "core/large/conditionals" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-200.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-conditionals-maxtested``() = - let cfg = testConfig "core/large/conditionals" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-maxtested.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-lets``() = - let cfg = testConfig "core/large/lets" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-500.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-lets-maxtested``() = - let cfg = testConfig "core/large/lets" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-maxtested.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-lists``() = - let cfg = testConfig "core/large/lists" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test-500.exe " cfg.fsc_flags ["LargeList-500.fs"] - exec cfg ("." ++ "test-500.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-matches``() = - let cfg = testConfig "core/large/matches" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-200.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-matches-maxtested``() = - let cfg = testConfig "core/large/matches" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-maxtested.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-sequential-and-let``() = - let cfg = testConfig "core/large/mixed" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-500.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-sequential-and-let-maxtested``() = - let cfg = testConfig "core/large/mixed" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-maxtested.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-sequential``() = - let cfg = testConfig "core/large/sequential" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-500.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - - [] - let ``lots-of-sequential-maxtested``() = - let cfg = testConfig "core/large/sequential" - use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-maxtested.fs"] - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - -#endif - - - -#if !NETCOREAPP - - // Requires winforms will not run on coreclr - [] - let controlWpf () = singleTestBuildAndRun "core/controlwpf" FSC_OPTIMIZED - - // These tests are enabled for .NET Framework - [] - let ``anon-FSC_OPTIMIZED``() = - let cfg = testConfig "core/anon" - - fsc cfg "%s -a -o:lib.dll" cfg.fsc_flags ["lib.fs"] - - peverify cfg "lib.dll" - - fsc cfg "%s -r:lib.dll" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - begin - use testOkFile = fileguard cfg "test.ok" - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test.ok" - - fsi cfg "-r:lib.dll" ["test.fsx"] - - testOkFile.CheckExists() - end - - [] - let events () = - let cfg = testConfig "core/events" - - fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"] - - peverify cfg "test.dll" - - csc cfg """/r:"%s" /reference:test.dll /debug+""" cfg.FSCOREDLLPATH ["testcs.cs"] - - peverify cfg "testcs.exe" - - use testOkFile = fileguard cfg "test.ok" - - fsi cfg "" ["test.fs"] - - testOkFile.CheckExists() - - exec cfg ("." ++ "testcs.exe") "" - - - // - // Shadowcopy does not work for public signed assemblies - // ===================================================== - // - //module ``FSI-Shadowcopy`` = - // - // [] - // // "%FSI%" %fsi_flags% < test1.fsx - // [] - // // "%FSI%" %fsi_flags% /shadowcopyreferences+ < test2.fsx - // [] - let forwarders () = - let cfg = testConfig "core/forwarders" - - mkdir cfg "orig" - mkdir cfg "split" - - csc cfg """/nologo /target:library /out:orig\a.dll /define:PART1;PART2""" ["a.cs"] - - csc cfg """/nologo /target:library /out:orig\b.dll /r:orig\a.dll""" ["b.cs"] - - fsc cfg """-a -o:orig\c.dll -r:orig\b.dll -r:orig\a.dll""" ["c.fs"] - - csc cfg """/nologo /target:library /out:split\a-part1.dll /define:PART1;SPLIT""" ["a.cs"] - - csc cfg """/nologo /target:library /r:split\a-part1.dll /out:split\a.dll /define:PART2;SPLIT""" ["a.cs"] - - copy cfg ("orig" ++ "b.dll") ("split" ++ "b.dll") - - copy cfg ("orig" ++ "c.dll") ("split" ++ "c.dll") - - fsc cfg """-o:orig\test.exe -r:orig\b.dll -r:orig\a.dll""" ["test.fs"] - - fsc cfg """-o:split\test.exe -r:split\b.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"] - - fsc cfg """-o:split\test-against-c.exe -r:split\c.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"] - - peverify cfg ("split" ++ "a-part1.dll") - - peverify cfg ("split" ++ "b.dll") - - peverify cfg ("split" ++ "c.dll") - - [] - let xmldoc () = - let cfg = testConfig "core/xmldoc" - - fsc cfg "%s -a --doc:lib.xml -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] - let outFile = "lib.xml" - let expectedFile = "lib.xml.bsl" - - if not (fileExists cfg expectedFile) then - copy cfg outFile expectedFile - - let diffs = fsdiff cfg outFile expectedFile - match diffs with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) - - [] - let fsfromcs () = - let cfg = testConfig "core/fsfromcs" - - fsc cfg "%s -a --doc:lib.xml -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] - - peverify cfg "lib.dll" - - csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib.dll /out:test.exe""" cfg.FSCOREDLLPATH ["test.cs"] - - fsc cfg """%s -a --doc:lib--optimize.xml -o:lib--optimize.dll -g""" cfg.fsc_flags ["lib.fs"] - - peverify cfg "lib--optimize.dll" - - csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"] - - exec cfg ("." ++ "test.exe") "" - - exec cfg ("." ++ "test--optimize.exe") "" - - [] - let fsfromfsviacs () = - let cfg = testConfig "core/fsfromfsviacs" - - fsc cfg "%s -a -o:lib.dll -g" cfg.fsc_flags ["lib.fs"] - - peverify cfg "lib.dll" - - csc cfg """/nologo /target:library /r:"%s" /r:lib.dll /out:lib2.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib2.cs"] - - csc cfg """/nologo /target:library /r:"%s" /out:lib3.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib3.cs"] - - // all features available in preview - fsc cfg "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - // Same with library references the other way around - fsc cfg "%s -r:lib.dll -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - // Same without the reference to lib.dll - testing an incomplete reference set, but only compiling a subset of the code - fsc cfg "%s --define:NO_LIB_REFERENCE -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - // some features missing in 4.7 - for version in ["4.7"] do - let outFile = "compilation.langversion.old.output.txt" - let expectedFile = "compilation.langversion.old.output.bsl" - fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --langversion:%s" cfg.fsc_flags version ["test.fsx"] - - let diffs = fsdiff cfg outFile expectedFile - match diffs with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) - - // check error messages for some cases - let outFile = "compilation.errors.output.txt" - let expectedFile = "compilation.errors.output.bsl" - fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --define:CHECK_ERRORS" cfg.fsc_flags ["test.fsx"] - - let diffs = fsdiff cfg outFile expectedFile - match diffs with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs) - - [] - let ``fsi-reference`` () = - - let cfg = testConfig "core/fsi-reference" - - begin - use testOkFile = fileguard cfg "test.ok" - fsc cfg @"--target:library -o:ImplementationAssembly\ReferenceAssemblyExample.dll" ["ImplementationAssembly.fs"] - fsc cfg @"--target:library -o:ReferenceAssembly\ReferenceAssemblyExample.dll" ["ReferenceAssembly.fs"] - fsiStdin cfg "test.fsx" "" [] - testOkFile.CheckExists() - end - - [] - let ``fsi-reload`` () = - let cfg = testConfig "core/fsi-reload" - - begin - use testOkFile = fileguard cfg "test.ok" - fsiStdin cfg "test1.ml" " --langversion:5.0 --mlcompatibility --maxerrors:1" [] - testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load1.fsx"] - testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load2.fsx"] - testOkFile.CheckExists() - end - - fsc cfg "" ["load1.fsx"] - fsc cfg "" ["load2.fsx"] - - - [] - let fsiAndModifiers () = - let cfg = testConfig "core/fsiAndModifiers" - - do if fileExists cfg "TestLibrary.dll" then rm cfg "TestLibrary.dll" - - fsiStdin cfg "prepare.fsx" "--maxerrors:1" [] - - use testOkFile = fileguard cfg "test.ok" - - fsiStdin cfg "test.fsx" "--maxerrors:1" [] - - testOkFile.CheckExists() - - [] - let ``genericmeasures-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/genericmeasures" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - - - [] - let hiding () = - let cfg = testConfig "core/hiding" - - fsc cfg "%s -a --optimize --langversion:5.0 --mlcompatibility -o:lib.dll" cfg.fsc_flags ["lib.mli";"lib.ml";"libv.ml"] - - peverify cfg "lib.dll" - - fsc cfg "%s -a --optimize --langversion:5.0 --mlcompatibility -r:lib.dll -o:lib2.dll" cfg.fsc_flags ["lib2.mli";"lib2.ml";"lib3.ml"] - - peverify cfg "lib2.dll" - - fsc cfg "%s --optimize --langversion:5.0 --mlcompatibility -r:lib.dll -r:lib2.dll -o:client.exe" cfg.fsc_flags ["client.ml"] - - peverify cfg "client.exe" - - [] - let ``innerpoly-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/innerpoly" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - - [] - let queriesCustomQueryOps () = - let cfg = testConfig "core/queriesCustomQueryOps" - - fsc cfg """%s -o:test.exe -g""" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - fsc cfg """%s --optimize -o:test--optimize.exe -g""" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test--optimize.exe" - - singleNegTest cfg "negativetest" - - begin - use testOkFile = fileguard cfg "test.ok" - - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - - testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test.ok" - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() - end - - begin - use testOkFile = fileguard cfg "test.ok" - - exec cfg ("." ++ "test--optimize.exe") "" - - testOkFile.CheckExists() - end - - // Debug with - // ..\..\..\..\debug\net40\bin\fsi.exe --nologo < test.fsx >a.out 2>a.err - // then - /// windiff output.stdout.bsl a.out - let runPrintingTest flag baseFile = - let diffFileOut = baseFile + ".stdout.txt" - let expectedFileOut = baseFile + ".stdout.bsl" - let diffFileErr = baseFile + ".stderr.txt" - let expectedFileErr = baseFile + ".stderr.bsl" - let cfg = testConfig "core/printing" - - if requireENCulture () then - - let ``fsi b 2>c`` = - // "%FSI%" %fsc_flags_errors_ok% --nologo z.raw.output.test.default.txt 2>&1 - let ``exec b 2>c`` (inFile, outFile, errFile) p = - Command.exec cfg.Directory cfg.EnvironmentVariables { Output = OutputAndError(Overwrite(outFile), Overwrite(errFile)); Input = Some(RedirectInput(inFile)); } p - >> checkResult - Printf.ksprintf (fun flags (inFile, outFile, errFile) -> Commands.fsi (``exec b 2>c`` (inFile, outFile, errFile)) cfg.FSI flags []) - - let fsc_flags_errors_ok = "" - - let rawFileOut = tryCreateTemporaryFileName () - let rawFileErr = tryCreateTemporaryFileName () - ``fsi b 2>c`` "%s --nologo --preferreduilang:en-US %s" fsc_flags_errors_ok flag ("test.fsx", rawFileOut, rawFileErr) - - let removeCDandHelp fromFile toFile = - File.ReadAllLines fromFile - |> Array.filter (fun s -> not (s.Contains(cfg.Directory))) - |> Array.filter (fun s -> not (s.Contains("--help' for options"))) - |> Array.filter (fun s -> not (s.Contains("[Loading"))) - |> Array.filter (fun s -> not (s.Contains("Binding session"))) - |> (fun lines -> File.WriteAllLines(getfullpath cfg toFile, lines)) - - removeCDandHelp rawFileOut diffFileOut - removeCDandHelp rawFileErr diffFileErr - - let withDefault defaultFile toFile = - if not (fileExists cfg toFile) then copy cfg defaultFile toFile - - expectedFileOut |> withDefault diffFileOut - expectedFileErr |> withDefault diffFileErr - - match fsdiff cfg diffFileOut expectedFileOut with - | "" -> () - | diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileOut expectedFileOut diffs) - - match fsdiff cfg diffFileErr expectedFileErr with - | "" -> () - | diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileErr expectedFileErr diffs) - - [] - let ``printing`` () = - runPrintingTest "--multiemit- --debug+" "output" - - // F# 5.0 changed some things printing output - [] - let ``printing-langversion47`` () = - runPrintingTest "--langversion:4.7" "output.47" - - // Output should not change with optimization off - [] - let ``printing-optimizeoff`` () = - runPrintingTest "--multiemit- --debug+ --optimize-" "output" - - // Legacy one-dynamic-assembly emit is the default for .NET Framework, which these tests are using - // Turning that off enables multi-assembly-emit. The printing test is useful for testing multi-assembly-emit - // as it feeds in many incremental fragments into stdin of the FSI process. - [] - let ``printing-multiemit`` () = - runPrintingTest "--multiemit+ --debug+" "output.multiemit" - - // Multi-assembly-emit establishes some slightly different rules regarding internals, and this - // needs to be tested with optimizations off. The output should not change. - [] - let ``printing-multiemit-optimizeoff`` () = - runPrintingTest "--multiemit+ --debug+ --optimize-" "output.multiemit" - - [] - let ``printing-width-1000`` () = - runPrintingTest "--use:preludePrintSize1000.fsx" "output.1000" - - [] - let ``printing-width-200`` () = - runPrintingTest "--use:preludePrintSize200.fsx" "output.200" - - [] - let ``printing-off`` () = - runPrintingTest "--use:preludeShowDeclarationValuesFalse.fsx" "output.off" - - [] - let ``printing-quiet`` () = - runPrintingTest "--quiet" "output.quiet" - - type SigningType = - | DelaySigned - | PublicSigned - | NotSigned - - let signedtest(programId:string, args:string, expectedSigning:SigningType) = - - let cfg = testConfig "core/signedtests" - let newFlags = cfg.fsc_flags + " " + args - - let exefile = programId + ".exe" - fsc cfg "%s -o:%s" newFlags exefile ["test.fs"] - - let assemblyPath = Path.Combine(cfg.Directory, exefile) - let assemblyName = AssemblyName.GetAssemblyName(assemblyPath) - let publicKeyToken = assemblyName.GetPublicKeyToken() - let isPublicKeyTokenPresent = not (Array.isEmpty publicKeyToken) - use exeStream = new FileStream(assemblyPath, FileMode.Open) - let peHeader = PEHeaders(exeStream) - let isSigned = peHeader.CorHeader.Flags.HasFlag(CorFlags.StrongNameSigned) - let actualSigning = - match isSigned, isPublicKeyTokenPresent with - | true, true-> SigningType.PublicSigned - | true, false -> failwith "unreachable" - | false, true -> SigningType.DelaySigned - | false, false -> SigningType.NotSigned - - Assert.AreEqual(expectedSigning, actualSigning) - - [] - let ``signedtest-1`` () = signedtest("test-unsigned", "", SigningType.NotSigned) - - [] - let ``signedtest-2`` () = signedtest("test-sha1-full-cl", "--keyfile:sha1full.snk", SigningType.PublicSigned) - - [] - let ``signedtest-3`` () = signedtest("test-sha256-full-cl", "--keyfile:sha256full.snk", SigningType.PublicSigned) - - [] - let ``signedtest-4`` () = signedtest("test-sha512-full-cl", "--keyfile:sha512full.snk", SigningType.PublicSigned) - - [] - let ``signedtest-5`` () = signedtest("test-sha1024-full-cl", "--keyfile:sha1024full.snk", SigningType.PublicSigned) - - [] - let ``signedtest-6`` () = signedtest("test-sha1-delay-cl", "--keyfile:sha1delay.snk --delaysign", SigningType.DelaySigned) - - [] - let ``signedtest-7`` () = signedtest("test-sha256-delay-cl", "--keyfile:sha256delay.snk --delaysign", SigningType.DelaySigned) - - [] - let ``signedtest-8`` () = signedtest("test-sha512-delay-cl", "--keyfile:sha512delay.snk --delaysign", SigningType.DelaySigned) - - [] - let ``signedtest-9`` () = signedtest("test-sha1024-delay-cl", "--keyfile:sha1024delay.snk --delaysign", SigningType.DelaySigned) - - // Test SHA1 key full signed Attributes - [] - let ``signedtest-10`` () = signedtest("test-sha1-full-attributes", "--define:SHA1", SigningType.PublicSigned) - - // Test SHA1 key delayl signed Attributes - [] - let ``signedtest-11`` () = signedtest("test-sha1-delay-attributes", "--keyfile:sha1delay.snk --define:SHA1 --define:DELAY", SigningType.DelaySigned) - - [] - let ``signedtest-12`` () = signedtest("test-sha256-full-attributes", "--define:SHA256", SigningType.PublicSigned) - - // Test SHA 256 bit key delay signed Attributes - [] - let ``signedtest-13`` () = signedtest("test-sha256-delay-attributes", "--define:SHA256 --define:DELAY", SigningType.DelaySigned) - - // Test SHA 512 bit key fully signed Attributes - [] - let ``signedtest-14`` () = signedtest("test-sha512-full-attributes", "--define:SHA512", SigningType.PublicSigned) - - // Test SHA 512 bit key delay signed Attributes - [] - let ``signedtest-15`` () = signedtest("test-sha512-delay-attributes", "--define:SHA512 --define:DELAY", SigningType.DelaySigned) - - // Test SHA 1024 bit key fully signed Attributes - [] - let ``signedtest-16`` () = signedtest("test-sha1024-full-attributes", "--define:SHA1024", SigningType.PublicSigned) -#endif - -#if !NETCOREAPP - [] - let quotes () = - let cfg = testConfig "core/quotes" - - - csc cfg """/nologo /target:library /out:cslib.dll""" ["cslib.cs"] - - fsc cfg "%s -o:test.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - begin - use testOkFile = fileguard cfg "test.ok" - exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() - end - - fsc cfg "%s -o:test-with-debug-data.exe --quotations-debug+ -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test-with-debug-data.exe" - - fsc cfg "%s --optimize -o:test--optimize.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test--optimize.exe" - - begin - use testOkFile = fileguard cfg "test.ok" - - fsi cfg "%s -r cslib.dll" cfg.fsi_flags ["test.fsx"] - - testOkFile.CheckExists() - end + fsiStdin cfg "test1.ml" " --langversion:5.0 --mlcompatibility --maxerrors:1" [] + testOkFile.CheckExists() + end begin use testOkFile = fileguard cfg "test.ok" - exec cfg ("." ++ "test-with-debug-data.exe") "" + fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load1.fsx"] testOkFile.CheckExists() end begin - use testOkFile = fileguard cfg "test.ok" - exec cfg ("." ++ "test--optimize.exe") "" - testOkFile.CheckExists() - end - - [] - let parsing () = - let cfg = testConfig "core/parsing" - - fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:crlf.dll -g" cfg.fsc_flags ["crlf.ml"] - - fsc cfg "%s --langversion:5.0 --mlcompatibility -o:toplet.exe -g" cfg.fsc_flags ["toplet.ml"] - - peverify cfg "toplet.exe" - - [] - let unicode () = - let cfg = testConfig "core/unicode" - - fsc cfg "%s -a -o:kanji-unicode-utf8-nosig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - - fsc cfg "%s -a -o:kanji-unicode-utf8-nosig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - - fsc cfg "%s -a -o:kanji-unicode-utf16.dll -g" cfg.fsc_flags ["kanji-unicode-utf16.fs"] - - fsc cfg "%s -a --codepage:65000 -o:kanji-unicode-utf7-codepage-65000.dll -g" cfg.fsc_flags ["kanji-unicode-utf7-codepage-65000.fs"] - - fsc cfg "%s -a -o:kanji-unicode-utf8-withsig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - - fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - - fsi cfg "%s --utf8output --codepage:65001" cfg.fsi_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - - fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - - fsi cfg "%s --utf8output --codepage:65000" cfg.fsi_flags ["kanji-unicode-utf7-codepage-65000.fs"] - - fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf16.fs"] - - - [] - let internalsvisible () = - let cfg = testConfig "core/internalsvisible" - - // Compiling F# Library - fsc cfg "%s --version:1.2.3 --keyfile:key.snk --langversion:5.0 --mlcompatibility -a --optimize -o:library.dll" cfg.fsc_flags ["library.fsi"; "library.fs"] - - peverify cfg "library.dll" - - // Compiling C# Library - csc cfg "/target:library /keyfile:key.snk /out:librarycs.dll" ["librarycs.cs"] - - peverify cfg "librarycs.dll" - - // Compiling F# main referencing C# and F# libraries - fsc cfg "%s --version:1.2.3 --keyfile:key.snk --optimize --langversion:5.0 --mlcompatibility -r:library.dll -r:librarycs.dll -o:main.exe" cfg.fsc_flags ["main.fs"] - - peverify cfg "main.exe" - - // Run F# main. Quick test! - exec cfg ("." ++ "main.exe") "" - - - // Repro for https://github.com/dotnet/fsharp/issues/1298 - [] - let fileorder () = - let cfg = testConfig "core/fileorder" - - log "== Compiling F# Library and Code, when empty file libfile2.fs IS NOT included" - fsc cfg "%s -a --optimize -o:lib.dll " cfg.fsc_flags ["libfile1.fs"] - - peverify cfg "lib.dll" - - fsc cfg "%s -r:lib.dll -o:test.exe" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - log "== Compiling F# Library and Code, when empty file libfile2.fs IS included" - fsc cfg "%s -a --optimize -o:lib2.dll " cfg.fsc_flags ["libfile1.fs"; "libfile2.fs"] - - peverify cfg "lib2.dll" - - fsc cfg "%s -r:lib2.dll -o:test2.exe" cfg.fsc_flags ["test.fsx"] - - peverify cfg "test2.exe" - - exec cfg ("." ++ "test2.exe") "" - - // Repro for https://github.com/dotnet/fsharp/issues/2679 - [] - let ``add files with same name from different folders`` () = - let cfg = testConfig "core/samename" - - log "== Compiling F# Code with files with same name in different folders" - fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fs"; "folder1/b.fs"; "folder2/a.fs"; "folder2/b.fs"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - [] - let ``add files with same name from different folders including signature files`` () = - let cfg = testConfig "core/samename" - - log "== Compiling F# Code with files with same name in different folders including signature files" - fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fsi"; "folder1/a.fs"; "folder1/b.fsi"; "folder1/b.fs"; "folder2/a.fsi"; "folder2/a.fs"; "folder2/b.fsi"; "folder2/b.fs"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - [] - let ``add files with same name from different folders including signature files that are not synced`` () = - let cfg = testConfig "core/samename" - - log "== Compiling F# Code with files with same name in different folders including signature files" - fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fsi"; "folder1/a.fs"; "folder1/b.fs"; "folder2/a.fsi"; "folder2/a.fs"; "folder2/b.fsi"; "folder2/b.fs"] - - peverify cfg "test.exe" - - exec cfg ("." ++ "test.exe") "" - - [] - let ``libtest-FSI_NETFX_STDIN`` () = singleTestBuildAndRun "core/libtest" FSI_NETFX_STDIN - - [] - let ``libtest-unoptimized codegen`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG - - [] - let ``libtest-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/libtest" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - - [] - let ``no-warn-2003-tests`` () = - // see https://github.com/dotnet/fsharp/issues/3139 - let cfg = testConfig "core/versionAttributes" - let stdoutPath = "out.stdout.txt" |> getfullpath cfg - let stderrPath = "out.stderr.txt" |> getfullpath cfg - let stderrBaseline = "out.stderr.bsl" |> getfullpath cfg - let stdoutBaseline = "out.stdout.bsl" |> getfullpath cfg - let echo text = - Commands.echoAppendToFile cfg.Directory text stdoutPath - Commands.echoAppendToFile cfg.Directory text stderrPath - - File.WriteAllText(stdoutPath, "") - File.WriteAllText(stderrPath, "") - - echo "Test 1=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo" ["NoWarn2003.fs"] - - echo "Test 2=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo" ["NoWarn2003_2.fs"] - - echo "Test 3=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_1.fs"] - - echo "Test 4=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_2.fs"] + use testOkFile = fileguard cfg "test.ok" + fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load2.fsx"] + testOkFile.CheckExists() + end - echo "Test 5=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_3.fs"] + fsc cfg "" ["load1.fsx"] + fsc cfg "" ["load2.fsx"] - echo "Test 6=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_1.fs"] - echo "Test 7=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_2.fs"] + [] + let fsiAndModifiers () = + let cfg = testConfig "core/fsiAndModifiers" - echo "Test 8=================================================" - fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_3.fs"] + do if fileExists cfg "TestLibrary.dll" then rm cfg "TestLibrary.dll" - let normalizePaths f = - let text = File.ReadAllText(f) - let dummyPath = @"D:\staging\staging\src\tests\fsharp\core\load-script" - let contents = System.Text.RegularExpressions.Regex.Replace(text, System.Text.RegularExpressions.Regex.Escape(cfg.Directory), dummyPath) - File.WriteAllText(f, contents) + fsiStdin cfg "prepare.fsx" "--maxerrors:1" [] - normalizePaths stdoutPath - normalizePaths stderrPath + use testOkFile = fileguard cfg "test.ok" - let diffs = fsdiff cfg stdoutPath stdoutBaseline + fsiStdin cfg "test.fsx" "--maxerrors:1" [] - match diffs with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stdoutPath stdoutBaseline diffs) + testOkFile.CheckExists() - let diffs2 = fsdiff cfg stderrPath stderrBaseline + [] + let ``genericmeasures-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/genericmeasures" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - match diffs2 with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stderrPath stderrBaseline diffs2) [] - let ``load-script`` () = - let cfg = testConfig "core/load-script" + let hiding () = + let cfg = testConfig "core/hiding" - let stdoutPath = "out.stdout.txt" |> getfullpath cfg - let stderrPath = "out.stderr.txt" |> getfullpath cfg - let stderrBaseline = "out.stderr.bsl" |> getfullpath cfg - let stdoutBaseline = "out.stdout.bsl" |> getfullpath cfg + fsc cfg "%s -a --optimize --langversion:5.0 --mlcompatibility -o:lib.dll" cfg.fsc_flags ["lib.mli";"lib.ml";"libv.ml"] - let appendToFile from = Commands.appendToFile cfg.Directory from stdoutPath - let echo text = Commands.echoAppendToFile cfg.Directory text stdoutPath + peverify cfg "lib.dll" - File.WriteAllText(stdoutPath, "") - File.WriteAllText(stderrPath, "") + fsc cfg "%s -a --optimize --langversion:5.0 --mlcompatibility -r:lib.dll -o:lib2.dll" cfg.fsc_flags ["lib2.mli";"lib2.ml";"lib3.ml"] - do if fileExists cfg "3.exe" then getfullpath cfg "3.exe" |> File.Delete + peverify cfg "lib2.dll" - ["1.fsx"; "2.fsx"; "3.fsx"] |> List.iter appendToFile + fsc cfg "%s --optimize --langversion:5.0 --mlcompatibility -r:lib.dll -r:lib2.dll -o:client.exe" cfg.fsc_flags ["client.ml"] - echo "Test 1=================================================" + peverify cfg "client.exe" - fscAppend cfg stdoutPath stderrPath "--nologo" ["3.fsx"] + [] + let ``innerpoly-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/innerpoly" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "3.exe") "" + [] + let queriesCustomQueryOps () = + let cfg = testConfig "core/queriesCustomQueryOps" - rm cfg "3.exe" + fsc cfg """%s -o:test.exe -g""" cfg.fsc_flags ["test.fsx"] - echo "Test 2=================================================" + peverify cfg "test.exe" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["3.fsx"] + fsc cfg """%s --optimize -o:test--optimize.exe -g""" cfg.fsc_flags ["test.fsx"] - echo "Test 3=================================================" + peverify cfg "test--optimize.exe" - fsiStdinAppendBothIgnoreExitCode cfg stdoutPath stderrPath "pipescr" "--nologo" [] + singleNegTest cfg "negativetest" - echo "Test 4=================================================" + begin + use testOkFile = fileguard cfg "test.ok" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["usesfsi.fsx"] + fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - echo "Test 5=================================================" + testOkFile.CheckExists() + end - fscAppendIgnoreExitCode cfg stdoutPath stderrPath "--nologo" ["usesfsi.fsx"] + begin + use testOkFile = fileguard cfg "test.ok" - echo "Test 6=================================================" + exec cfg ("." ++ "test.exe") "" - fscAppend cfg stdoutPath stderrPath "--nologo -r \"%s\"" cfg.FSharpCompilerInteractiveSettings ["usesfsi.fsx"] + testOkFile.CheckExists() + end - echo "Test 7=================================================" + begin + use testOkFile = fileguard cfg "test.ok" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["1.fsx";"2.fsx";"3.fsx"] + exec cfg ("." ++ "test--optimize.exe") "" - echo "Test 8=================================================" + testOkFile.CheckExists() + end - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["3.fsx";"2.fsx";"1.fsx"] + // Debug with + // ..\..\..\..\debug\net40\bin\fsi.exe --nologo < test.fsx >a.out 2>a.err + // then + /// windiff output.stdout.bsl a.out + let runPrintingTest flag baseFile = + let diffFileOut = baseFile + ".stdout.txt" + let expectedFileOut = baseFile + ".stdout.bsl" + let diffFileErr = baseFile + ".stderr.txt" + let expectedFileErr = baseFile + ".stderr.bsl" + let cfg = testConfig "core/printing" - echo "Test 9=================================================" + if requireENCulture () then - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["multiple-load-1.fsx"] + let ``fsi b 2>c`` = + // "%FSI%" %fsc_flags_errors_ok% --nologo z.raw.output.test.default.txt 2>&1 + let ``exec b 2>c`` (inFile, outFile, errFile) p = + Command.exec cfg.Directory cfg.EnvironmentVariables { Output = OutputAndError(Overwrite(outFile), Overwrite(errFile)); Input = Some(RedirectInput(inFile)); } p + >> checkResult + Printf.ksprintf (fun flags (inFile, outFile, errFile) -> Commands.fsi (``exec b 2>c`` (inFile, outFile, errFile)) cfg.FSI flags []) - echo "Test 10=================================================" + let fsc_flags_errors_ok = "" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["multiple-load-2.fsx"] + let rawFileOut = tryCreateTemporaryFileName () + let rawFileErr = tryCreateTemporaryFileName () + ``fsi b 2>c`` "%s --nologo --preferreduilang:en-US %s" fsc_flags_errors_ok flag ("test.fsx", rawFileOut, rawFileErr) - echo "Test 11=================================================" + let removeCDandHelp fromFile toFile = + File.ReadAllLines fromFile + |> Array.filter (fun s -> not (s.Contains(cfg.Directory))) + |> Array.filter (fun s -> not (s.Contains("--help' for options"))) + |> Array.filter (fun s -> not (s.Contains("[Loading"))) + |> Array.filter (fun s -> not (s.Contains("Binding session"))) + |> (fun lines -> File.WriteAllLines(getfullpath cfg toFile, lines)) - fscAppend cfg stdoutPath stderrPath "--nologo" ["FlagCheck.fs"] + removeCDandHelp rawFileOut diffFileOut + removeCDandHelp rawFileErr diffFileErr - execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "FlagCheck.exe") "" + let withDefault defaultFile toFile = + if not (fileExists cfg toFile) then copy cfg defaultFile toFile - rm cfg "FlagCheck.exe" + expectedFileOut |> withDefault diffFileOut + expectedFileErr |> withDefault diffFileErr - echo "Test 12=================================================" + match fsdiff cfg diffFileOut expectedFileOut with + | "" -> () + | diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileOut expectedFileOut diffs) - fscAppend cfg stdoutPath stderrPath "-o FlagCheckScript.exe --nologo" ["FlagCheck.fsx"] + match fsdiff cfg diffFileErr expectedFileErr with + | "" -> () + | diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileErr expectedFileErr diffs) - execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "FlagCheckScript.exe") "" + [] + let ``printing`` () = + runPrintingTest "--multiemit- --debug+" "output" - rm cfg "FlagCheckScript.exe" + // F# 5.0 changed some things printing output + [] + let ``printing-langversion47`` () = + runPrintingTest "--langversion:4.7" "output.47" - echo "Test 13=================================================" + // Output should not change with optimization off + [] + let ``printing-optimizeoff`` () = + runPrintingTest "--multiemit- --debug+ --optimize-" "output" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["load-FlagCheckFs.fsx"] + // Legacy one-dynamic-assembly emit is the default for .NET Framework, which these tests are using + // Turning that off enables multi-assembly-emit. The printing test is useful for testing multi-assembly-emit + // as it feeds in many incremental fragments into stdin of the FSI process. + [] + let ``printing-multiemit`` () = + runPrintingTest "--multiemit+ --debug+" "output.multiemit" - echo "Test 14=================================================" + // Multi-assembly-emit establishes some slightly different rules regarding internals, and this + // needs to be tested with optimizations off. The output should not change. + [] + let ``printing-multiemit-optimizeoff`` () = + runPrintingTest "--multiemit+ --debug+ --optimize-" "output.multiemit" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["FlagCheck.fsx"] + [] + let ``printing-width-1000`` () = + runPrintingTest "--use:preludePrintSize1000.fsx" "output.1000" - echo "Test 15=================================================" + [] + let ``printing-width-200`` () = + runPrintingTest "--use:preludePrintSize200.fsx" "output.200" - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["ProjectDriver.fsx"] + [] + let ``printing-off`` () = + runPrintingTest "--use:preludeShowDeclarationValuesFalse.fsx" "output.off" - echo "Test 16=================================================" + [] + let ``printing-quiet`` () = + runPrintingTest "--quiet" "output.quiet" - fscAppend cfg stdoutPath stderrPath "--nologo" ["ProjectDriver.fsx"] + type SigningType = + | DelaySigned + | PublicSigned + | NotSigned - execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "ProjectDriver.exe") "" + let signedtest(programId:string, args:string, expectedSigning:SigningType) = - rm cfg "ProjectDriver.exe" + let cfg = testConfig "core/signedtests" + let newFlags = cfg.fsc_flags + " " + args - echo "Test 17=================================================" + let exefile = programId + ".exe" + fsc cfg "%s -o:%s" newFlags exefile ["test.fs"] - fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["load-IncludeNoWarn211.fsx"] + let assemblyPath = Path.Combine(cfg.Directory, exefile) + let assemblyName = AssemblyName.GetAssemblyName(assemblyPath) + let publicKeyToken = assemblyName.GetPublicKeyToken() + let isPublicKeyTokenPresent = not (Array.isEmpty publicKeyToken) + use exeStream = new FileStream(assemblyPath, FileMode.Open) + let peHeader = PEHeaders(exeStream) + let isSigned = peHeader.CorHeader.Flags.HasFlag(CorFlags.StrongNameSigned) + let actualSigning = + match isSigned, isPublicKeyTokenPresent with + | true, true-> SigningType.PublicSigned + | true, false -> failwith "unreachable" + | false, true -> SigningType.DelaySigned + | false, false -> SigningType.NotSigned - echo "Done ==================================================" + Assert.AreEqual(expectedSigning, actualSigning) - // an extra case - fsiExpectFail cfg "" ["loadfail3.fsx"] + [] + let ``signedtest-1`` () = signedtest("test-unsigned", "", SigningType.NotSigned) - let normalizePaths f = - let text = File.ReadAllText(f) - let dummyPath = @"D:\staging\staging\src\tests\fsharp\core\load-script" - let contents = System.Text.RegularExpressions.Regex.Replace(text, System.Text.RegularExpressions.Regex.Escape(cfg.Directory), dummyPath) - File.WriteAllText(f, contents) + [] + let ``signedtest-2`` () = signedtest("test-sha1-full-cl", "--keyfile:sha1full.snk", SigningType.PublicSigned) - normalizePaths stdoutPath - normalizePaths stderrPath + [] + let ``signedtest-3`` () = signedtest("test-sha256-full-cl", "--keyfile:sha256full.snk", SigningType.PublicSigned) - let diffs = fsdiff cfg stdoutPath stdoutBaseline + [] + let ``signedtest-4`` () = signedtest("test-sha512-full-cl", "--keyfile:sha512full.snk", SigningType.PublicSigned) - match diffs with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stdoutPath stdoutBaseline diffs) + [] + let ``signedtest-5`` () = signedtest("test-sha1024-full-cl", "--keyfile:sha1024full.snk", SigningType.PublicSigned) - let diffs2 = fsdiff cfg stderrPath stderrBaseline + [] + let ``signedtest-6`` () = signedtest("test-sha1-delay-cl", "--keyfile:sha1delay.snk --delaysign", SigningType.DelaySigned) - match diffs2 with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stderrPath stderrBaseline diffs2) -#endif + [] + let ``signedtest-7`` () = signedtest("test-sha256-delay-cl", "--keyfile:sha256delay.snk --delaysign", SigningType.DelaySigned) + [] + let ``signedtest-8`` () = signedtest("test-sha512-delay-cl", "--keyfile:sha512delay.snk --delaysign", SigningType.DelaySigned) + [] + let ``signedtest-9`` () = signedtest("test-sha1024-delay-cl", "--keyfile:sha1024delay.snk --delaysign", SigningType.DelaySigned) -#if !NETCOREAPP - [] - let ``measures-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/measures" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL + // Test SHA1 key full signed Attributes + [] + let ``signedtest-10`` () = signedtest("test-sha1-full-attributes", "--define:SHA1", SigningType.PublicSigned) - [] - let ``members-basics-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/members/basics" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL + // Test SHA1 key delayl signed Attributes + [] + let ``signedtest-11`` () = signedtest("test-sha1-delay-attributes", "--keyfile:sha1delay.snk --define:SHA1 --define:DELAY", SigningType.DelaySigned) - [] - let ``members-basics-hw`` () = singleTestBuildAndRun "core/members/basics-hw" FSC_OPTIMIZED + [] + let ``signedtest-12`` () = signedtest("test-sha256-full-attributes", "--define:SHA256", SigningType.PublicSigned) - [] - let ``members-basics-hw-mutrec`` () = singleTestBuildAndRun "core/members/basics-hw-mutrec" FSC_OPTIMIZED + // Test SHA 256 bit key delay signed Attributes + [] + let ``signedtest-13`` () = signedtest("test-sha256-delay-attributes", "--define:SHA256 --define:DELAY", SigningType.DelaySigned) - [] - let ``members-incremental-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental" FSC_OPTIMIZED + // Test SHA 512 bit key fully signed Attributes + [] + let ``signedtest-14`` () = signedtest("test-sha512-full-attributes", "--define:SHA512", SigningType.PublicSigned) - [] - let ``members-incremental-FSI`` () = singleTestBuildAndRun "core/members/incremental" FSI + // Test SHA 512 bit key delay signed Attributes + [] + let ``signedtest-15`` () = signedtest("test-sha512-delay-attributes", "--define:SHA512 --define:DELAY", SigningType.DelaySigned) - [] - let ``members-incremental-hw-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental-hw" FSC_OPTIMIZED + // Test SHA 1024 bit key fully signed Attributes + [] + let ``signedtest-16`` () = signedtest("test-sha1024-full-attributes", "--define:SHA1024", SigningType.PublicSigned) +#endif +#if !NETCOREAPP [] - let ``members-incremental-hw-FSI`` () = singleTestBuildAndRun "core/members/incremental-hw" FSI + let quotes () = + let cfg = testConfig "core/quotes" - [] - let ``members-incremental-hw-mutrec-FSC_OPTIMIZED`` () = singleTestBuildAndRun "core/members/incremental-hw-mutrec" FSC_OPTIMIZED - [] - let queriesLeafExpressionConvert () = - let cfg = testConfig "core/queriesLeafExpressionConvert" + csc cfg """/nologo /target:library /out:cslib.dll""" ["cslib.cs"] - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] + fsc cfg "%s -o:test.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] peverify cfg "test.exe" - fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] + begin + use testOkFile = fileguard cfg "test.ok" + exec cfg ("." ++ "test.exe") "" + testOkFile.CheckExists() + end - peverify cfg "test--optimize.exe" + fsc cfg "%s -o:test-with-debug-data.exe --quotations-debug+ -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] - use testOkFile = fileguard cfg "test.ok" + peverify cfg "test-with-debug-data.exe" - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] + fsc cfg "%s --optimize -o:test--optimize.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"] - testOkFile.CheckExists() + peverify cfg "test--optimize.exe" - use testOkFile2 = fileguard cfg "test.ok" + begin + use testOkFile = fileguard cfg "test.ok" - exec cfg ("." ++ "test.exe") "" + fsi cfg "%s -r cslib.dll" cfg.fsi_flags ["test.fsx"] - testOkFile2.CheckExists() + testOkFile.CheckExists() + end - use testOkFile3 = fileguard cfg "test.ok" + begin + use testOkFile = fileguard cfg "test.ok" + exec cfg ("." ++ "test-with-debug-data.exe") "" + testOkFile.CheckExists() + end - exec cfg ("." ++ "test--optimize.exe") "" + begin + use testOkFile = fileguard cfg "test.ok" + exec cfg ("." ++ "test--optimize.exe") "" + testOkFile.CheckExists() + end - testOkFile3.CheckExists() + [] + let parsing () = + let cfg = testConfig "core/parsing" + fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:crlf.dll -g" cfg.fsc_flags ["crlf.ml"] - [] - let queriesNullableOperators () = - let cfg = testConfig "core/queriesNullableOperators" + fsc cfg "%s --langversion:5.0 --mlcompatibility -o:toplet.exe -g" cfg.fsc_flags ["toplet.ml"] - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] + peverify cfg "toplet.exe" - peverify cfg "test.exe" + [] + let unicode () = + let cfg = testConfig "core/unicode" - fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] + fsc cfg "%s -a -o:kanji-unicode-utf8-nosig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - peverify cfg "test--optimize.exe" + fsc cfg "%s -a -o:kanji-unicode-utf8-nosig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - testOkFile.CheckExists() + fsc cfg "%s -a -o:kanji-unicode-utf16.dll -g" cfg.fsc_flags ["kanji-unicode-utf16.fs"] - use testOkFile2 = fileguard cfg "test.ok" - exec cfg ("." ++ "test.exe") "" - testOkFile2.CheckExists() + fsc cfg "%s -a --codepage:65000 -o:kanji-unicode-utf7-codepage-65000.dll -g" cfg.fsc_flags ["kanji-unicode-utf7-codepage-65000.fs"] - use testOkFile3 = fileguard cfg "test.ok" - exec cfg ("." ++ "test--optimize.exe") "" - testOkFile3.CheckExists() + fsc cfg "%s -a -o:kanji-unicode-utf8-withsig-codepage-65001.dll -g" cfg.fsc_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - [] - let queriesOverIEnumerable () = - let cfg = testConfig "core/queriesOverIEnumerable" + fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf8-nosig-codepage-65001.fs"] - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] + fsi cfg "%s --utf8output --codepage:65001" cfg.fsi_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - peverify cfg "test.exe" + fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf8-withsig-codepage-65001.fs"] - fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] + fsi cfg "%s --utf8output --codepage:65000" cfg.fsi_flags ["kanji-unicode-utf7-codepage-65000.fs"] - peverify cfg "test--optimize.exe" + fsi cfg "%s --utf8output" cfg.fsi_flags ["kanji-unicode-utf16.fs"] - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] + [] + let internalsvisible () = + let cfg = testConfig "core/internalsvisible" - testOkFile.CheckExists() + // Compiling F# Library + fsc cfg "%s --version:1.2.3 --keyfile:key.snk --langversion:5.0 --mlcompatibility -a --optimize -o:library.dll" cfg.fsc_flags ["library.fsi"; "library.fs"] - use testOkFile2 = fileguard cfg "test.ok" + peverify cfg "library.dll" - exec cfg ("." ++ "test.exe") "" + // Compiling C# Library + csc cfg "/target:library /keyfile:key.snk /out:librarycs.dll" ["librarycs.cs"] - testOkFile2.CheckExists() + peverify cfg "librarycs.dll" - use testOkFile3 = fileguard cfg "test.ok" + // Compiling F# main referencing C# and F# libraries + fsc cfg "%s --version:1.2.3 --keyfile:key.snk --optimize --langversion:5.0 --mlcompatibility -r:library.dll -r:librarycs.dll -o:main.exe" cfg.fsc_flags ["main.fs"] - exec cfg ("." ++ "test--optimize.exe") "" + peverify cfg "main.exe" + + // Run F# main. Quick test! + exec cfg ("." ++ "main.exe") "" - testOkFile3.CheckExists() + // Repro for https://github.com/dotnet/fsharp/issues/1298 [] - let queriesOverIQueryable () = - let cfg = testConfig "core/queriesOverIQueryable" + let fileorder () = + let cfg = testConfig "core/fileorder" - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] + log "== Compiling F# Library and Code, when empty file libfile2.fs IS NOT included" + fsc cfg "%s -a --optimize -o:lib.dll " cfg.fsc_flags ["libfile1.fs"] - peverify cfg "test.exe" + peverify cfg "lib.dll" - fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] + fsc cfg "%s -r:lib.dll -o:test.exe" cfg.fsc_flags ["test.fsx"] - peverify cfg "test--optimize.exe" + peverify cfg "test.exe" - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] + exec cfg ("." ++ "test.exe") "" - testOkFile.CheckExists() + log "== Compiling F# Library and Code, when empty file libfile2.fs IS included" + fsc cfg "%s -a --optimize -o:lib2.dll " cfg.fsc_flags ["libfile1.fs"; "libfile2.fs"] + peverify cfg "lib2.dll" - use testOkFile2 = fileguard cfg "test.ok" + fsc cfg "%s -r:lib2.dll -o:test2.exe" cfg.fsc_flags ["test.fsx"] - exec cfg ("." ++ "test.exe") "" + peverify cfg "test2.exe" - testOkFile2.CheckExists() + exec cfg ("." ++ "test2.exe") "" + // Repro for https://github.com/dotnet/fsharp/issues/2679 + [] + let ``add files with same name from different folders`` () = + let cfg = testConfig "core/samename" - use testOkFile3 = fileguard cfg "test.ok" - exec cfg ("." ++ "test--optimize.exe") "" + log "== Compiling F# Code with files with same name in different folders" + fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fs"; "folder1/b.fs"; "folder2/a.fs"; "folder2/b.fs"] - testOkFile3.CheckExists() + peverify cfg "test.exe" + exec cfg ("." ++ "test.exe") "" [] - let quotesDebugInfo () = - let cfg = testConfig "core/quotesDebugInfo" + let ``add files with same name from different folders including signature files`` () = + let cfg = testConfig "core/samename" - fsc cfg "%s --quotations-debug+ --optimize -o:test.exe -g" cfg.fsc_flags ["test.fsx"] + log "== Compiling F# Code with files with same name in different folders including signature files" + fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fsi"; "folder1/a.fs"; "folder1/b.fsi"; "folder1/b.fs"; "folder2/a.fsi"; "folder2/a.fs"; "folder2/b.fsi"; "folder2/b.fs"] peverify cfg "test.exe" - fsc cfg "%s --quotations-debug+ --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] + exec cfg ("." ++ "test.exe") "" - peverify cfg "test--optimize.exe" + [] + let ``add files with same name from different folders including signature files that are not synced`` () = + let cfg = testConfig "core/samename" - use testOkFile = fileguard cfg "test.ok" - fsi cfg "%s --quotations-debug+" cfg.fsi_flags ["test.fsx"] + log "== Compiling F# Code with files with same name in different folders including signature files" + fsc cfg "%s -o:test.exe" cfg.fsc_flags ["folder1/a.fsi"; "folder1/a.fs"; "folder1/b.fs"; "folder2/a.fsi"; "folder2/a.fs"; "folder2/b.fsi"; "folder2/b.fs"] - testOkFile.CheckExists() + peverify cfg "test.exe" + exec cfg ("." ++ "test.exe") "" - use testOkFile2 = fileguard cfg "test.ok" + [] + let ``libtest-FSI_NETFX_STDIN`` () = singleTestBuildAndRun "core/libtest" FSI_NETFX_STDIN - exec cfg ("." ++ "test.exe") "" + [] + let ``libtest-unoptimized codegen`` () = singleTestBuildAndRun "core/libtest" FSC_DEBUG - testOkFile2.CheckExists() + [] + let ``libtest-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/libtest" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - use testOkFile3 = fileguard cfg "test.ok" + [] + let ``no-warn-2003-tests`` () = + // see https://github.com/dotnet/fsharp/issues/3139 + let cfg = testConfig "core/versionAttributes" + let stdoutPath = "out.stdout.txt" |> getfullpath cfg + let stderrPath = "out.stderr.txt" |> getfullpath cfg + let stderrBaseline = "out.stderr.bsl" |> getfullpath cfg + let stdoutBaseline = "out.stdout.bsl" |> getfullpath cfg + let echo text = + Commands.echoAppendToFile cfg.Directory text stdoutPath + Commands.echoAppendToFile cfg.Directory text stderrPath - exec cfg ("." ++ "test--optimize.exe") "" + File.WriteAllText(stdoutPath, "") + File.WriteAllText(stderrPath, "") - testOkFile3.CheckExists() + echo "Test 1=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo" ["NoWarn2003.fs"] + echo "Test 2=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo" ["NoWarn2003_2.fs"] - [] - let quotesInMultipleModules () = - let cfg = testConfig "core/quotesInMultipleModules" + echo "Test 3=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_1.fs"] - fsc cfg "%s -o:module1.dll --target:library" cfg.fsc_flags ["module1.fsx"] + echo "Test 4=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_2.fs"] - peverify cfg "module1.dll" + echo "Test 5=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo" ["Warn2003_3.fs"] - fsc cfg "%s -o:module2.exe -r:module1.dll" cfg.fsc_flags ["module2.fsx"] + echo "Test 6=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_1.fs"] - peverify cfg "module2.exe" + echo "Test 7=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_2.fs"] - fsc cfg "%s --staticlink:module1 -o:module2-staticlink.exe -r:module1.dll" cfg.fsc_flags ["module2.fsx"] + echo "Test 8=================================================" + fscAppend cfg stdoutPath stderrPath "--nologo --nowarn:2003" ["Warn2003_3.fs"] - peverify cfg "module2-staticlink.exe" + let normalizePaths f = + let text = File.ReadAllText(f) + let dummyPath = @"D:\staging\staging\src\tests\fsharp\core\load-script" + let contents = System.Text.RegularExpressions.Regex.Replace(text, System.Text.RegularExpressions.Regex.Escape(cfg.Directory), dummyPath) + File.WriteAllText(f, contents) - fsc cfg "%s -o:module1-opt.dll --target:library --optimize" cfg.fsc_flags ["module1.fsx"] + normalizePaths stdoutPath + normalizePaths stderrPath - peverify cfg "module1-opt.dll" + let diffs = fsdiff cfg stdoutPath stdoutBaseline - fsc cfg "%s -o:module2-opt.exe -r:module1-opt.dll --optimize" cfg.fsc_flags ["module2.fsx"] + match diffs with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stdoutPath stdoutBaseline diffs) - peverify cfg "module2-opt.exe" + let diffs2 = fsdiff cfg stderrPath stderrBaseline - use testOkFile = fileguard cfg "test.ok" + match diffs2 with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stderrPath stderrBaseline diffs2) - fsi cfg "%s -r module1.dll" cfg.fsi_flags ["module2.fsx"] + [] + let ``load-script`` () = + let cfg = testConfig "core/load-script" - testOkFile.CheckExists() + let stdoutPath = "out.stdout.txt" |> getfullpath cfg + let stderrPath = "out.stderr.txt" |> getfullpath cfg + let stderrBaseline = "out.stderr.bsl" |> getfullpath cfg + let stdoutBaseline = "out.stdout.bsl" |> getfullpath cfg + let appendToFile from = Commands.appendToFile cfg.Directory from stdoutPath + let echo text = Commands.echoAppendToFile cfg.Directory text stdoutPath - use testOkFile = fileguard cfg "test.ok" + File.WriteAllText(stdoutPath, "") + File.WriteAllText(stderrPath, "") - exec cfg ("." ++ "module2.exe") "" + do if fileExists cfg "3.exe" then getfullpath cfg "3.exe" |> File.Delete - testOkFile.CheckExists() + ["1.fsx"; "2.fsx"; "3.fsx"] |> List.iter appendToFile - use testOkFile = fileguard cfg "test.ok" + echo "Test 1=================================================" - exec cfg ("." ++ "module2-opt.exe") "" + fscAppend cfg stdoutPath stderrPath "--nologo" ["3.fsx"] - testOkFile.CheckExists() + execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "3.exe") "" - use testOkFile = fileguard cfg "test.ok" + rm cfg "3.exe" - exec cfg ("." ++ "module2-staticlink.exe") "" + echo "Test 2=================================================" - testOkFile.CheckExists() -#endif + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["3.fsx"] + echo "Test 3=================================================" + fsiStdinAppendBothIgnoreExitCode cfg stdoutPath stderrPath "pipescr" "--nologo" [] -#if !NETCOREAPP - [] - let refnormalization () = - let cfg = testConfig "core/refnormalization" + echo "Test 4=================================================" - // Prepare by building multiple versions of the test assemblies - fsc cfg @"%s --target:library -o:version1\DependentAssembly.dll -g --version:1.0.0.0 --keyfile:keyfile.snk" cfg.fsc_flags [@"DependentAssembly.fs"] - fsc cfg @"%s --target:library -o:version1\AscendentAssembly.dll -g --version:1.0.0.0 --keyfile:keyfile.snk -r:version1\DependentAssembly.dll" cfg.fsc_flags [@"AscendentAssembly.fs"] + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["usesfsi.fsx"] - fsc cfg @"%s --target:library -o:version2\DependentAssembly.dll -g --version:2.0.0.0" cfg.fsc_flags [@"DependentAssembly.fs"] - fsc cfg @"%s --target:library -o:version2\AscendentAssembly.dll -g --version:2.0.0.0 -r:version2\DependentAssembly.dll" cfg.fsc_flags [@"AscendentAssembly.fs"] + echo "Test 5=================================================" - //TestCase1 - // Build a program that references v2 of ascendent and v1 of dependent. - // Note that, even though ascendent v2 references dependent v2, the reference is marked as v1. - use TestOk = fileguard cfg "test.ok" - fsc cfg @"%s -o:test1.exe -r:version1\DependentAssembly.dll -r:version2\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] - exec cfg ("." ++ "test1.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-2.0.0.0" - TestOk.CheckExists() + fscAppendIgnoreExitCode cfg stdoutPath stderrPath "--nologo" ["usesfsi.fsx"] - //TestCase2 - // Build a program that references v1 of ascendent and v2 of dependent. - // Note that, even though ascendent v1 references dependent v1, the reference is marked as v2 which was passed in. - use TestOk = fileguard cfg "test.ok" - fsc cfg @"%s -o:test2.exe -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] - exec cfg ("." ++ "test2.exe") "DependentAssembly-2.0.0.0 AscendentAssembly-1.0.0.0" - TestOk.CheckExists() + echo "Test 6=================================================" - //TestCase3 - // Build a program that references v1 of ascendent and v1 and v2 of dependent. - // Verifies that compiler uses first version of a duplicate assembly passed on command line. - use TestOk = fileguard cfg "test.ok" - fsc cfg @"%s -o:test3.exe -r:version1\DependentAssembly.dll -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] - exec cfg ("." ++ "test3.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-1.0.0.0" - TestOk.CheckExists() + fscAppend cfg stdoutPath stderrPath "--nologo -r \"%s\"" cfg.FSharpCompilerInteractiveSettings ["usesfsi.fsx"] + echo "Test 7=================================================" - [] - let testResources () = - let cfg = testConfig "core/resources" + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["1.fsx";"2.fsx";"3.fsx"] - fsc cfg "%s --langversion:5.0 --mlcompatibility --resource:Resources.resources -o:test-embed.exe -g" cfg.fsc_flags ["test.fs"] + echo "Test 8=================================================" - peverify cfg "test-embed.exe" + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["3.fsx";"2.fsx";"1.fsx"] - fsc cfg "%s --langversion:5.0 --mlcompatibility --linkresource:Resources.resources -o:test-link.exe -g" cfg.fsc_flags ["test.fs"] + echo "Test 9=================================================" - peverify cfg "test-link.exe" + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["multiple-load-1.fsx"] - fsc cfg "%s --langversion:5.0 --mlcompatibility --resource:Resources.resources,ResourceName.resources -o:test-embed-named.exe -g" cfg.fsc_flags ["test.fs"] + echo "Test 10=================================================" - peverify cfg "test-embed-named.exe" + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["multiple-load-2.fsx"] - fsc cfg "%s --langversion:5.0 --mlcompatibility --linkresource:Resources.resources,ResourceName.resources -o:test-link-named.exe -g" cfg.fsc_flags ["test.fs"] + echo "Test 11=================================================" - peverify cfg "test-link-named.exe" + fscAppend cfg stdoutPath stderrPath "--nologo" ["FlagCheck.fs"] - exec cfg ("." ++ "test-embed.exe") "" + execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "FlagCheck.exe") "" - exec cfg ("." ++ "test-link.exe") "" + rm cfg "FlagCheck.exe" - exec cfg ("." ++ "test-link-named.exe") "ResourceName" + echo "Test 12=================================================" - exec cfg ("." ++ "test-embed-named.exe") "ResourceName" + fscAppend cfg stdoutPath stderrPath "-o FlagCheckScript.exe --nologo" ["FlagCheck.fsx"] - [] - let topinit () = - let cfg = testConfig "core/topinit" + execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "FlagCheckScript.exe") "" - fsc cfg "%s --optimize -o both69514.exe -g" cfg.fsc_flags ["lib69514.fs"; "app69514.fs"] + rm cfg "FlagCheckScript.exe" - peverify cfg "both69514.exe" + echo "Test 13=================================================" - fsc cfg "%s --optimize- -o both69514-noopt.exe -g" cfg.fsc_flags ["lib69514.fs"; "app69514.fs"] + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["load-FlagCheckFs.fsx"] - peverify cfg "both69514-noopt.exe" + echo "Test 14=================================================" - fsc cfg "%s --optimize -a -g" cfg.fsc_flags ["lib69514.fs"] + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["FlagCheck.fsx"] - peverify cfg "lib69514.dll" + echo "Test 15=================================================" - fsc cfg "%s --optimize -r:lib69514.dll -g" cfg.fsc_flags ["app69514.fs"] + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["ProjectDriver.fsx"] - peverify cfg "app69514.exe" + echo "Test 16=================================================" - fsc cfg "%s --optimize- -o:lib69514-noopt.dll -a -g" cfg.fsc_flags ["lib69514.fs"] + fscAppend cfg stdoutPath stderrPath "--nologo" ["ProjectDriver.fsx"] - peverify cfg "lib69514-noopt.dll" + execAppendIgnoreExitCode cfg stdoutPath stderrPath ("." ++ "ProjectDriver.exe") "" - fsc cfg "%s --optimize- -r:lib69514-noopt.dll -o:app69514-noopt.exe -g" cfg.fsc_flags ["app69514.fs"] + rm cfg "ProjectDriver.exe" - peverify cfg "app69514-noopt.exe" + echo "Test 17=================================================" - fsc cfg "%s --optimize- -o:lib69514-noopt-withsig.dll -a -g" cfg.fsc_flags ["lib69514.fsi"; "lib69514.fs"] + fsiAppendIgnoreExitCode cfg stdoutPath stderrPath "" ["load-IncludeNoWarn211.fsx"] - peverify cfg "lib69514-noopt-withsig.dll" + echo "Done ==================================================" - fsc cfg "%s --optimize- -r:lib69514-noopt-withsig.dll -o:app69514-noopt-withsig.exe -g" cfg.fsc_flags ["app69514.fs"] + // an extra case + fsiExpectFail cfg "" ["loadfail3.fsx"] - peverify cfg "app69514-noopt-withsig.exe" + let normalizePaths f = + let text = File.ReadAllText(f) + let dummyPath = @"D:\staging\staging\src\tests\fsharp\core\load-script" + let contents = System.Text.RegularExpressions.Regex.Replace(text, System.Text.RegularExpressions.Regex.Escape(cfg.Directory), dummyPath) + File.WriteAllText(f, contents) - fsc cfg "%s -o:lib69514-withsig.dll -a -g" cfg.fsc_flags ["lib69514.fsi"; "lib69514.fs"] + normalizePaths stdoutPath + normalizePaths stderrPath - peverify cfg "lib69514-withsig.dll" + let diffs = fsdiff cfg stdoutPath stdoutBaseline - fsc cfg "%s -r:lib69514-withsig.dll -o:app69514-withsig.exe -g" cfg.fsc_flags ["app69514.fs"] + match diffs with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stdoutPath stdoutBaseline diffs) - peverify cfg "app69514-withsig.exe" + let diffs2 = fsdiff cfg stderrPath stderrBaseline - fsc cfg "%s -o:lib.dll -a --langversion:5.0 --mlcompatibility -g" cfg.fsc_flags ["lib.ml"] + match diffs2 with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" stderrPath stderrBaseline diffs2) +#endif - peverify cfg "lib.dll" - csc cfg """/nologo /r:"%s" /r:lib.dll /out:test.exe """ cfg.FSCOREDLLPATH ["test.cs"] - fsc cfg "%s --optimize -o:lib--optimize.dll -a --langversion:5.0 --mlcompatibility -g" cfg.fsc_flags ["lib.ml"] +#if !NETCOREAPP + [] + let ``measures-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/measures" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - peverify cfg "lib--optimize.dll" + [] + let ``members-basics-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/members/basics" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL - csc cfg """/nologo /r:"%s" /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"] + [] + let queriesLeafExpressionConvert () = + let cfg = testConfig "core/queriesLeafExpressionConvert" - let dicases = ["flag_deterministic_init1.fs"; "lib_deterministic_init1.fs"; "flag_deterministic_init2.fs"; "lib_deterministic_init2.fs"; "flag_deterministic_init3.fs"; "lib_deterministic_init3.fs"; "flag_deterministic_init4.fs"; "lib_deterministic_init4.fs"; "flag_deterministic_init5.fs"; "lib_deterministic_init5.fs"; "flag_deterministic_init6.fs"; "lib_deterministic_init6.fs"; "flag_deterministic_init7.fs"; "lib_deterministic_init7.fs"; "flag_deterministic_init8.fs"; "lib_deterministic_init8.fs"; "flag_deterministic_init9.fs"; "lib_deterministic_init9.fs"; "flag_deterministic_init10.fs"; "lib_deterministic_init10.fs"; "flag_deterministic_init11.fs"; "lib_deterministic_init11.fs"; "flag_deterministic_init12.fs"; "lib_deterministic_init12.fs"; "flag_deterministic_init13.fs"; "lib_deterministic_init13.fs"; "flag_deterministic_init14.fs"; "lib_deterministic_init14.fs"; "flag_deterministic_init15.fs"; "lib_deterministic_init15.fs"; "flag_deterministic_init16.fs"; "lib_deterministic_init16.fs"; "flag_deterministic_init17.fs"; "lib_deterministic_init17.fs"; "flag_deterministic_init18.fs"; "lib_deterministic_init18.fs"; "flag_deterministic_init19.fs"; "lib_deterministic_init19.fs"; "flag_deterministic_init20.fs"; "lib_deterministic_init20.fs"; "flag_deterministic_init21.fs"; "lib_deterministic_init21.fs"; "flag_deterministic_init22.fs"; "lib_deterministic_init22.fs"; "flag_deterministic_init23.fs"; "lib_deterministic_init23.fs"; "flag_deterministic_init24.fs"; "lib_deterministic_init24.fs"; "flag_deterministic_init25.fs"; "lib_deterministic_init25.fs"; "flag_deterministic_init26.fs"; "lib_deterministic_init26.fs"; "flag_deterministic_init27.fs"; "lib_deterministic_init27.fs"; "flag_deterministic_init28.fs"; "lib_deterministic_init28.fs"; "flag_deterministic_init29.fs"; "lib_deterministic_init29.fs"; "flag_deterministic_init30.fs"; "lib_deterministic_init30.fs"; "flag_deterministic_init31.fs"; "lib_deterministic_init31.fs"; "flag_deterministic_init32.fs"; "lib_deterministic_init32.fs"; "flag_deterministic_init33.fs"; "lib_deterministic_init33.fs"; "flag_deterministic_init34.fs"; "lib_deterministic_init34.fs"; "flag_deterministic_init35.fs"; "lib_deterministic_init35.fs"; "flag_deterministic_init36.fs"; "lib_deterministic_init36.fs"; "flag_deterministic_init37.fs"; "lib_deterministic_init37.fs"; "flag_deterministic_init38.fs"; "lib_deterministic_init38.fs"; "flag_deterministic_init39.fs"; "lib_deterministic_init39.fs"; "flag_deterministic_init40.fs"; "lib_deterministic_init40.fs"; "flag_deterministic_init41.fs"; "lib_deterministic_init41.fs"; "flag_deterministic_init42.fs"; "lib_deterministic_init42.fs"; "flag_deterministic_init43.fs"; "lib_deterministic_init43.fs"; "flag_deterministic_init44.fs"; "lib_deterministic_init44.fs"; "flag_deterministic_init45.fs"; "lib_deterministic_init45.fs"; "flag_deterministic_init46.fs"; "lib_deterministic_init46.fs"; "flag_deterministic_init47.fs"; "lib_deterministic_init47.fs"; "flag_deterministic_init48.fs"; "lib_deterministic_init48.fs"; "flag_deterministic_init49.fs"; "lib_deterministic_init49.fs"; "flag_deterministic_init50.fs"; "lib_deterministic_init50.fs"; "flag_deterministic_init51.fs"; "lib_deterministic_init51.fs"; "flag_deterministic_init52.fs"; "lib_deterministic_init52.fs"; "flag_deterministic_init53.fs"; "lib_deterministic_init53.fs"; "flag_deterministic_init54.fs"; "lib_deterministic_init54.fs"; "flag_deterministic_init55.fs"; "lib_deterministic_init55.fs"; "flag_deterministic_init56.fs"; "lib_deterministic_init56.fs"; "flag_deterministic_init57.fs"; "lib_deterministic_init57.fs"; "flag_deterministic_init58.fs"; "lib_deterministic_init58.fs"; "flag_deterministic_init59.fs"; "lib_deterministic_init59.fs"; "flag_deterministic_init60.fs"; "lib_deterministic_init60.fs"; "flag_deterministic_init61.fs"; "lib_deterministic_init61.fs"; "flag_deterministic_init62.fs"; "lib_deterministic_init62.fs"; "flag_deterministic_init63.fs"; "lib_deterministic_init63.fs"; "flag_deterministic_init64.fs"; "lib_deterministic_init64.fs"; "flag_deterministic_init65.fs"; "lib_deterministic_init65.fs"; "flag_deterministic_init66.fs"; "lib_deterministic_init66.fs"; "flag_deterministic_init67.fs"; "lib_deterministic_init67.fs"; "flag_deterministic_init68.fs"; "lib_deterministic_init68.fs"; "flag_deterministic_init69.fs"; "lib_deterministic_init69.fs"; "flag_deterministic_init70.fs"; "lib_deterministic_init70.fs"; "flag_deterministic_init71.fs"; "lib_deterministic_init71.fs"; "flag_deterministic_init72.fs"; "lib_deterministic_init72.fs"; "flag_deterministic_init73.fs"; "lib_deterministic_init73.fs"; "flag_deterministic_init74.fs"; "lib_deterministic_init74.fs"; "flag_deterministic_init75.fs"; "lib_deterministic_init75.fs"; "flag_deterministic_init76.fs"; "lib_deterministic_init76.fs"; "flag_deterministic_init77.fs"; "lib_deterministic_init77.fs"; "flag_deterministic_init78.fs"; "lib_deterministic_init78.fs"; "flag_deterministic_init79.fs"; "lib_deterministic_init79.fs"; "flag_deterministic_init80.fs"; "lib_deterministic_init80.fs"; "flag_deterministic_init81.fs"; "lib_deterministic_init81.fs"; "flag_deterministic_init82.fs"; "lib_deterministic_init82.fs"; "flag_deterministic_init83.fs"; "lib_deterministic_init83.fs"; "flag_deterministic_init84.fs"; "lib_deterministic_init84.fs"; "flag_deterministic_init85.fs"; "lib_deterministic_init85.fs"] + fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - fsc cfg "%s --optimize- -o test_deterministic_init.exe" cfg.fsc_flags (dicases @ ["test_deterministic_init.fs"]) + peverify cfg "test.exe" - peverify cfg "test_deterministic_init.exe" + fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] - fsc cfg "%s --optimize -o test_deterministic_init--optimize.exe" cfg.fsc_flags (dicases @ ["test_deterministic_init.fs"]) + peverify cfg "test--optimize.exe" - peverify cfg "test_deterministic_init--optimize.exe" + use testOkFile = fileguard cfg "test.ok" - fsc cfg "%s --optimize- -a -o test_deterministic_init_lib.dll" cfg.fsc_flags dicases + fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - peverify cfg "test_deterministic_init_lib.dll" + testOkFile.CheckExists() - fsc cfg "%s --optimize- -r test_deterministic_init_lib.dll -o test_deterministic_init_exe.exe" cfg.fsc_flags ["test_deterministic_init.fs"] + use testOkFile2 = fileguard cfg "test.ok" - peverify cfg "test_deterministic_init_exe.exe" + exec cfg ("." ++ "test.exe") "" - fsc cfg "%s --optimize -a -o test_deterministic_init_lib--optimize.dll" cfg.fsc_flags dicases + testOkFile2.CheckExists() - peverify cfg "test_deterministic_init_lib--optimize.dll" + use testOkFile3 = fileguard cfg "test.ok" - fsc cfg "%s --optimize -r test_deterministic_init_lib--optimize.dll -o test_deterministic_init_exe--optimize.exe" cfg.fsc_flags ["test_deterministic_init.fs"] + exec cfg ("." ++ "test--optimize.exe") "" - peverify cfg "test_deterministic_init_exe--optimize.exe" + testOkFile3.CheckExists() - let static_init_cases = [ "test0.fs"; "test1.fs"; "test2.fs"; "test3.fs"; "test4.fs"; "test5.fs"; "test6.fs" ] - fsc cfg "%s --optimize- -o test_static_init.exe" cfg.fsc_flags (static_init_cases @ ["static-main.fs"]) + [] + let queriesNullableOperators () = + let cfg = testConfig "core/queriesNullableOperators" - peverify cfg "test_static_init.exe" + fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - fsc cfg "%s --optimize -o test_static_init--optimize.exe" cfg.fsc_flags (static_init_cases @ [ "static-main.fs" ]) + peverify cfg "test.exe" - peverify cfg "test_static_init--optimize.exe" + fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] - fsc cfg "%s --optimize- -a -o test_static_init_lib.dll" cfg.fsc_flags static_init_cases + peverify cfg "test--optimize.exe" - peverify cfg "test_static_init_lib.dll" + use testOkFile = fileguard cfg "test.ok" + fsi cfg "%s" cfg.fsi_flags ["test.fsx"] + testOkFile.CheckExists() - fsc cfg "%s --optimize- -r test_static_init_lib.dll -o test_static_init_exe.exe" cfg.fsc_flags ["static-main.fs"] + use testOkFile2 = fileguard cfg "test.ok" + exec cfg ("." ++ "test.exe") "" + testOkFile2.CheckExists() - peverify cfg "test_static_init_exe.exe" + use testOkFile3 = fileguard cfg "test.ok" + exec cfg ("." ++ "test--optimize.exe") "" + testOkFile3.CheckExists() - fsc cfg "%s --optimize -a -o test_static_init_lib--optimize.dll" cfg.fsc_flags static_init_cases + [] + let queriesOverIEnumerable () = + let cfg = testConfig "core/queriesOverIEnumerable" - peverify cfg "test_static_init_lib--optimize.dll" + fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - fsc cfg "%s --optimize -r test_static_init_lib--optimize.dll -o test_static_init_exe--optimize.exe" cfg.fsc_flags ["static-main.fs"] + peverify cfg "test.exe" - peverify cfg "test_static_init_exe--optimize.exe" + fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] - exec cfg ("." ++ "test.exe") "" + peverify cfg "test--optimize.exe" - exec cfg ("." ++ "test--optimize.exe") "" + use testOkFile = fileguard cfg "test.ok" - exec cfg ("." ++ "test_deterministic_init.exe") "" + fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - exec cfg ("." ++ "test_deterministic_init--optimize.exe") "" + testOkFile.CheckExists() - exec cfg ("." ++ "test_deterministic_init_exe.exe") "" + use testOkFile2 = fileguard cfg "test.ok" - exec cfg ("." ++ "test_deterministic_init_exe--optimize.exe") "" + exec cfg ("." ++ "test.exe") "" - exec cfg ("." ++ "test_static_init.exe") "" + testOkFile2.CheckExists() - exec cfg ("." ++ "test_static_init--optimize.exe") "" + use testOkFile3 = fileguard cfg "test.ok" - exec cfg ("." ++ "test_static_init_exe.exe") "" + exec cfg ("." ++ "test--optimize.exe") "" - exec cfg ("." ++ "test_static_init_exe--optimize.exe") "" + testOkFile3.CheckExists() [] - let unitsOfMeasure () = - let cfg = testConfig "core/unitsOfMeasure" + let queriesOverIQueryable () = + let cfg = testConfig "core/queriesOverIQueryable" - fsc cfg "%s --optimize- -o:test.exe -g" cfg.fsc_flags ["test.fs"] + fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] peverify cfg "test.exe" - use testOkFile = fileguard cfg "test.ok" - - exec cfg ("." ++ "test.exe") "" - - testOkFile.CheckExists() + fsc cfg "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] - [] - let verify () = - let cfg = testConfig "core/verify" + peverify cfg "test--optimize.exe" - peverifyWithArgs cfg "/nologo" (cfg.FSharpBuild) + use testOkFile = fileguard cfg "test.ok" + fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - // peverifyWithArgs cfg "/nologo /MD" (getDirectoryName(cfg.FSC) ++ "FSharp.Compiler.dll") + testOkFile.CheckExists() - peverifyWithArgs cfg "/nologo" (cfg.FSI) - peverifyWithArgs cfg "/nologo" (cfg.FSharpCompilerInteractiveSettings) + use testOkFile2 = fileguard cfg "test.ok" - fsc cfg "%s -o:xmlverify.exe -g" cfg.fsc_flags ["xmlverify.fs"] + exec cfg ("." ++ "test.exe") "" - peverifyWithArgs cfg "/nologo" "xmlverify.exe" - - - [] - let ``property setter in method or constructor`` () = - let cfg = testConfig "core/members/set-only-property" - csc cfg @"%s /target:library /out:cs.dll" cfg.csc_flags ["cs.cs"] - vbc cfg @"%s /target:library /out:vb.dll" cfg.vbc_flags ["vb.vb"] - fsc cfg @"%s /target:library /out:fs.dll" cfg.fsc_flags ["fs.fs"] - singleNegTest cfg "calls" + testOkFile2.CheckExists() -#endif -[] -module VersionTests = - [] - let ``member-selfidentifier-version4_6``() = singleTestBuildAndRunVersion "core/members/self-identifier/version46" (FSC_BUILDONLY true) "4.6" + use testOkFile3 = fileguard cfg "test.ok" + exec cfg ("." ++ "test--optimize.exe") "" - [] - let ``member-selfidentifier-version4_7``() = singleTestBuildAndRun "core/members/self-identifier/version47" (FSC_BUILDONLY true) + testOkFile3.CheckExists() - [] - let ``indent-version4_6``() = singleTestBuildAndRunVersion "core/indent/version46" (FSC_BUILDONLY true) "4.6" [] - let ``indent-version4_7``() = singleTestBuildAndRun "core/indent/version47" (FSC_BUILDONLY true) + let quotesDebugInfo () = + let cfg = testConfig "core/quotesDebugInfo" - [] - let ``nameof-version4_6``() = singleTestBuildAndRunVersion "core/nameof/version46" (FSC_BUILDONLY true) "4.6" + fsc cfg "%s --quotations-debug+ --optimize -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - [] - let ``nameof-versionpreview``() = singleTestBuildAndRunVersion "core/nameof/preview" (FSC_BUILDONLY true) "preview" + peverify cfg "test.exe" - [] - let ``nameof-execute``() = singleTestBuildAndRunVersion "core/nameof/preview" FSC_OPTIMIZED "preview" + fsc cfg "%s --quotations-debug+ --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"] - [] - let ``nameof-fsi``() = singleTestBuildAndRunVersion "core/nameof/preview" FSI "preview" + peverify cfg "test--optimize.exe" -#if !NETCOREAPP -[] -module ToolsTests = + use testOkFile = fileguard cfg "test.ok" + fsi cfg "%s --quotations-debug+" cfg.fsi_flags ["test.fsx"] - // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 - [] - let bundle () = - let cfg = - testConfig "tools/bundle" + testOkFile.CheckExists() - fsc cfg "%s --progress --langversion:5.0 --mlcompatibility --standalone -o:test-one-fsharp-module.exe -g" cfg.fsc_flags ["test-one-fsharp-module.fs"] - peverify cfg "test-one-fsharp-module.exe" + use testOkFile2 = fileguard cfg "test.ok" - fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:test_two_fsharp_modules_module_1.dll -g" cfg.fsc_flags ["test_two_fsharp_modules_module_1.fs"] + exec cfg ("." ++ "test.exe") "" - peverify cfg "test_two_fsharp_modules_module_1.dll" + testOkFile2.CheckExists() - fsc cfg "%s --langversion:5.0 --mlcompatibility --standalone -r:test_two_fsharp_modules_module_1.dll -o:test_two_fsharp_modules_module_2.exe -g" cfg.fsc_flags ["test_two_fsharp_modules_module_2.fs"] + use testOkFile3 = fileguard cfg "test.ok" - peverify cfg "test_two_fsharp_modules_module_2.exe" + exec cfg ("." ++ "test--optimize.exe") "" - fsc cfg "%s -a --langversion:5.0 --mlcompatibility --standalone -r:test_two_fsharp_modules_module_1.dll -o:test_two_fsharp_modules_module_2_as_dll.dll -g" cfg.fsc_flags ["test_two_fsharp_modules_module_2.fs"] + testOkFile3.CheckExists() - peverify cfg "test_two_fsharp_modules_module_2_as_dll.dll" -#endif [] - let ``eval-FSC_OPTIMIZED`` () = singleTestBuildAndRun "tools/eval" FSC_OPTIMIZED - [] - let ``eval-FSI`` () = singleTestBuildAndRun "tools/eval" FSI + let quotesInMultipleModules () = + let cfg = testConfig "core/quotesInMultipleModules" -[] -module RegressionTests = + fsc cfg "%s -o:module1.dll --target:library" cfg.fsc_flags ["module1.fsx"] - [] - let ``literal-value-bug-2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/literal-value-bug-2" FSC_OPTIMIZED + peverify cfg "module1.dll" - [] - let ``literal-value-bug-2-FSI`` () = singleTestBuildAndRun "regression/literal-value-bug-2" FSI + fsc cfg "%s -o:module2.exe -r:module1.dll" cfg.fsc_flags ["module2.fsx"] - [] - let ``OverloadResolution-bug-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/OverloadResolution-bug" FSC_OPTIMIZED + peverify cfg "module2.exe" - [] - let ``OverloadResolution-bug-FSI`` () = singleTestBuildAndRun "regression/OverloadResolution-bug" FSI + fsc cfg "%s --staticlink:module1 -o:module2-staticlink.exe -r:module1.dll" cfg.fsc_flags ["module2.fsx"] - [] - let ``struct-tuple-bug-1-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/struct-tuple-bug-1" FSC_OPTIMIZED + peverify cfg "module2-staticlink.exe" - [] - let ``tuple-bug-1-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "regression/tuple-bug-1" FSC_OPTIMIZED "supports-ml" + fsc cfg "%s -o:module1-opt.dll --target:library --optimize" cfg.fsc_flags ["module1.fsx"] - [] - let ``12383-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/12383" FSC_OPTIMIZED + peverify cfg "module1-opt.dll" - [] - let ``13219-bug-FSI`` () = singleTestBuildAndRun "regression/13219" FSI + fsc cfg "%s -o:module2-opt.exe -r:module1-opt.dll --optimize" cfg.fsc_flags ["module2.fsx"] - [] - let ``4715-optimized`` () = - let cfg = testConfig "regression/4715" - fsc cfg "%s -o:test.exe --optimize+" cfg.fsc_flags ["date.fs"; "env.fs"; "main.fs"] + peverify cfg "module2-opt.exe" - [] - let ``multi-package-type-provider-test-FSI`` () = singleTestBuildAndRun "regression/13710" FSI + use testOkFile = fileguard cfg "test.ok" -#if NETCOREAPP - [] - let ``Large inputs 12322 fsc.dll 64-bit fsc.dll .NET SDK generating optimized code`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) + fsi cfg "%s -r module1.dll" cfg.fsi_flags ["module2.fsx"] - [] - let ``Large inputs 12322 fsc.dll 64-bit .NET SDK generating debug code`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) + testOkFile.CheckExists() -#else - [] - let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, portable PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, full PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) + use testOkFile = fileguard cfg "test.ok" - [] - let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code portable PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) + exec cfg ("." ++ "module2.exe") "" - [] - let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code, full PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) + testOkFile.CheckExists() - [] - let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, portable PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with FSC = cfg.FSCANYCPU } - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) + use testOkFile = fileguard cfg "test.ok" - [] - let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, full PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with FSC = cfg.FSCANYCPU } - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full " } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) + exec cfg ("." ++ "module2-opt.exe") "" - [] - let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, portable PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with FSC = cfg.FSCANYCPU } - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) + testOkFile.CheckExists() - [] - let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, full PDB`` () = - let cfg = testConfig "regression/12322" - let cfg = { cfg with FSC = cfg.FSCANYCPU } - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } - singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) -#endif + use testOkFile = fileguard cfg "test.ok" -#if !NETCOREAPP + exec cfg ("." ++ "module2-staticlink.exe") "" - [] - let ``SRTP doesn't handle calling member hiding hinherited members`` () = - let cfg = - testConfig "regression/5531" - + testOkFile.CheckExists() +#endif - let outFile = "compilation.output.test.txt" - let expectedFile = "compilation.output.test.bsl" - fscBothToOut cfg outFile "%s --nologo -O" cfg.fsc_flags ["test.fs"] - let diff = fsdiff cfg outFile expectedFile +#if !NETCOREAPP + [] + let refnormalization () = + let cfg = testConfig "core/refnormalization" - match diff with - | "" -> () - | _ -> - Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) + // Prepare by building multiple versions of the test assemblies + fsc cfg @"%s --target:library -o:version1\DependentAssembly.dll -g --version:1.0.0.0 --keyfile:keyfile.snk" cfg.fsc_flags [@"DependentAssembly.fs"] + fsc cfg @"%s --target:library -o:version1\AscendentAssembly.dll -g --version:1.0.0.0 --keyfile:keyfile.snk -r:version1\DependentAssembly.dll" cfg.fsc_flags [@"AscendentAssembly.fs"] - let outFile2 = "output.test.txt" - let expectedFile2 = "output.test.bsl" + fsc cfg @"%s --target:library -o:version2\DependentAssembly.dll -g --version:2.0.0.0" cfg.fsc_flags [@"DependentAssembly.fs"] + fsc cfg @"%s --target:library -o:version2\AscendentAssembly.dll -g --version:2.0.0.0 -r:version2\DependentAssembly.dll" cfg.fsc_flags [@"AscendentAssembly.fs"] - execBothToOut cfg (cfg.Directory) outFile2 (cfg.Directory ++ "test.exe") "" + //TestCase1 + // Build a program that references v2 of ascendent and v1 of dependent. + // Note that, even though ascendent v2 references dependent v2, the reference is marked as v1. + use TestOk = fileguard cfg "test.ok" + fsc cfg @"%s -o:test1.exe -r:version1\DependentAssembly.dll -r:version2\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] + exec cfg ("." ++ "test1.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-2.0.0.0" + TestOk.CheckExists() - let diff2 = fsdiff cfg outFile2 expectedFile2 - match diff2 with - | "" -> () - | _ -> - Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile2) (getfullpath cfg expectedFile2) diff2) -#endif + //TestCase2 + // Build a program that references v1 of ascendent and v2 of dependent. + // Note that, even though ascendent v1 references dependent v1, the reference is marked as v2 which was passed in. + use TestOk = fileguard cfg "test.ok" + fsc cfg @"%s -o:test2.exe -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] + exec cfg ("." ++ "test2.exe") "DependentAssembly-2.0.0.0 AscendentAssembly-1.0.0.0" + TestOk.CheckExists() - [] - let ``26`` () = singleTestBuildAndRunVersion "regression/26" FSC_OPTIMIZED "supports-ml" + //TestCase3 + // Build a program that references v1 of ascendent and v1 and v2 of dependent. + // Verifies that compiler uses first version of a duplicate assembly passed on command line. + use TestOk = fileguard cfg "test.ok" + fsc cfg @"%s -o:test3.exe -r:version1\DependentAssembly.dll -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"] + exec cfg ("." ++ "test3.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-1.0.0.0" + TestOk.CheckExists() - [] - let ``321`` () = singleTestBuildAndRunVersion "regression/321" FSC_OPTIMIZED "supports-ml" -#if !NETCOREAPP - // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 [] - let ``655`` () = - let cfg = testConfig "regression/655" + let testResources () = + let cfg = testConfig "core/resources" - fsc cfg "%s --langversion:5.0 --mlcompatibility -a -o:pack.dll" cfg.fsc_flags ["xlibC.ml"] + fsc cfg "%s --langversion:5.0 --mlcompatibility --resource:Resources.resources -o:test-embed.exe -g" cfg.fsc_flags ["test.fs"] - peverify cfg "pack.dll" + peverify cfg "test-embed.exe" - fsc cfg "%s --langversion:5.0 --mlcompatibility -o:test.exe -r:pack.dll" cfg.fsc_flags ["main.fs"] + fsc cfg "%s --langversion:5.0 --mlcompatibility --linkresource:Resources.resources -o:test-link.exe -g" cfg.fsc_flags ["test.fs"] - peverify cfg "test.exe" + peverify cfg "test-link.exe" - use testOkFile = fileguard cfg "test.ok" + fsc cfg "%s --langversion:5.0 --mlcompatibility --resource:Resources.resources,ResourceName.resources -o:test-embed-named.exe -g" cfg.fsc_flags ["test.fs"] - exec cfg ("." ++ "test.exe") "" + peverify cfg "test-embed-named.exe" - testOkFile.CheckExists() + fsc cfg "%s --langversion:5.0 --mlcompatibility --linkresource:Resources.resources,ResourceName.resources -o:test-link-named.exe -g" cfg.fsc_flags ["test.fs"] - // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 - [] - let ``656`` () = - let cfg = testConfig "regression/656" + peverify cfg "test-link-named.exe" - fsc cfg "%s --langversion:5.0 --mlcompatibility -o:pack.exe" cfg.fsc_flags ["misc.fs mathhelper.fs filehelper.fs formshelper.fs plot.fs traj.fs playerrecord.fs trackedplayers.fs form.fs"] + exec cfg ("." ++ "test-embed.exe") "" - peverify cfg "pack.exe" -#endif + exec cfg ("." ++ "test-link.exe") "" -#if !NETCOREAPP - // Requires WinForms - [] - let ``83`` () = singleTestBuildAndRunVersion "regression/83" FSC_OPTIMIZED "supports-ml" + exec cfg ("." ++ "test-link-named.exe") "ResourceName" - [] - let ``84`` () = singleTestBuildAndRunVersion "regression/84" FSC_OPTIMIZED "supports-ml" + exec cfg ("." ++ "test-embed-named.exe") "ResourceName" - [] - let ``85`` () = - let cfg = testConfig "regression/85" + [] + let topinit () = + let cfg = testConfig "core/topinit" - fsc cfg "%s --langversion:5.0 --mlcompatibility -r:Category.dll -a -o:petshop.dll" cfg.fsc_flags ["Category.ml"] + fsc cfg "%s --optimize -o both69514.exe -g" cfg.fsc_flags ["lib69514.fs"; "app69514.fs"] - peverify cfg "petshop.dll" -#endif + peverify cfg "both69514.exe" - [] - let ``86`` () = singleTestBuildAndRunVersion "regression/86" FSC_OPTIMIZED "supports-ml" + fsc cfg "%s --optimize- -o both69514-noopt.exe -g" cfg.fsc_flags ["lib69514.fs"; "app69514.fs"] - [] - let ``struct-tuple-bug-1-FSI`` () = singleTestBuildAndRun "regression/struct-tuple-bug-1" FSI + peverify cfg "both69514-noopt.exe" -#if !NETCOREAPP - // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 - [] - let ``struct-measure-bug-1`` () = - let cfg = testConfig "regression/struct-measure-bug-1" + fsc cfg "%s --optimize -a -g" cfg.fsc_flags ["lib69514.fs"] - fsc cfg "%s --optimize- -o:test.exe -g" cfg.fsc_flags ["test.fs"] + peverify cfg "lib69514.dll" - peverify cfg "test.exe" + fsc cfg "%s --optimize -r:lib69514.dll -g" cfg.fsc_flags ["app69514.fs"] -[] -module OptimizationTests = + peverify cfg "app69514.exe" - [] - let functionSizes () = - let cfg = testConfig "optimize/analyses" + fsc cfg "%s --optimize- -o:lib69514-noopt.dll -a -g" cfg.fsc_flags ["lib69514.fs"] - let outFile = "sizes.FunctionSizes.output.test.txt" - let expectedFile = "sizes.FunctionSizes.output.test.bsl" + peverify cfg "lib69514-noopt.dll" - log "== FunctionSizes" - fscBothToOut cfg outFile "%s --nologo -O --test:FunctionSizes" cfg.fsc_flags ["sizes.fs"] + fsc cfg "%s --optimize- -r:lib69514-noopt.dll -o:app69514-noopt.exe -g" cfg.fsc_flags ["app69514.fs"] - let diff = fsdiff cfg outFile expectedFile + peverify cfg "app69514-noopt.exe" - match diff with - | "" -> () - | _ -> - Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) + fsc cfg "%s --optimize- -o:lib69514-noopt-withsig.dll -a -g" cfg.fsc_flags ["lib69514.fsi"; "lib69514.fs"] + peverify cfg "lib69514-noopt-withsig.dll" - [] - let totalSizes () = - let cfg = testConfig "optimize/analyses" + fsc cfg "%s --optimize- -r:lib69514-noopt-withsig.dll -o:app69514-noopt-withsig.exe -g" cfg.fsc_flags ["app69514.fs"] - let outFile = "sizes.TotalSizes.output.test.txt" - let expectedFile = "sizes.TotalSizes.output.test.bsl" + peverify cfg "app69514-noopt-withsig.exe" - log "== TotalSizes" - fscBothToOut cfg outFile "%s --nologo -O --test:TotalSizes" cfg.fsc_flags ["sizes.fs"] + fsc cfg "%s -o:lib69514-withsig.dll -a -g" cfg.fsc_flags ["lib69514.fsi"; "lib69514.fs"] - let diff = fsdiff cfg outFile expectedFile + peverify cfg "lib69514-withsig.dll" - match diff with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) + fsc cfg "%s -r:lib69514-withsig.dll -o:app69514-withsig.exe -g" cfg.fsc_flags ["app69514.fs"] + peverify cfg "app69514-withsig.exe" - [] - let hasEffect () = - let cfg = testConfig "optimize/analyses" + fsc cfg "%s -o:lib.dll -a --langversion:5.0 --mlcompatibility -g" cfg.fsc_flags ["lib.ml"] - let outFile = "effects.HasEffect.output.test.txt" - let expectedFile = "effects.HasEffect.output.test.bsl" + peverify cfg "lib.dll" - log "== HasEffect" - fscBothToOut cfg outFile "%s --nologo -O --test:HasEffect" cfg.fsc_flags ["effects.fs"] + csc cfg """/nologo /r:"%s" /r:lib.dll /out:test.exe """ cfg.FSCOREDLLPATH ["test.cs"] - let diff = fsdiff cfg outFile expectedFile + fsc cfg "%s --optimize -o:lib--optimize.dll -a --langversion:5.0 --mlcompatibility -g" cfg.fsc_flags ["lib.ml"] - match diff with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) + peverify cfg "lib--optimize.dll" + csc cfg """/nologo /r:"%s" /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"] - [] - let noNeedToTailcall () = - let cfg = testConfig "optimize/analyses" + let dicases = ["flag_deterministic_init1.fs"; "lib_deterministic_init1.fs"; "flag_deterministic_init2.fs"; "lib_deterministic_init2.fs"; "flag_deterministic_init3.fs"; "lib_deterministic_init3.fs"; "flag_deterministic_init4.fs"; "lib_deterministic_init4.fs"; "flag_deterministic_init5.fs"; "lib_deterministic_init5.fs"; "flag_deterministic_init6.fs"; "lib_deterministic_init6.fs"; "flag_deterministic_init7.fs"; "lib_deterministic_init7.fs"; "flag_deterministic_init8.fs"; "lib_deterministic_init8.fs"; "flag_deterministic_init9.fs"; "lib_deterministic_init9.fs"; "flag_deterministic_init10.fs"; "lib_deterministic_init10.fs"; "flag_deterministic_init11.fs"; "lib_deterministic_init11.fs"; "flag_deterministic_init12.fs"; "lib_deterministic_init12.fs"; "flag_deterministic_init13.fs"; "lib_deterministic_init13.fs"; "flag_deterministic_init14.fs"; "lib_deterministic_init14.fs"; "flag_deterministic_init15.fs"; "lib_deterministic_init15.fs"; "flag_deterministic_init16.fs"; "lib_deterministic_init16.fs"; "flag_deterministic_init17.fs"; "lib_deterministic_init17.fs"; "flag_deterministic_init18.fs"; "lib_deterministic_init18.fs"; "flag_deterministic_init19.fs"; "lib_deterministic_init19.fs"; "flag_deterministic_init20.fs"; "lib_deterministic_init20.fs"; "flag_deterministic_init21.fs"; "lib_deterministic_init21.fs"; "flag_deterministic_init22.fs"; "lib_deterministic_init22.fs"; "flag_deterministic_init23.fs"; "lib_deterministic_init23.fs"; "flag_deterministic_init24.fs"; "lib_deterministic_init24.fs"; "flag_deterministic_init25.fs"; "lib_deterministic_init25.fs"; "flag_deterministic_init26.fs"; "lib_deterministic_init26.fs"; "flag_deterministic_init27.fs"; "lib_deterministic_init27.fs"; "flag_deterministic_init28.fs"; "lib_deterministic_init28.fs"; "flag_deterministic_init29.fs"; "lib_deterministic_init29.fs"; "flag_deterministic_init30.fs"; "lib_deterministic_init30.fs"; "flag_deterministic_init31.fs"; "lib_deterministic_init31.fs"; "flag_deterministic_init32.fs"; "lib_deterministic_init32.fs"; "flag_deterministic_init33.fs"; "lib_deterministic_init33.fs"; "flag_deterministic_init34.fs"; "lib_deterministic_init34.fs"; "flag_deterministic_init35.fs"; "lib_deterministic_init35.fs"; "flag_deterministic_init36.fs"; "lib_deterministic_init36.fs"; "flag_deterministic_init37.fs"; "lib_deterministic_init37.fs"; "flag_deterministic_init38.fs"; "lib_deterministic_init38.fs"; "flag_deterministic_init39.fs"; "lib_deterministic_init39.fs"; "flag_deterministic_init40.fs"; "lib_deterministic_init40.fs"; "flag_deterministic_init41.fs"; "lib_deterministic_init41.fs"; "flag_deterministic_init42.fs"; "lib_deterministic_init42.fs"; "flag_deterministic_init43.fs"; "lib_deterministic_init43.fs"; "flag_deterministic_init44.fs"; "lib_deterministic_init44.fs"; "flag_deterministic_init45.fs"; "lib_deterministic_init45.fs"; "flag_deterministic_init46.fs"; "lib_deterministic_init46.fs"; "flag_deterministic_init47.fs"; "lib_deterministic_init47.fs"; "flag_deterministic_init48.fs"; "lib_deterministic_init48.fs"; "flag_deterministic_init49.fs"; "lib_deterministic_init49.fs"; "flag_deterministic_init50.fs"; "lib_deterministic_init50.fs"; "flag_deterministic_init51.fs"; "lib_deterministic_init51.fs"; "flag_deterministic_init52.fs"; "lib_deterministic_init52.fs"; "flag_deterministic_init53.fs"; "lib_deterministic_init53.fs"; "flag_deterministic_init54.fs"; "lib_deterministic_init54.fs"; "flag_deterministic_init55.fs"; "lib_deterministic_init55.fs"; "flag_deterministic_init56.fs"; "lib_deterministic_init56.fs"; "flag_deterministic_init57.fs"; "lib_deterministic_init57.fs"; "flag_deterministic_init58.fs"; "lib_deterministic_init58.fs"; "flag_deterministic_init59.fs"; "lib_deterministic_init59.fs"; "flag_deterministic_init60.fs"; "lib_deterministic_init60.fs"; "flag_deterministic_init61.fs"; "lib_deterministic_init61.fs"; "flag_deterministic_init62.fs"; "lib_deterministic_init62.fs"; "flag_deterministic_init63.fs"; "lib_deterministic_init63.fs"; "flag_deterministic_init64.fs"; "lib_deterministic_init64.fs"; "flag_deterministic_init65.fs"; "lib_deterministic_init65.fs"; "flag_deterministic_init66.fs"; "lib_deterministic_init66.fs"; "flag_deterministic_init67.fs"; "lib_deterministic_init67.fs"; "flag_deterministic_init68.fs"; "lib_deterministic_init68.fs"; "flag_deterministic_init69.fs"; "lib_deterministic_init69.fs"; "flag_deterministic_init70.fs"; "lib_deterministic_init70.fs"; "flag_deterministic_init71.fs"; "lib_deterministic_init71.fs"; "flag_deterministic_init72.fs"; "lib_deterministic_init72.fs"; "flag_deterministic_init73.fs"; "lib_deterministic_init73.fs"; "flag_deterministic_init74.fs"; "lib_deterministic_init74.fs"; "flag_deterministic_init75.fs"; "lib_deterministic_init75.fs"; "flag_deterministic_init76.fs"; "lib_deterministic_init76.fs"; "flag_deterministic_init77.fs"; "lib_deterministic_init77.fs"; "flag_deterministic_init78.fs"; "lib_deterministic_init78.fs"; "flag_deterministic_init79.fs"; "lib_deterministic_init79.fs"; "flag_deterministic_init80.fs"; "lib_deterministic_init80.fs"; "flag_deterministic_init81.fs"; "lib_deterministic_init81.fs"; "flag_deterministic_init82.fs"; "lib_deterministic_init82.fs"; "flag_deterministic_init83.fs"; "lib_deterministic_init83.fs"; "flag_deterministic_init84.fs"; "lib_deterministic_init84.fs"; "flag_deterministic_init85.fs"; "lib_deterministic_init85.fs"] - let outFile = "tailcalls.NoNeedToTailcall.output.test.txt" - let expectedFile = "tailcalls.NoNeedToTailcall.output.test.bsl" + fsc cfg "%s --optimize- -o test_deterministic_init.exe" cfg.fsc_flags (dicases @ ["test_deterministic_init.fs"]) - log "== NoNeedToTailcall" - fscBothToOut cfg outFile "%s --nologo -O --test:NoNeedToTailcall" cfg.fsc_flags ["tailcalls.fs"] + peverify cfg "test_deterministic_init.exe" - let diff = fsdiff cfg outFile expectedFile + fsc cfg "%s --optimize -o test_deterministic_init--optimize.exe" cfg.fsc_flags (dicases @ ["test_deterministic_init.fs"]) - match diff with - | "" -> () - | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) + peverify cfg "test_deterministic_init--optimize.exe" + fsc cfg "%s --optimize- -a -o test_deterministic_init_lib.dll" cfg.fsc_flags dicases - [] - let ``inline`` () = - let cfg = testConfig "optimize/inline" + peverify cfg "test_deterministic_init_lib.dll" - fsc cfg "%s -g --optimize- --target:library -o:lib.dll" cfg.fsc_flags ["lib.fs"; "lib2.fs"] + fsc cfg "%s --optimize- -r test_deterministic_init_lib.dll -o test_deterministic_init_exe.exe" cfg.fsc_flags ["test_deterministic_init.fs"] - peverify cfg "lib.dll " + peverify cfg "test_deterministic_init_exe.exe" - fsc cfg "%s -g --optimize- --target:library -o:lib3.dll -r:lib.dll " cfg.fsc_flags ["lib3.fs"] + fsc cfg "%s --optimize -a -o test_deterministic_init_lib--optimize.dll" cfg.fsc_flags dicases - fsc cfg "%s -g --optimize- -o:test.exe -r:lib.dll -r:lib3.dll" cfg.fsc_flags ["test.fs "] + peverify cfg "test_deterministic_init_lib--optimize.dll" - fsc cfg "%s --optimize --target:library -o:lib--optimize.dll -g" cfg.fsc_flags ["lib.fs"; "lib2.fs"] + fsc cfg "%s --optimize -r test_deterministic_init_lib--optimize.dll -o test_deterministic_init_exe--optimize.exe" cfg.fsc_flags ["test_deterministic_init.fs"] - fsc cfg "%s --optimize --target:library -o:lib3--optimize.dll -r:lib--optimize.dll -g" cfg.fsc_flags ["lib3.fs"] + peverify cfg "test_deterministic_init_exe--optimize.exe" - fsc cfg "%s --optimize -o:test--optimize.exe -g -r:lib--optimize.dll -r:lib3--optimize.dll" cfg.fsc_flags ["test.fs "] + let static_init_cases = [ "test0.fs"; "test1.fs"; "test2.fs"; "test3.fs"; "test4.fs"; "test5.fs"; "test6.fs" ] - ildasm cfg "/out=test.il" "test.exe" + fsc cfg "%s --optimize- -o test_static_init.exe" cfg.fsc_flags (static_init_cases @ ["static-main.fs"]) - ildasm cfg "/out=test--optimize.il" "test--optimize.exe" + peverify cfg "test_static_init.exe" - let ``test--optimize.il`` = - File.ReadLines (getfullpath cfg "test--optimize.il") - |> Seq.filter (fun line -> line.Contains(".locals init")) - |> List.ofSeq + fsc cfg "%s --optimize -o test_static_init--optimize.exe" cfg.fsc_flags (static_init_cases @ [ "static-main.fs" ]) - match ``test--optimize.il`` with - | [] -> () - | lines -> - Assert.Fail (sprintf "Error: optimizations not removed. Relevant lines from IL file follow: %A" lines) + peverify cfg "test_static_init--optimize.exe" - let numElim = - File.ReadLines (getfullpath cfg "test.il") - |> Seq.filter (fun line -> line.Contains(".locals init")) - |> Seq.length + fsc cfg "%s --optimize- -a -o test_static_init_lib.dll" cfg.fsc_flags static_init_cases - log "Ran ok - optimizations removed %d textual occurrences of optimizable identifiers from target IL" numElim + peverify cfg "test_static_init_lib.dll" - [] - let stats () = - let cfg = testConfig "optimize/stats" + fsc cfg "%s --optimize- -r test_static_init_lib.dll -o test_static_init_exe.exe" cfg.fsc_flags ["static-main.fs"] - ildasm cfg "/out=FSharp.Core.il" cfg.FSCOREDLLPATH + peverify cfg "test_static_init_exe.exe" - let fscore = File.ReadLines(getfullpath cfg "FSharp.Core.il") |> Seq.toList + fsc cfg "%s --optimize -a -o test_static_init_lib--optimize.dll" cfg.fsc_flags static_init_cases - let contains text (s: string) = if s.Contains(text) then 1 else 0 + peverify cfg "test_static_init_lib--optimize.dll" - let typeFunc = fscore |> List.sumBy (contains "extends Microsoft.FSharp.TypeFunc") - let classes = fscore |> List.sumBy (contains ".class") - let methods = fscore |> List.sumBy (contains ".method") - let fields = fscore |> List.sumBy (contains ".field") + fsc cfg "%s --optimize -r test_static_init_lib--optimize.dll -o test_static_init_exe--optimize.exe" cfg.fsc_flags ["static-main.fs"] - let date = DateTime.Today.ToString("dd/MM/yyyy") // 23/11/2006 - let time = DateTime.Now.ToString("HH:mm:ss.ff") // 16:03:23.40 - let m = sprintf "%s, %s, Microsoft.FSharp-TypeFunc, %d, Microsoft.FSharp-classes, %d, Microsoft.FSharp-methods, %d, , Microsoft.FSharp-fields, %d, " date time typeFunc classes methods fields + peverify cfg "test_static_init_exe--optimize.exe" - log "now:" - log "%s" m -#endif + exec cfg ("." ++ "test.exe") "" -[] -module TypecheckTests = - [] - let ``full-rank-arrays`` () = - let cfg = testConfig "typecheck/full-rank-arrays" - SingleTest.singleTestBuildAndRunWithCopyDlls cfg "full-rank-arrays.dll" FSC_OPTIMIZED + exec cfg ("." ++ "test--optimize.exe") "" - [] - let misc () = singleTestBuildAndRunVersion "typecheck/misc" FSC_OPTIMIZED "supports-ml" + exec cfg ("." ++ "test_deterministic_init.exe") "" -#if !NETCOREAPP + exec cfg ("." ++ "test_deterministic_init--optimize.exe") "" - [] - let ``sigs pos26`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos26.exe" cfg.fsc_flags ["pos26.fsi"; "pos26.fs"] - peverify cfg "pos26.exe" + exec cfg ("." ++ "test_deterministic_init_exe.exe") "" - [] - let ``sigs pos25`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos25.exe" cfg.fsc_flags ["pos25.fs"] - peverify cfg "pos25.exe" + exec cfg ("." ++ "test_deterministic_init_exe--optimize.exe") "" - [] - let ``sigs pos27`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos27.exe" cfg.fsc_flags ["pos27.fs"] - peverify cfg "pos27.exe" + exec cfg ("." ++ "test_static_init.exe") "" - [] - let ``sigs pos28`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos28.exe" cfg.fsc_flags ["pos28.fs"] - peverify cfg "pos28.exe" + exec cfg ("." ++ "test_static_init--optimize.exe") "" - [] - let ``sigs pos29`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos29.exe" cfg.fsc_flags ["pos29.fsi"; "pos29.fs"; "pos29.app.fs"] - peverify cfg "pos29.exe" + exec cfg ("." ++ "test_static_init_exe.exe") "" - [] - let ``sigs pos30`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos30.exe --warnaserror+" cfg.fsc_flags ["pos30.fs"] - peverify cfg "pos30.exe" + exec cfg ("." ++ "test_static_init_exe--optimize.exe") "" [] - let ``sigs pos24`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos24.exe" cfg.fsc_flags ["pos24.fs"] - peverify cfg "pos24.exe" + let unitsOfMeasure () = + let cfg = testConfig "core/unitsOfMeasure" - [] - let ``sigs pos31`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos31.exe --warnaserror" cfg.fsc_flags ["pos31.fsi"; "pos31.fs"] - peverify cfg "pos31.exe" + fsc cfg "%s --optimize- -o:test.exe -g" cfg.fsc_flags ["test.fs"] - [] - let ``sigs pos32`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos32.dll --warnaserror" cfg.fsc_flags ["pos32.fs"] - peverify cfg "pos32.dll" + peverify cfg "test.exe" - [] - let ``sigs pos33`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos33.dll --warnaserror" cfg.fsc_flags ["pos33.fsi"; "pos33.fs"] - peverify cfg "pos33.dll" + use testOkFile = fileguard cfg "test.ok" - [] - let ``sigs pos34`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos34.dll --warnaserror" cfg.fsc_flags ["pos34.fs"] - peverify cfg "pos34.dll" + exec cfg ("." ++ "test.exe") "" - [] - let ``sigs pos35`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos35.dll --warnaserror" cfg.fsc_flags ["pos35.fs"] - peverify cfg "pos35.dll" + testOkFile.CheckExists() [] - let ``sigs pos36-srtp`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos36-srtp-lib.dll --warnaserror" cfg.fsc_flags ["pos36-srtp-lib.fs"] - fsc cfg "%s --target:exe -r:pos36-srtp-lib.dll -o:pos36-srtp-app.exe --warnaserror" cfg.fsc_flags ["pos36-srtp-app.fs"] - peverify cfg "pos36-srtp-lib.dll" - peverify cfg "pos36-srtp-app.exe" - exec cfg ("." ++ "pos36-srtp-app.exe") "" + let verify () = + let cfg = testConfig "core/verify" - [] - let ``sigs pos37`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos37.dll --warnaserror" cfg.fsc_flags ["pos37.fs"] - peverify cfg "pos37.dll" + peverifyWithArgs cfg "/nologo" (cfg.FSharpBuild) - [] - let ``sigs pos38`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:library -o:pos38.dll --warnaserror" cfg.fsc_flags ["pos38.fs"] - peverify cfg "pos38.dll" + // peverifyWithArgs cfg "/nologo /MD" (getDirectoryName(cfg.FSC) ++ "FSharp.Compiler.dll") - [] - let ``sigs pos39`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos39.exe" cfg.fsc_flags ["pos39.fs"] - peverify cfg "pos39.exe" - exec cfg ("." ++ "pos39.exe") "" + peverifyWithArgs cfg "/nologo" (cfg.FSI) - [] - let ``sigs pos40`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --langversion:6.0 --target:exe -o:pos40.exe" cfg.fsc_flags ["pos40.fs"] - peverify cfg "pos40.exe" - exec cfg ("." ++ "pos40.exe") "" + peverifyWithArgs cfg "/nologo" (cfg.FSharpCompilerInteractiveSettings) - [] - let ``sigs pos1281`` () = - let cfg = testConfig "typecheck/sigs" - // This checks that warning 25 "incomplete matches" is not triggered - fsc cfg "%s --target:exe -o:pos1281.exe --warnaserror --nowarn:26" cfg.fsc_flags ["pos1281.fs"] - peverify cfg "pos1281.exe" - exec cfg ("." ++ "pos1281.exe") "" + fsc cfg "%s -o:xmlverify.exe -g" cfg.fsc_flags ["xmlverify.fs"] + peverifyWithArgs cfg "/nologo" "xmlverify.exe" + + [] - let ``sigs pos3294`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos3294.exe --warnaserror" cfg.fsc_flags ["pos3294.fs"] - peverify cfg "pos3294.exe" - exec cfg ("." ++ "pos3294.exe") "" + let ``property setter in method or constructor`` () = + let cfg = testConfig "core/members/set-only-property" + csc cfg @"%s /target:library /out:cs.dll" cfg.csc_flags ["cs.cs"] + vbc cfg @"%s /target:library /out:vb.dll" cfg.vbc_flags ["vb.vb"] + fsc cfg @"%s /target:library /out:fs.dll" cfg.fsc_flags ["fs.fs"] + singleNegTest cfg "calls" - [] - let ``sigs pos23`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos23.exe" cfg.fsc_flags ["pos23.fs"] - peverify cfg "pos23.exe" - exec cfg ("." ++ "pos23.exe") "" +#endif +[] +module VersionTests = [] - let ``sigs pos20`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos20.exe" cfg.fsc_flags ["pos20.fs"] - peverify cfg "pos20.exe" - exec cfg ("." ++ "pos20.exe") "" + let ``member-selfidentifier-version4_6``() = singleTestBuildAndRunVersion "core/members/self-identifier/version46" (FSC_BUILDONLY true) "4.6" [] - let ``sigs pos19`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos19.exe" cfg.fsc_flags ["pos19.fs"] - peverify cfg "pos19.exe" - exec cfg ("." ++ "pos19.exe") "" + let ``member-selfidentifier-version4_7``() = singleTestBuildAndRun "core/members/self-identifier/version47" (FSC_BUILDONLY true) [] - let ``sigs pos18`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos18.exe" cfg.fsc_flags ["pos18.fs"] - peverify cfg "pos18.exe" - exec cfg ("." ++ "pos18.exe") "" + let ``indent-version4_6``() = singleTestBuildAndRunVersion "core/indent/version46" (FSC_BUILDONLY true) "4.6" [] - let ``sigs pos16`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos16.exe" cfg.fsc_flags ["pos16.fs"] - peverify cfg "pos16.exe" - exec cfg ("." ++ "pos16.exe") "" + let ``indent-version4_7``() = singleTestBuildAndRun "core/indent/version47" (FSC_BUILDONLY true) [] - let ``sigs pos17`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos17.exe" cfg.fsc_flags ["pos17.fs"] - peverify cfg "pos17.exe" - exec cfg ("." ++ "pos17.exe") "" + let ``nameof-version4_6``() = singleTestBuildAndRunVersion "core/nameof/version46" (FSC_BUILDONLY true) "4.6" [] - let ``sigs pos15`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos15.exe" cfg.fsc_flags ["pos15.fs"] - peverify cfg "pos15.exe" - exec cfg ("." ++ "pos15.exe") "" + let ``nameof-versionpreview``() = singleTestBuildAndRunVersion "core/nameof/preview" (FSC_BUILDONLY true) "preview" [] - let ``sigs pos14`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos14.exe" cfg.fsc_flags ["pos14.fs"] - peverify cfg "pos14.exe" - exec cfg ("." ++ "pos14.exe") "" + let ``nameof-execute``() = singleTestBuildAndRunVersion "core/nameof/preview" FSC_OPTIMIZED "preview" [] - let ``sigs pos13`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s --target:exe -o:pos13.exe" cfg.fsc_flags ["pos13.fs"] - peverify cfg "pos13.exe" - exec cfg ("." ++ "pos13.exe") "" + let ``nameof-fsi``() = singleTestBuildAndRunVersion "core/nameof/preview" FSI "preview" - [] - let ``sigs pos12 `` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos12.dll" cfg.fsc_flags ["pos12.fs"] +#if !NETCOREAPP +[] +module ToolsTests = + // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 [] - let ``sigs pos11`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos11.dll" cfg.fsc_flags ["pos11.fs"] + let bundle () = + let cfg = + testConfig "tools/bundle" - [] - let ``sigs pos10`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos10.dll" cfg.fsc_flags ["pos10.fs"] - peverify cfg "pos10.dll" + fsc cfg "%s --progress --langversion:5.0 --mlcompatibility --standalone -o:test-one-fsharp-module.exe -g" cfg.fsc_flags ["test-one-fsharp-module.fs"] - [] - let ``sigs pos09`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos09.dll" cfg.fsc_flags ["pos09.fs"] - peverify cfg "pos09.dll" + peverify cfg "test-one-fsharp-module.exe" - [] - let ``sigs pos07`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos07.dll" cfg.fsc_flags ["pos07.fs"] - peverify cfg "pos07.dll" + fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:test_two_fsharp_modules_module_1.dll -g" cfg.fsc_flags ["test_two_fsharp_modules_module_1.fs"] - [] - let ``sigs pos08`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos08.dll" cfg.fsc_flags ["pos08.fs"] - peverify cfg "pos08.dll" + peverify cfg "test_two_fsharp_modules_module_1.dll" - [] - let ``sigs pos06`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos06.dll" cfg.fsc_flags ["pos06.fs"] - peverify cfg "pos06.dll" + fsc cfg "%s --langversion:5.0 --mlcompatibility --standalone -r:test_two_fsharp_modules_module_1.dll -o:test_two_fsharp_modules_module_2.exe -g" cfg.fsc_flags ["test_two_fsharp_modules_module_2.fs"] - [] - let ``sigs pos03`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos03.dll" cfg.fsc_flags ["pos03.fs"] - peverify cfg "pos03.dll" - fsc cfg "%s -a -o:pos03a.dll" cfg.fsc_flags ["pos03a.fsi"; "pos03a.fs"] - peverify cfg "pos03a.dll" + peverify cfg "test_two_fsharp_modules_module_2.exe" - [] - let ``sigs pos01a`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:pos01a.dll" cfg.fsc_flags ["pos01a.fsi"; "pos01a.fs"] - peverify cfg "pos01a.dll" + fsc cfg "%s -a --langversion:5.0 --mlcompatibility --standalone -r:test_two_fsharp_modules_module_1.dll -o:test_two_fsharp_modules_module_2_as_dll.dll -g" cfg.fsc_flags ["test_two_fsharp_modules_module_2.fs"] - [] - let ``sigs pos02`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos02.dll" cfg.fsc_flags ["pos02.fs"] - peverify cfg "pos02.dll" + peverify cfg "test_two_fsharp_modules_module_2_as_dll.dll" +#endif [] - let ``sigs pos05`` () = - let cfg = testConfig "typecheck/sigs" - fsc cfg "%s -a -o:pos05.dll" cfg.fsc_flags ["pos05.fs"] - + let ``eval-FSC_OPTIMIZED`` () = singleTestBuildAndRun "tools/eval" FSC_OPTIMIZED [] - let ``type check neg01`` () = singleNegTest (testConfig "typecheck/sigs") "neg01" + let ``eval-FSI`` () = singleTestBuildAndRun "tools/eval" FSI - [] - let ``type check neg02`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "6.0" "neg02" +[] +module RegressionTests = [] - let ``type check neg03`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "supports-ml*" "neg03" + let ``literal-value-bug-2-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/literal-value-bug-2" FSC_OPTIMIZED [] - let ``type check neg04`` () = singleNegTest (testConfig "typecheck/sigs") "neg04" + let ``literal-value-bug-2-FSI`` () = singleTestBuildAndRun "regression/literal-value-bug-2" FSI [] - let ``type check neg05`` () = singleNegTest (testConfig "typecheck/sigs") "neg05" + let ``OverloadResolution-bug-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/OverloadResolution-bug" FSC_OPTIMIZED [] - let ``type check neg06`` () = singleNegTest (testConfig "typecheck/sigs") "neg06" + let ``OverloadResolution-bug-FSI`` () = singleTestBuildAndRun "regression/OverloadResolution-bug" FSI [] - let ``type check neg06_a`` () = singleNegTest (testConfig "typecheck/sigs") "neg06_a" + let ``struct-tuple-bug-1-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/struct-tuple-bug-1" FSC_OPTIMIZED - [] - let ``type check neg06_b`` () = singleNegTest (testConfig "typecheck/sigs") "neg06_b" + [] + let ``tuple-bug-1-FSC_OPTIMIZED`` () = singleTestBuildAndRunVersion "regression/tuple-bug-1" FSC_OPTIMIZED "supports-ml" - [] - let ``type check neg07`` () = singleNegTest (testConfig "typecheck/sigs") "neg07" + [] + let ``12383-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/12383" FSC_OPTIMIZED [] - let ``type check neg08`` () = singleNegTest (testConfig "typecheck/sigs") "neg08" + let ``13219-bug-FSI`` () = singleTestBuildAndRun "regression/13219" FSI - [] - let ``type check neg09`` () = singleNegTest (testConfig "typecheck/sigs") "neg09" + [] + let ``4715-optimized`` () = + let cfg = testConfig "regression/4715" + fsc cfg "%s -o:test.exe --optimize+" cfg.fsc_flags ["date.fs"; "env.fs"; "main.fs"] [] - let ``type check neg10`` () = singleNegTest (testConfig "typecheck/sigs") "neg10" + let ``multi-package-type-provider-test-FSI`` () = singleTestBuildAndRun "regression/13710" FSI - [] - let ``type check neg10_a`` () = singleNegTest (testConfig "typecheck/sigs") "neg10_a" +#if NETCOREAPP + [] + let ``Large inputs 12322 fsc.dll 64-bit fsc.dll .NET SDK generating optimized code`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``type check neg11`` () = singleNegTest (testConfig "typecheck/sigs") "neg11" + [] + let ``Large inputs 12322 fsc.dll 64-bit .NET SDK generating debug code`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) - [] - let ``type check neg12`` () = singleNegTest (testConfig "typecheck/sigs") "neg12" +#else + [] + let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, portable PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``type check neg13`` () = singleNegTest (testConfig "typecheck/sigs") "neg13" + [] + let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, full PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``type check neg14`` () = singleNegTest (testConfig "typecheck/sigs") "neg14" + [] + let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code portable PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) - [] - let ``type check neg15`` () = singleNegTest (testConfig "typecheck/sigs") "neg15" + [] + let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code, full PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) - [] - let ``type check neg16`` () = singleNegTest (testConfig "typecheck/sigs") "neg16" + [] + let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, portable PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with FSC = cfg.FSCANYCPU } + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``type check neg17`` () = singleNegTest (testConfig "typecheck/sigs") "neg17" + [] + let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, full PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with FSC = cfg.FSCANYCPU } + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full " } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY true) - [] - let ``type check neg18`` () = singleNegTest (testConfig "typecheck/sigs") "neg18" + [] + let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, portable PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with FSC = cfg.FSCANYCPU } + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) - [] - let ``type check neg19`` () = singleNegTest (testConfig "typecheck/sigs") "neg19" + [] + let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, full PDB`` () = + let cfg = testConfig "regression/12322" + let cfg = { cfg with FSC = cfg.FSCANYCPU } + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" } + singleTestBuildAndRunAux cfg (FSC_BUILDONLY false) +#endif - [] - let ``type check neg20`` () = singleNegTest (testConfig "typecheck/sigs") "neg20" +#if !NETCOREAPP [] - let ``type check neg20 version 5_0`` () = - let cfg = testConfig "typecheck/sigs/version50" - singleVersionedNegTest cfg "5.0" "neg20" + let ``SRTP doesn't handle calling member hiding hinherited members`` () = + let cfg = + testConfig "regression/5531" + - [] - let ``type check neg21`` () = singleNegTest (testConfig "typecheck/sigs") "neg21" + let outFile = "compilation.output.test.txt" + let expectedFile = "compilation.output.test.bsl" - [] - let ``type check neg23`` () = singleNegTest (testConfig "typecheck/sigs") "neg23" + fscBothToOut cfg outFile "%s --nologo -O" cfg.fsc_flags ["test.fs"] - [] - let ``type check neg24 version 4_6`` () = - let cfg = testConfig "typecheck/sigs/version46" - // For some reason this warning is off by default in the test framework but in this case we are testing for it - let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } - singleVersionedNegTest cfg "4.6" "neg24" + let diff = fsdiff cfg outFile expectedFile - [] - let ``type check neg24 version 4_7`` () = - let cfg = testConfig "typecheck/sigs/version47" - // For some reason this warning is off by default in the test framework but in this case we are testing for it - let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } - singleVersionedNegTest cfg "4.7" "neg24" + match diff with + | "" -> () + | _ -> + Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) - [] - let ``type check neg24 version preview`` () = - let cfg = testConfig "typecheck/sigs" - // For some reason this warning is off by default in the test framework but in this case we are testing for it - let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } - singleVersionedNegTest cfg "preview" "neg24" + let outFile2 = "output.test.txt" + let expectedFile2 = "output.test.bsl" - [] - let ``type check neg25`` () = singleNegTest (testConfig "typecheck/sigs") "neg25" + execBothToOut cfg (cfg.Directory) outFile2 (cfg.Directory ++ "test.exe") "" - [] - let ``type check neg26`` () = singleNegTest (testConfig "typecheck/sigs") "neg26" + let diff2 = fsdiff cfg outFile2 expectedFile2 + match diff2 with + | "" -> () + | _ -> + Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile2) (getfullpath cfg expectedFile2) diff2) +#endif [] - let ``type check neg27`` () = singleNegTest (testConfig "typecheck/sigs") "neg27" + let ``26`` () = singleTestBuildAndRunVersion "regression/26" FSC_OPTIMIZED "supports-ml" - [] - let ``type check neg28`` () = singleNegTest (testConfig "typecheck/sigs") "neg28" + [] + let ``321`` () = singleTestBuildAndRunVersion "regression/321" FSC_OPTIMIZED "supports-ml" +#if !NETCOREAPP + // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 [] - let ``type check neg29`` () = singleNegTest (testConfig "typecheck/sigs") "neg29" + let ``655`` () = + let cfg = testConfig "regression/655" - [] - let ``type check neg30`` () = singleNegTest (testConfig "typecheck/sigs") "neg30" + fsc cfg "%s --langversion:5.0 --mlcompatibility -a -o:pack.dll" cfg.fsc_flags ["xlibC.ml"] - [] - let ``type check neg31`` () = singleNegTest (testConfig "typecheck/sigs") "neg31" + peverify cfg "pack.dll" - [] - let ``type check neg32`` () = singleNegTest (testConfig "typecheck/sigs") "neg32" + fsc cfg "%s --langversion:5.0 --mlcompatibility -o:test.exe -r:pack.dll" cfg.fsc_flags ["main.fs"] - [] - let ``type check neg33`` () = singleNegTest (testConfig "typecheck/sigs") "neg33" + peverify cfg "test.exe" - [] - let ``type check neg34`` () = singleNegTest (testConfig "typecheck/sigs") "neg34" + use testOkFile = fileguard cfg "test.ok" - [] - let ``type check neg35`` () = singleNegTest (testConfig "typecheck/sigs") "neg35" + exec cfg ("." ++ "test.exe") "" - [] - let ``type check neg36`` () = singleNegTest (testConfig "typecheck/sigs") "neg36" + testOkFile.CheckExists() - [] - let ``type check neg37`` () = singleNegTest (testConfig "typecheck/sigs") "neg37" + // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 + [] + let ``656`` () = + let cfg = testConfig "regression/656" - [] - let ``type check neg37_a`` () = singleNegTest (testConfig "typecheck/sigs") "neg37_a" + fsc cfg "%s --langversion:5.0 --mlcompatibility -o:pack.exe" cfg.fsc_flags ["misc.fs mathhelper.fs filehelper.fs formshelper.fs plot.fs traj.fs playerrecord.fs trackedplayers.fs form.fs"] - [] - let ``type check neg38`` () = singleNegTest (testConfig "typecheck/sigs") "neg38" + peverify cfg "pack.exe" +#endif +#if !NETCOREAPP + // Requires WinForms [] - let ``type check neg39`` () = singleNegTest (testConfig "typecheck/sigs") "neg39" + let ``83`` () = singleTestBuildAndRunVersion "regression/83" FSC_OPTIMIZED "supports-ml" - [] - let ``type check neg40`` () = singleNegTest (testConfig "typecheck/sigs") "neg40" + [] + let ``84`` () = singleTestBuildAndRunVersion "regression/84" FSC_OPTIMIZED "supports-ml" - [] - let ``type check neg41`` () = singleNegTest (testConfig "typecheck/sigs") "neg41" + [] + let ``85`` () = + let cfg = testConfig "regression/85" - [] - let ``type check neg42`` () = singleNegTest (testConfig "typecheck/sigs") "neg42" + fsc cfg "%s --langversion:5.0 --mlcompatibility -r:Category.dll -a -o:petshop.dll" cfg.fsc_flags ["Category.ml"] - [] - let ``type check neg43`` () = singleNegTest (testConfig "typecheck/sigs") "neg43" + peverify cfg "petshop.dll" +#endif - [] - let ``type check neg44`` () = singleNegTest (testConfig "typecheck/sigs") "neg44" + [] + let ``86`` () = singleTestBuildAndRunVersion "regression/86" FSC_OPTIMIZED "supports-ml" -#if !DEBUG // requires release version of compiler to avoid very deep stacks - [] - let ``type check neg45`` () = singleNegTest (testConfig "typecheck/sigs") "neg45" -#endif + [] + let ``struct-tuple-bug-1-FSI`` () = singleTestBuildAndRun "regression/struct-tuple-bug-1" FSI +#if !NETCOREAPP + // This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600 [] - let ``type check neg46`` () = singleNegTest (testConfig "typecheck/sigs") "neg46" + let ``struct-measure-bug-1`` () = + let cfg = testConfig "regression/struct-measure-bug-1" - [] - let ``type check neg47`` () = singleNegTest (testConfig "typecheck/sigs") "neg47" + fsc cfg "%s --optimize- -o:test.exe -g" cfg.fsc_flags ["test.fs"] - [] - let ``type check neg48`` () = singleNegTest (testConfig "typecheck/sigs") "neg48" + peverify cfg "test.exe" - [] - let ``type check neg49`` () = singleNegTest (testConfig "typecheck/sigs") "neg49" +[] +module OptimizationTests = [] - let ``type check neg50`` () = singleNegTest (testConfig "typecheck/sigs") "neg50" + let functionSizes () = + let cfg = testConfig "optimize/analyses" - [] - let ``type check neg51`` () = singleNegTest (testConfig "typecheck/sigs") "neg51" + let outFile = "sizes.FunctionSizes.output.test.txt" + let expectedFile = "sizes.FunctionSizes.output.test.bsl" - [] - let ``type check neg52`` () = singleNegTest (testConfig "typecheck/sigs") "neg52" + log "== FunctionSizes" + fscBothToOut cfg outFile "%s --nologo -O --test:FunctionSizes" cfg.fsc_flags ["sizes.fs"] - [] - let ``type check neg53`` () = singleNegTest (testConfig "typecheck/sigs") "neg53" + let diff = fsdiff cfg outFile expectedFile - [] - let ``type check neg54`` () = singleNegTest (testConfig "typecheck/sigs") "neg54" + match diff with + | "" -> () + | _ -> + Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) - [] - let ``type check neg55`` () = singleNegTest (testConfig "typecheck/sigs") "neg55" [] - let ``type check neg56`` () = singleNegTest (testConfig "typecheck/sigs") "neg56" + let totalSizes () = + let cfg = testConfig "optimize/analyses" - [] - let ``type check neg56_a`` () = singleNegTest (testConfig "typecheck/sigs") "neg56_a" + let outFile = "sizes.TotalSizes.output.test.txt" + let expectedFile = "sizes.TotalSizes.output.test.bsl" - [] - let ``type check neg56_b`` () = singleNegTest (testConfig "typecheck/sigs") "neg56_b" + log "== TotalSizes" + fscBothToOut cfg outFile "%s --nologo -O --test:TotalSizes" cfg.fsc_flags ["sizes.fs"] - [] - let ``type check neg57`` () = singleNegTest (testConfig "typecheck/sigs") "neg57" + let diff = fsdiff cfg outFile expectedFile - [] - let ``type check neg58`` () = singleNegTest (testConfig "typecheck/sigs") "neg58" + match diff with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) - [] - let ``type check neg59`` () = singleNegTest (testConfig "typecheck/sigs") "neg59" [] - let ``type check neg60`` () = singleNegTest (testConfig "typecheck/sigs") "neg60" + let hasEffect () = + let cfg = testConfig "optimize/analyses" - [] - let ``type check neg61`` () = singleNegTest (testConfig "typecheck/sigs") "neg61" + let outFile = "effects.HasEffect.output.test.txt" + let expectedFile = "effects.HasEffect.output.test.bsl" - [] - let ``type check neg62`` () = singleNegTest (testConfig "typecheck/sigs") "neg62" + log "== HasEffect" + fscBothToOut cfg outFile "%s --nologo -O --test:HasEffect" cfg.fsc_flags ["effects.fs"] - [] - let ``type check neg63`` () = singleNegTest (testConfig "typecheck/sigs") "neg63" + let diff = fsdiff cfg outFile expectedFile - [] - let ``type check neg64`` () = singleNegTest (testConfig "typecheck/sigs") "neg64" + match diff with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) - [] - let ``type check neg65`` () = singleNegTest (testConfig "typecheck/sigs") "neg65" [] - let ``type check neg66`` () = singleNegTest (testConfig "typecheck/sigs") "neg66" + let noNeedToTailcall () = + let cfg = testConfig "optimize/analyses" - [] - let ``type check neg67`` () = singleNegTest (testConfig "typecheck/sigs") "neg67" + let outFile = "tailcalls.NoNeedToTailcall.output.test.txt" + let expectedFile = "tailcalls.NoNeedToTailcall.output.test.bsl" - [] - let ``type check neg68`` () = singleNegTest (testConfig "typecheck/sigs") "neg68" + log "== NoNeedToTailcall" + fscBothToOut cfg outFile "%s --nologo -O --test:NoNeedToTailcall" cfg.fsc_flags ["tailcalls.fs"] - [] - let ``type check neg69`` () = singleNegTest (testConfig "typecheck/sigs") "neg69" + let diff = fsdiff cfg outFile expectedFile - [] - let ``type check neg70`` () = singleNegTest (testConfig "typecheck/sigs") "neg70" + match diff with + | "" -> () + | _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) - [] - let ``type check neg71`` () = singleNegTest (testConfig "typecheck/sigs") "neg71" [] - let ``type check neg72`` () = singleNegTest (testConfig "typecheck/sigs") "neg72" + let ``inline`` () = + let cfg = testConfig "optimize/inline" - [] - let ``type check neg73`` () = singleNegTest (testConfig "typecheck/sigs") "neg73" + fsc cfg "%s -g --optimize- --target:library -o:lib.dll" cfg.fsc_flags ["lib.fs"; "lib2.fs"] - [] - let ``type check neg74`` () = singleNegTest (testConfig "typecheck/sigs") "neg74" + peverify cfg "lib.dll " - [] - let ``type check neg75`` () = singleNegTest (testConfig "typecheck/sigs") "neg75" + fsc cfg "%s -g --optimize- --target:library -o:lib3.dll -r:lib.dll " cfg.fsc_flags ["lib3.fs"] - [] - let ``type check neg76`` () = singleNegTest (testConfig "typecheck/sigs") "neg76" + fsc cfg "%s -g --optimize- -o:test.exe -r:lib.dll -r:lib3.dll" cfg.fsc_flags ["test.fs "] - [] - let ``type check neg77`` () = singleNegTest (testConfig "typecheck/sigs") "neg77" + fsc cfg "%s --optimize --target:library -o:lib--optimize.dll -g" cfg.fsc_flags ["lib.fs"; "lib2.fs"] - [] - let ``type check neg78`` () = singleNegTest (testConfig "typecheck/sigs") "neg78" + fsc cfg "%s --optimize --target:library -o:lib3--optimize.dll -r:lib--optimize.dll -g" cfg.fsc_flags ["lib3.fs"] - [] - let ``type check neg79`` () = singleNegTest (testConfig "typecheck/sigs") "neg79" + fsc cfg "%s --optimize -o:test--optimize.exe -g -r:lib--optimize.dll -r:lib3--optimize.dll" cfg.fsc_flags ["test.fs "] - [] - let ``type check neg80`` () = singleNegTest (testConfig "typecheck/sigs") "neg80" + ildasm cfg "/out=test.il" "test.exe" - [] - let ``type check neg81`` () = singleNegTest (testConfig "typecheck/sigs") "neg81" + ildasm cfg "/out=test--optimize.il" "test--optimize.exe" - [] - let ``type check neg82`` () = singleNegTest (testConfig "typecheck/sigs") "neg82" + let ``test--optimize.il`` = + File.ReadLines (getfullpath cfg "test--optimize.il") + |> Seq.filter (fun line -> line.Contains(".locals init")) + |> List.ofSeq - [] - let ``type check neg83`` () = singleNegTest (testConfig "typecheck/sigs") "neg83" + match ``test--optimize.il`` with + | [] -> () + | lines -> + Assert.Fail (sprintf "Error: optimizations not removed. Relevant lines from IL file follow: %A" lines) - [] - let ``type check neg84`` () = singleNegTest (testConfig "typecheck/sigs") "neg84" + let numElim = + File.ReadLines (getfullpath cfg "test.il") + |> Seq.filter (fun line -> line.Contains(".locals init")) + |> Seq.length - [] - let ``type check neg85`` () = singleNegTest (testConfig "typecheck/sigs") "neg85" + log "Ran ok - optimizations removed %d textual occurrences of optimizable identifiers from target IL" numElim [] - let ``type check neg86`` () = singleNegTest (testConfig "typecheck/sigs") "neg86" + let stats () = + let cfg = testConfig "optimize/stats" - [] - let ``type check neg88`` () = singleNegTest (testConfig "typecheck/sigs") "neg88" + ildasm cfg "/out=FSharp.Core.il" cfg.FSCOREDLLPATH - [] - let ``type check neg89`` () = singleNegTest (testConfig "typecheck/sigs") "neg89" + let fscore = File.ReadLines(getfullpath cfg "FSharp.Core.il") |> Seq.toList - [] - let ``type check neg90`` () = singleNegTest (testConfig "typecheck/sigs") "neg90" + let contains text (s: string) = if s.Contains(text) then 1 else 0 - [] - let ``type check neg91`` () = singleNegTest (testConfig "typecheck/sigs") "neg91" + let typeFunc = fscore |> List.sumBy (contains "extends Microsoft.FSharp.TypeFunc") + let classes = fscore |> List.sumBy (contains ".class") + let methods = fscore |> List.sumBy (contains ".method") + let fields = fscore |> List.sumBy (contains ".field") - [] - let ``type check neg92`` () = singleNegTest (testConfig "typecheck/sigs") "neg92" + let date = DateTime.Today.ToString("dd/MM/yyyy") // 23/11/2006 + let time = DateTime.Now.ToString("HH:mm:ss.ff") // 16:03:23.40 + let m = sprintf "%s, %s, Microsoft.FSharp-TypeFunc, %d, Microsoft.FSharp-classes, %d, Microsoft.FSharp-methods, %d, , Microsoft.FSharp-fields, %d, " date time typeFunc classes methods fields - [] - let ``type check neg93`` () = singleNegTest (testConfig "typecheck/sigs") "neg93" + log "now:" + log "%s" m +#endif +[] +module TypecheckTests = [] - let ``type check neg94`` () = singleNegTest (testConfig "typecheck/sigs") "neg94" + let ``full-rank-arrays`` () = + let cfg = testConfig "typecheck/full-rank-arrays" + SingleTest.singleTestBuildAndRunWithCopyDlls cfg "full-rank-arrays.dll" FSC_OPTIMIZED - [] - let ``type check neg95`` () = singleNegTest (testConfig "typecheck/sigs") "neg95" +#if !NETCOREAPP [] - let ``type check neg96`` () = singleNegTest (testConfig "typecheck/sigs") "neg96" + let ``sigs pos26`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos26.exe" cfg.fsc_flags ["pos26.fsi"; "pos26.fs"] + peverify cfg "pos26.exe" [] - let ``type check neg97`` () = singleNegTest (testConfig "typecheck/sigs") "neg97" + let ``sigs pos25`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos25.exe" cfg.fsc_flags ["pos25.fs"] + peverify cfg "pos25.exe" [] - let ``type check neg98`` () = singleNegTest (testConfig "typecheck/sigs") "neg98" + let ``sigs pos27`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos27.exe" cfg.fsc_flags ["pos27.fs"] + peverify cfg "pos27.exe" [] - let ``type check neg99`` () = singleNegTest (testConfig "typecheck/sigs") "neg99" + let ``sigs pos28`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos28.exe" cfg.fsc_flags ["pos28.fs"] + peverify cfg "pos28.exe" [] - let ``type check neg100`` () = + let ``sigs pos29`` () = let cfg = testConfig "typecheck/sigs" - let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --warnon:3218" } - singleNegTest cfg "neg100" + fsc cfg "%s --target:exe -o:pos29.exe" cfg.fsc_flags ["pos29.fsi"; "pos29.fs"; "pos29.app.fs"] + peverify cfg "pos29.exe" [] - let ``type check neg101`` () = singleNegTest (testConfig "typecheck/sigs") "neg101" + let ``sigs pos30`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos30.exe --warnaserror+" cfg.fsc_flags ["pos30.fs"] + peverify cfg "pos30.exe" [] - let ``type check neg102`` () = singleNegTest (testConfig "typecheck/sigs") "neg102" + let ``sigs pos24`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos24.exe" cfg.fsc_flags ["pos24.fs"] + peverify cfg "pos24.exe" [] - let ``type check neg103`` () = singleNegTest (testConfig "typecheck/sigs") "neg103" + let ``sigs pos31`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos31.exe --warnaserror" cfg.fsc_flags ["pos31.fsi"; "pos31.fs"] + peverify cfg "pos31.exe" [] - let ``type check neg104`` () = singleNegTest (testConfig "typecheck/sigs") "neg104" + let ``sigs pos32`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos32.dll --warnaserror" cfg.fsc_flags ["pos32.fs"] + peverify cfg "pos32.dll" [] - let ``type check neg106`` () = singleNegTest (testConfig "typecheck/sigs") "neg106" + let ``sigs pos33`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos33.dll --warnaserror" cfg.fsc_flags ["pos33.fsi"; "pos33.fs"] + peverify cfg "pos33.dll" [] - let ``type check neg107`` () = singleNegTest (testConfig "typecheck/sigs") "neg107" + let ``sigs pos34`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos34.dll --warnaserror" cfg.fsc_flags ["pos34.fs"] + peverify cfg "pos34.dll" [] - let ``type check neg108`` () = singleNegTest (testConfig "typecheck/sigs") "neg108" + let ``sigs pos35`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos35.dll --warnaserror" cfg.fsc_flags ["pos35.fs"] + peverify cfg "pos35.dll" [] - let ``type check neg109`` () = singleNegTest (testConfig "typecheck/sigs") "neg109" + let ``sigs pos36-srtp`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos36-srtp-lib.dll --warnaserror" cfg.fsc_flags ["pos36-srtp-lib.fs"] + fsc cfg "%s --target:exe -r:pos36-srtp-lib.dll -o:pos36-srtp-app.exe --warnaserror" cfg.fsc_flags ["pos36-srtp-app.fs"] + peverify cfg "pos36-srtp-lib.dll" + peverify cfg "pos36-srtp-app.exe" + exec cfg ("." ++ "pos36-srtp-app.exe") "" [] - let ``type check neg110`` () = singleNegTest (testConfig "typecheck/sigs") "neg110" + let ``sigs pos37`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos37.dll --warnaserror" cfg.fsc_flags ["pos37.fs"] + peverify cfg "pos37.dll" [] - let ``type check neg111`` () = singleNegTest (testConfig "typecheck/sigs") "neg111" + let ``sigs pos38`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:library -o:pos38.dll --warnaserror" cfg.fsc_flags ["pos38.fs"] + peverify cfg "pos38.dll" - [] - let ``type check neg112`` () = singleNegTest (testConfig "typecheck/sigs") "neg112" - [] - let ``type check neg113`` () = singleNegTest (testConfig "typecheck/sigs") "neg113" + let ``sigs pos39`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos39.exe" cfg.fsc_flags ["pos39.fs"] + peverify cfg "pos39.exe" + exec cfg ("." ++ "pos39.exe") "" [] - let ``type check neg114`` () = singleNegTest (testConfig "typecheck/sigs") "neg114" + let ``sigs pos40`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --langversion:6.0 --target:exe -o:pos40.exe" cfg.fsc_flags ["pos40.fs"] + peverify cfg "pos40.exe" + exec cfg ("." ++ "pos40.exe") "" [] - let ``type check neg115`` () = singleNegTest (testConfig "typecheck/sigs") "neg115" + let ``sigs pos1281`` () = + let cfg = testConfig "typecheck/sigs" + // This checks that warning 25 "incomplete matches" is not triggered + fsc cfg "%s --target:exe -o:pos1281.exe --warnaserror --nowarn:26" cfg.fsc_flags ["pos1281.fs"] + peverify cfg "pos1281.exe" + exec cfg ("." ++ "pos1281.exe") "" [] - let ``type check neg116`` () = singleNegTest (testConfig "typecheck/sigs") "neg116" + let ``sigs pos3294`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos3294.exe --warnaserror" cfg.fsc_flags ["pos3294.fs"] + peverify cfg "pos3294.exe" + exec cfg ("." ++ "pos3294.exe") "" [] - let ``type check neg117`` () = singleNegTest (testConfig "typecheck/sigs") "neg117" + let ``sigs pos23`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos23.exe" cfg.fsc_flags ["pos23.fs"] + peverify cfg "pos23.exe" + exec cfg ("." ++ "pos23.exe") "" [] - let ``type check neg118`` () = singleNegTest (testConfig "typecheck/sigs") "neg118" + let ``sigs pos20`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos20.exe" cfg.fsc_flags ["pos20.fs"] + peverify cfg "pos20.exe" + exec cfg ("." ++ "pos20.exe") "" [] - let ``type check neg119a`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "6.0" "neg119a" + let ``sigs pos19`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos19.exe" cfg.fsc_flags ["pos19.fs"] + peverify cfg "pos19.exe" + exec cfg ("." ++ "pos19.exe") "" [] - let ``type check neg119b`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "7.0" "neg119b" + let ``sigs pos18`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos18.exe" cfg.fsc_flags ["pos18.fs"] + peverify cfg "pos18.exe" + exec cfg ("." ++ "pos18.exe") "" [] - let ``type check neg120`` () = singleNegTest (testConfig "typecheck/sigs") "neg120" + let ``sigs pos16`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos16.exe" cfg.fsc_flags ["pos16.fs"] + peverify cfg "pos16.exe" + exec cfg ("." ++ "pos16.exe") "" [] - let ``type check neg121`` () = singleNegTest (testConfig "typecheck/sigs") "neg121" + let ``sigs pos17`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos17.exe" cfg.fsc_flags ["pos17.fs"] + peverify cfg "pos17.exe" + exec cfg ("." ++ "pos17.exe") "" [] - let ``type check neg122`` () = singleNegTest (testConfig "typecheck/sigs") "neg122" + let ``sigs pos15`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos15.exe" cfg.fsc_flags ["pos15.fs"] + peverify cfg "pos15.exe" + exec cfg ("." ++ "pos15.exe") "" [] - let ``type check neg123`` () = singleNegTest (testConfig "typecheck/sigs") "neg123" + let ``sigs pos14`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos14.exe" cfg.fsc_flags ["pos14.fs"] + peverify cfg "pos14.exe" + exec cfg ("." ++ "pos14.exe") "" [] - let ``type check neg124`` () = singleNegTest (testConfig "typecheck/sigs") "neg124" + let ``sigs pos13`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s --target:exe -o:pos13.exe" cfg.fsc_flags ["pos13.fs"] + peverify cfg "pos13.exe" + exec cfg ("." ++ "pos13.exe") "" [] - let ``type check neg125`` () = singleNegTest (testConfig "typecheck/sigs") "neg125" + let ``sigs pos12 `` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos12.dll" cfg.fsc_flags ["pos12.fs"] [] - let ``type check neg126`` () = singleNegTest (testConfig "typecheck/sigs") "neg126" + let ``sigs pos11`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos11.dll" cfg.fsc_flags ["pos11.fs"] [] - let ``type check neg127`` () = singleNegTest (testConfig "typecheck/sigs") "neg127" + let ``sigs pos10`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos10.dll" cfg.fsc_flags ["pos10.fs"] + peverify cfg "pos10.dll" [] - let ``type check neg128`` () = singleNegTest (testConfig "typecheck/sigs") "neg128" + let ``sigs pos09`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos09.dll" cfg.fsc_flags ["pos09.fs"] + peverify cfg "pos09.dll" [] - let ``type check neg129`` () = singleNegTest (testConfig "typecheck/sigs") "neg129" + let ``sigs pos07`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos07.dll" cfg.fsc_flags ["pos07.fs"] + peverify cfg "pos07.dll" [] - let ``type check neg130`` () = singleNegTest (testConfig "typecheck/sigs") "neg130" + let ``sigs pos08`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos08.dll" cfg.fsc_flags ["pos08.fs"] + peverify cfg "pos08.dll" [] - let ``type check neg131`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "6.0" "neg131" + let ``sigs pos06`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos06.dll" cfg.fsc_flags ["pos06.fs"] + peverify cfg "pos06.dll" [] - let ``type check neg132`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "5.0" "neg132" - - [] - let ``type check neg133`` () = singleNegTest (testConfig "typecheck/sigs") "neg133" + let ``sigs pos03`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos03.dll" cfg.fsc_flags ["pos03.fs"] + peverify cfg "pos03.dll" + fsc cfg "%s -a -o:pos03a.dll" cfg.fsc_flags ["pos03a.fsi"; "pos03a.fs"] + peverify cfg "pos03a.dll" [] - let ``type check neg_anon_1`` () = singleNegTest (testConfig "typecheck/sigs") "neg_anon_1" + let ``sigs pos01a`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a --langversion:5.0 --mlcompatibility -o:pos01a.dll" cfg.fsc_flags ["pos01a.fsi"; "pos01a.fs"] + peverify cfg "pos01a.dll" [] - let ``type check neg_anon_2`` () = singleNegTest (testConfig "typecheck/sigs") "neg_anon_2" + let ``sigs pos02`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos02.dll" cfg.fsc_flags ["pos02.fs"] + peverify cfg "pos02.dll" [] - let ``type check neg_issue_3752`` () = singleNegTest (testConfig "typecheck/sigs") "neg_issue_3752" + let ``sigs pos05`` () = + let cfg = testConfig "typecheck/sigs" + fsc cfg "%s -a -o:pos05.dll" cfg.fsc_flags ["pos05.fs"] [] - let ``type check neg_byref_1`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_1" + let ``type check neg01`` () = singleNegTest (testConfig "typecheck/sigs") "neg01" [] - let ``type check neg_byref_2`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_2" + let ``type check neg03`` () = singleVersionedNegTest (testConfig "typecheck/sigs") "supports-ml*" "neg03" [] - let ``type check neg_byref_3`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_3" + let ``type check neg08`` () = singleNegTest (testConfig "typecheck/sigs") "neg08" [] - let ``type check neg_byref_4`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_4" + let ``type check neg09`` () = singleNegTest (testConfig "typecheck/sigs") "neg09" [] - let ``type check neg_byref_5`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_5" - + let ``type check neg10`` () = singleNegTest (testConfig "typecheck/sigs") "neg10" + [] - let ``type check neg_byref_6`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_6" + let ``type check neg14`` () = singleNegTest (testConfig "typecheck/sigs") "neg14" [] - let ``type check neg_byref_7`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_7" + let ``type check neg17`` () = singleNegTest (testConfig "typecheck/sigs") "neg17" [] - let ``type check neg_byref_8`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_8" + let ``type check neg24 version 4_6`` () = + let cfg = testConfig "typecheck/sigs/version46" + // For some reason this warning is off by default in the test framework but in this case we are testing for it + let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } + singleVersionedNegTest cfg "4.6" "neg24" [] - let ``type check neg_byref_10`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_10" + let ``type check neg24 version 4_7`` () = + let cfg = testConfig "typecheck/sigs/version47" + // For some reason this warning is off by default in the test framework but in this case we are testing for it + let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } + singleVersionedNegTest cfg "4.7" "neg24" [] - let ``type check neg_byref_11`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_11" + let ``type check neg24 version preview`` () = + let cfg = testConfig "typecheck/sigs" + // For some reason this warning is off by default in the test framework but in this case we are testing for it + let cfg = { cfg with fsc_flags = cfg.fsc_flags.Replace("--nowarn:20", "") } + singleVersionedNegTest cfg "preview" "neg24" [] - let ``type check neg_byref_12`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_12" + let ``type check neg27`` () = singleNegTest (testConfig "typecheck/sigs") "neg27" [] - let ``type check neg_byref_13`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_13" + let ``type check neg31`` () = singleNegTest (testConfig "typecheck/sigs") "neg31" [] - let ``type check neg_byref_14`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_14" + let ``type check neg33`` () = singleNegTest (testConfig "typecheck/sigs") "neg33" [] - let ``type check neg_byref_15`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_15" + let ``type check neg43`` () = singleNegTest (testConfig "typecheck/sigs") "neg43" +#if !DEBUG // requires release version of compiler to avoid very deep stacks [] - let ``type check neg_byref_16`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_16" + let ``type check neg45`` () = singleNegTest (testConfig "typecheck/sigs") "neg45" +#endif [] - let ``type check neg_byref_17`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_17" + let ``type check neg49`` () = singleNegTest (testConfig "typecheck/sigs") "neg49" [] - let ``type check neg_byref_18`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_18" + let ``type check neg56_a`` () = singleNegTest (testConfig "typecheck/sigs") "neg56_a" [] - let ``type check neg_byref_19`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_19" + let ``type check neg94`` () = singleNegTest (testConfig "typecheck/sigs") "neg94" [] - let ``type check neg_byref_20`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_20" + let ``type check neg100`` () = + let cfg = testConfig "typecheck/sigs" + let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --warnon:3218" } + singleNegTest cfg "neg100" [] - let ``type check neg_byref_21`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_21" - + let ``type check neg107`` () = singleNegTest (testConfig "typecheck/sigs") "neg107" + [] - let ``type check neg_byref_22`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_22" + let ``type check neg116`` () = singleNegTest (testConfig "typecheck/sigs") "neg116" [] - let ``type check neg_byref_23`` () = singleNegTest (testConfig "typecheck/sigs") "neg_byref_23" + let ``type check neg117`` () = singleNegTest (testConfig "typecheck/sigs") "neg117" [] module FscTests = @@ -3382,40 +2501,4 @@ namespace CST.RI.Anshun fileVersionInfo.ProductVersion |> Assert.areEqual expected -#endif - -#if !NETCOREAPP -[] -module OverloadResolution__MigratedAlready_FeelFreeToDelete = - module ``fsharpqa migrated tests`` = - let [] ``Conformance\Expressions\SyntacticSugar (E_Slices01_fs)`` () = singleNegTest (testConfig "conformance/expressions/syntacticsugar") "E_Slices01" - let [] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03_fsx)`` () = singleNegTest (testConfig "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03" - let [] ``Conformance\Inference (E_OneTypeVariable03_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_OneTypeVariable03" - let [] ``Conformance\Inference (E_OneTypeVariable03rec_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_OneTypeVariable03rec" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariablesGen00" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariables01" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariables01rec_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariables01rec" - let [] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00rec_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariablesGen00rec" - let [] ``Conformance\Inference (E_TwoEqualTypeVariables02_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoEqualTypeVariables02" - let [] ``Conformance\Inference (E_TwoEqualYypeVariables02rec_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoEqualYypeVariables02rec" - let [] ``Conformance\Inference (E_LeftToRightOverloadResolution01_fs)`` () = singleNegTest (testConfig "conformance/inference") "E_LeftToRightOverloadResolution01" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01_fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03_fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03" - let [] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04_fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04" - // note: this test still exist in fsharpqa to assert the compiler doesn't crash - // the part of the code generating a flaky error due to https://github.com/dotnet/fsharp/issues/6725 - // is elided here to focus on overload resolution error messages - let [] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001_fs)`` () = singleNegTest (testConfig "conformance/lexicalanalysis") "E_LessThanDotOpenParen001" - - module ``error messages using BCL``= - let [] ``neg_System_Convert_ToString_OverloadList``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Convert.ToString.OverloadList" - let [] ``neg_System_Threading_Tasks_Task_Run_OverloadList``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Threading.Tasks.Task.Run.OverloadList" - let [] ``neg_System_Drawing_Graphics_DrawRectangleOverloadList_fsx``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Drawing.Graphics.DrawRectangleOverloadList" - - module ``ad hoc code overload error messages``= - let [] ``neg_many_many_overloads`` () = singleNegTest (testConfig "typecheck/overloads") "neg_many_many_overloads" - let [] ``neg_interface_generics`` () = singleNegTest (testConfig "typecheck/overloads") "neg_interface_generics" - let [] ``neg_known_return_type_and_known_type_arguments`` () = singleNegTest (testConfig "typecheck/overloads") "neg_known_return_type_and_known_type_arguments" - let [] ``neg_generic_known_argument_types`` () = singleNegTest (testConfig "typecheck/overloads") "neg_generic_known_argument_types" - let [] ``neg_tupled_arguments`` () = singleNegTest (testConfig "typecheck/overloads") "neg_tupled_arguments" -#endif +#endif \ No newline at end of file From 547b68c24a25ece981057fb7bd833af378c295ee Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 31 Jan 2023 13:19:39 +0100 Subject: [PATCH 14/19] Test framework - script execution in separate thread (to get shorter call stack) --- tests/FSharp.Test.Utilities/Compiler.fs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 32be989438f..d1ed0ee1292 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -835,9 +835,8 @@ module rec Compiler = |> List.map (fun x -> x.GetSourceFileName) |> List.map (sprintf " @\"%s\"") |> String.Concat - - script.Eval("#load" + fileNames ) - |> (processScriptResults fs) + let scripTask = async { return script.Eval("#load" + fileNames ) } |> Async.StartAsTask + scripTask.GetAwaiter().GetResult() |> (processScriptResults fs) let eval (cUnit: CompilationUnit) : CompilationResult = match cUnit with From 05093a0dc5163db56b8ac32d0b7c7d316f718d8f Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 31 Jan 2023 14:12:11 +0100 Subject: [PATCH 15/19] Trying to address stackoverflow for MacOs CI run --- azure-pipelines.yml | 2 ++ tests/FSharp.Test.Utilities/Compiler.fs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9e7825f03b9..980fd1bab83 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -441,6 +441,8 @@ stages: - checkout: self clean: true - script: ./eng/cibuild.sh --configuration $(_BuildConfig) --testcoreclr + env: + COMPlus_DefaultStackSize: 1000000 displayName: Build / Test - task: PublishTestResults@2 displayName: Publish Test Results diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index d1ed0ee1292..d14a53f0b38 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -835,8 +835,8 @@ module rec Compiler = |> List.map (fun x -> x.GetSourceFileName) |> List.map (sprintf " @\"%s\"") |> String.Concat - let scripTask = async { return script.Eval("#load" + fileNames ) } |> Async.StartAsTask - scripTask.GetAwaiter().GetResult() |> (processScriptResults fs) + + script.Eval("#load" + fileNames ) |> (processScriptResults fs) let eval (cUnit: CompilationUnit) : CompilationResult = match cUnit with From 4b16738928a3752815d879d0efff29701d796f43 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 31 Jan 2023 17:13:17 +0100 Subject: [PATCH 16/19] Fixing negtest45 run to match older test suite --- .../Miscellaneous/FsharpSuiteMigrated.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 1ef1d1df2ad..9f1ce26048a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -134,7 +134,7 @@ module TestFrameworkAdapter = |> withOptions (["--nowarn:0988;3370"] @ bonusArgs) | NEG_TEST_BUILD _ -> cu |> - withOptions (["--vserrors";"--maxerrors:10000";"--warnaserror";"--warn:3";"--nowarn:20;1178;52"] @ bonusArgs) + withOptions (["--vserrors";"--maxerrors:10000";"--warnaserror";"--warn:3";"--nowarn:20;21;1178;52"] @ bonusArgs) |> fun cu -> match mode with | FSC_DEBUG -> From 086e272dde8730e8cb4e52d8cc70f4059749590b Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 6 Feb 2023 14:45:32 +0100 Subject: [PATCH 17/19] Apply suggestions from code review --- tests/FSharp.Test.Utilities/Compiler.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index d14a53f0b38..1db3a5f4056 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1288,8 +1288,8 @@ module rec Compiler = module TextBasedDiagnosticAsserts = open FSharp.Compiler.Text.Range - let private messageAndNumber erroryType = - match erroryType with + let private messageAndNumber errorType= + match errorType with | ErrorType.Error n -> "error",n | ErrorType.Warning n-> "warning",n | ErrorType.Hidden n @@ -1323,7 +1323,7 @@ module rec Compiler = | _ -> File.WriteAllText(path, actualErrors) match Assert.shouldBeSameMultilineStringSets expectedContent actualErrors with - | None -> () // Assert.That(actualErrors, Is.EqualTo(expectedContent).NoClip,path) + | None -> () | Some diff -> Assert.That(diff, Is.Empty, path) result From 27928bf11b60dbe2a2ee85b8bd1a0a3de00aa588 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 6 Feb 2023 18:17:19 +0100 Subject: [PATCH 18/19] conflicts resolved --- .../Language/SequenceExpressionTests.fs | 4 ++-- tests/FSharp.Test.Utilities/Compiler.fs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs index 5542717a94a..9f87a5078eb 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs @@ -4,10 +4,10 @@ module FSharp.Compiler.ComponentTests.Language.SequenceExpressionTests open Xunit open FSharp.Test.Compiler +open FSharp.Test.ScriptHelpers - -let fsiSession = getSessionForEval() +let fsiSession = getSessionForEval [||] LangVersion.Preview let runCode = evalInSharedSession fsiSession diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 1db3a5f4056..2107de014d0 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -366,6 +366,9 @@ module rec Compiler = | FS fs -> FS { fs with Options = fs.Options @ options } | _ -> failwith message + let withCodepage (codepage:string) (cUnit: CompilationUnit) : CompilationUnit = + withOptionsHelper [ $"--codepage:{codepage}" ] "codepage is only supported on F#" cUnit + let withDebug (cUnit: CompilationUnit) : CompilationUnit = withOptionsHelper [ "--debug+" ] "debug+ is only supported on F#" cUnit From 81d060fae1b2e4822d60ad469618277dc6ee3b62 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Sat, 11 Feb 2023 00:40:56 +0100 Subject: [PATCH 19/19] Apply suggestions from code review --- .../Miscellaneous/FsharpSuiteMigrated.fs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs index 9f1ce26048a..00ed7c9dc5e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs +++ b/tests/FSharp.Compiler.ComponentTests/Miscellaneous/FsharpSuiteMigrated.fs @@ -11,6 +11,9 @@ open FSharp.Test.ScriptHelpers +module Configuration = + let supportedNames = set ["testlib.fsi";"testlib.fs";"test.mli";"test.ml";"test.fsi";"test.fs";"test2.fsi";"test2.fs";"test.fsx";"test2.fsx"] + module ScriptRunner = open Internal.Utilities.Library @@ -90,7 +93,6 @@ module TestFrameworkAdapter = | LangVersion.Latest -> "latest", bonusArgs | LangVersion.SupportsMl -> "5.0", "--mlcompatibility" :: bonusArgs - let supportedNames = set ["testlib.fsi";"testlib.fs";"test.mli";"test.ml";"test.fsi";"test.fs";"test2.fsi";"test2.fs";"test.fsx";"test2.fsx"] let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion = let absFolder = Path.Combine(baseFolder,folder) @@ -98,14 +100,14 @@ module TestFrameworkAdapter = match mode with | NEG_TEST_BUILD testName -> let nameSet = - supportedNames + Configuration.supportedNames .Add(testName+".fsx") .Add(testName+".fs") .Add(testName+".fsi") .Add(testName+"-pre.fs") let files = Directory.GetFiles(absFolder,"*.fs*") |> Array.filter(fun n -> nameSet.Contains(Path.GetFileName(n))) nameSet, files - | _ -> supportedNames, Directory.GetFiles(absFolder,"test*.fs*") + | _ -> Configuration.supportedNames, Directory.GetFiles(absFolder,"test*.fs*") let mainFile,otherFiles = match files.Length with