From 2b1084d7acf35141ed2f66dec33b311aaaa8f954 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 15:56:47 +0200 Subject: [PATCH 01/32] one --- .../FSharp.Compiler.Service.Tests.fsproj | 3 -- .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../PerfTests.fs | 48 +++++++++---------- 3 files changed, 23 insertions(+), 32 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/PerfTests.fs (76%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index cd4f7e2d1db..fe609d69cef 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -52,9 +52,6 @@ MultiProjectAnalysisTests.fs - - PerfTests.fs - InteractiveCheckerTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 38a8a9c4e49..0dd25d55697 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -53,9 +53,7 @@ CompilerService\MultiProjectAnalysisTests.fs --> - - CompilerService\PerfTests.fs - + CompilerService\InteractiveCheckerTests.fs diff --git a/tests/service/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs similarity index 76% rename from tests/service/PerfTests.fs rename to tests/FSharp.Compiler.UnitTests/PerfTests.fs index b3c47903283..5a7c5e56d6a 100644 --- a/tests/service/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -1,21 +1,18 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module FSharp.Compiler.Service.Tests.PerfTests #endif - -open NUnit.Framework -open FsUnit +open Xunit open System.IO open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.IO open FSharp.Compiler.Text open FSharp.Compiler.Service.Tests.Common open TestFramework +open FSharp.Test // Create an interactive checker instance let internal checker = FSharpChecker.Create() @@ -36,9 +33,8 @@ module internal Project1 = let parsingOptions, _ = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args) -[] +[] let ``Test request for parse and check doesn't check whole project`` () = - printfn "starting test..." let backgroundParseCount = ref 0 let backgroundCheckCount = ref 0 @@ -51,54 +47,54 @@ let ``Test request for parse and check doesn't check whole project`` () = printfn "ParseFile()..." let parseResults1 = checker.ParseFile(Project1.fileNames[5], Project1.fileSources2[5], Project1.parsingOptions) |> Async.RunImmediate let pC, tC = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount - (pC - pB) |> shouldEqual 1 - (tC - tB) |> shouldEqual 0 + (pC - pB) |> Assert.shouldBe 1 + (tC - tB) |> Assert.shouldBe 0 printfn "checking backgroundParseCount.Value = %d" backgroundParseCount.Value - backgroundParseCount.Value |> shouldEqual 0 + backgroundParseCount.Value |> Assert.shouldBe 0 printfn "checking backgroundCheckCount.Value = %d" backgroundCheckCount.Value - backgroundCheckCount.Value |> shouldEqual 0 + backgroundCheckCount.Value |> Assert.shouldBe 0 printfn "CheckFileInProject()..." let checkResults1 = checker.CheckFileInProject(parseResults1, Project1.fileNames[5], 0, Project1.fileSources2[5], Project1.options) |> Async.RunImmediate let pD, tD = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking background parsing happened...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value >= 5) |> shouldEqual true // but note, the project does not get reparsed + (backgroundParseCount.Value >= 5) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking background typechecks happened...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value >= 5) |> shouldEqual true // only two extra typechecks of files + (backgroundCheckCount.Value >= 5) |> Assert.shouldBeTrue // only two extra typechecks of files printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - (pD - pC) |> shouldEqual 0 + (pD - pC) |> Assert.shouldBe 0 printfn "checking (tD - tC) = %d" (tD - tC) - (tD - tC) |> shouldEqual 1 + (tD - tC) |> Assert.shouldBe 1 printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pE, tE = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...., (pE - pD) = %d" (pE - pD) - (pE - pD) |> shouldEqual 0 + (pE - pD) |> Assert.shouldBe 0 printfn "checking one foreground typecheck...., tE - tD = %d" (tE - tD) - (tE - tD) |> shouldEqual 1 + (tE - tD) |> Assert.shouldBe 1 printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files printfn "ParseAndCheckFileInProject()..." // A subsequent ParseAndCheck of identical source code doesn't do any more anything let checkResults2 = checker.ParseAndCheckFileInProject(Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pF, tF = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...." - (pF - pE) |> shouldEqual 0 // note, no new parse of the file + (pF - pE) |> Assert.shouldBe 0 // note, no new parse of the file printfn "checking no extra foreground typechecks...." - (tF - tE) |> shouldEqual 0 // note, no new typecheck of the file + (tF - tE) |> Assert.shouldBe 0 // note, no new typecheck of the file printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files () From abe759c2132ac8463eeada677321dd9a45a8a868 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 16:10:29 +0200 Subject: [PATCH 02/32] two --- .../AssemblyContentProviderTests.fs | 14 ++++++-------- .../FSharp.Compiler.UnitTests.fsproj | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/AssemblyContentProviderTests.fs (96%) diff --git a/tests/service/AssemblyContentProviderTests.fs b/tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs similarity index 96% rename from tests/service/AssemblyContentProviderTests.fs rename to tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs index 41d6a8c660f..e87ee58ec4a 100644 --- a/tests/service/AssemblyContentProviderTests.fs +++ b/tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs @@ -1,14 +1,12 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.AssemblyContentProviderTests #endif open System -open NUnit.Framework +open Xunit open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common @@ -69,7 +67,7 @@ let private getSymbolMap (getSymbolProperty: AssemblySymbol -> 'a) (source: stri |> List.map (fun s -> getCleanedFullName s, getSymbolProperty s) |> Map.ofList -[] +[] let ``implicitly added Module suffix is removed``() = """ type MyType = { F: int } @@ -82,7 +80,7 @@ module MyType = "Test.MyType" "Test.MyType.func123"] -[] +[] let ``Module suffix added by an explicitly applied ModuleSuffix attribute is removed``() = """ [] @@ -93,7 +91,7 @@ module MyType = "Test.MyType" "Test.MyType.func123" ] -[] +[] let ``Property getters and setters are removed``() = """ type MyType() = @@ -103,7 +101,7 @@ let ``Property getters and setters are removed``() = "Test.MyType" "Test.MyType.MyProperty" ] -[] +[] let ``TopRequireQualifiedAccessParent property should be valid``() = let source = """ module M1 = diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 0dd25d55697..0e7ea9aab53 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -66,9 +66,7 @@ CompilerService\StructureTests.fs - - CompilerService\AssemblyContentProviderTests.fs - + CompilerService\ServiceUntypedParseTests.fs From 8982357f5de898121e8e9faac4ed0597d357bf4d Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 16:22:52 +0200 Subject: [PATCH 03/32] three --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 +++++++++---------- 3 files changed, 41 insertions(+), 49 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index fe609d69cef..51e6c41b6a2 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -61,9 +61,6 @@ CSharpProjectAnalysis.fs - - StructureTests.fs - ServiceUntypedParseTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 0e7ea9aab53..56f0ba990bf 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -63,9 +63,7 @@ CompilerService\CSharpProjectAnalysis.fs - - CompilerService\StructureTests.fs - + CompilerService\ServiceUntypedParseTests.fs diff --git a/tests/service/StructureTests.fs b/tests/FSharp.Compiler.UnitTests/StructureTests.fs similarity index 96% rename from tests/service/StructureTests.fs rename to tests/FSharp.Compiler.UnitTests/StructureTests.fs index 9d0541f579f..17a2508f43b 100644 --- a/tests/service/StructureTests.fs +++ b/tests/FSharp.Compiler.UnitTests/StructureTests.fs @@ -1,15 +1,12 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.StructureTests #endif open System.IO -open NUnit.Framework -open FSharp.Compiler.EditorServices +open Xunit open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -55,10 +52,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -71,7 +68,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -82,7 +79,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -93,7 +90,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -111,7 +108,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -133,7 +130,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -148,7 +145,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -194,7 +191,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -231,7 +228,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -260,7 +257,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -275,7 +272,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -293,7 +290,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -314,7 +311,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -330,7 +327,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -341,7 +338,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -352,7 +349,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -370,7 +367,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -386,7 +383,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -403,7 +400,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -412,7 +409,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -421,7 +418,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -431,7 +428,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -444,7 +441,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -453,7 +450,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -463,7 +460,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -472,7 +469,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -481,7 +478,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -498,7 +495,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -523,7 +520,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -545,7 +542,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -562,7 +559,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -577,7 +574,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -588,7 +585,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -598,7 +595,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -614,7 +611,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -638,7 +635,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -661,7 +658,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From bee920031ad0684a53ead7c0b027a8d15bb10f80 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 18:04:58 +0200 Subject: [PATCH 04/32] four --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../ExprTests.fs | 174 +++++++++--------- .../FSharp.Compiler.UnitTests.fsproj | 4 +- tests/FSharp.Test.Utilities/Assert.fs | 18 ++ tests/service/FsUnit.fs | 18 -- 5 files changed, 104 insertions(+), 113 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/ExprTests.fs (99%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 51e6c41b6a2..3129e7553af 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -55,9 +55,6 @@ InteractiveCheckerTests.fs - - ExprTests.fs - CSharpProjectAnalysis.fs diff --git a/tests/service/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs similarity index 99% rename from tests/service/ExprTests.fs rename to tests/FSharp.Compiler.UnitTests/ExprTests.fs index 8c8128eca18..c2763ffea08 100644 --- a/tests/service/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -1,15 +1,12 @@  #if INTERACTIVE #r "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0/FSharp.Compiler.Service.dll" -#r "../../artifacts/bin/FSharp.Compiler.UnitTests/Debug/net472/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module FSharp.Compiler.Service.Tests.ExprTests #endif -open NUnit.Framework -open FsUnit +open Xunit open System open System.IO open System.Text @@ -22,6 +19,7 @@ open FSharp.Compiler.IO open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns +open FSharp.Test open TestFramework type FSharpCore = @@ -724,15 +722,8 @@ let test{0}ToStringOperator (e1:{1}) = string e1 """ -let ignoreTestIfStackOverflowExpected () = -#if !NETFRAMEWORK && DEBUG - Assert.Ignore("Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.") -#else - () -#endif - /// This test is run in unison with its optimized counterpart below -[] +[] let ``Test Unoptimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -742,12 +733,12 @@ let ``Test Unoptimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 2 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 2 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let file2 = wholeProjectResults.AssemblyContents.ImplementationFiles[1] @@ -858,16 +849,16 @@ let ``Test Unoptimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> shouldPairwiseEqual (Utils.filterHack expected) + |> Assert.shouldBePairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> shouldPairwiseEqual (Utils.filterHack expected2) + |> Assert.shouldBePairwiseEqual (Utils.filterHack expected2) () -[] +[] let ``Test Optimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -877,12 +868,12 @@ let ``Test Optimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> shouldEqual 2 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldBe 2 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] let file2 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[1] @@ -994,12 +985,12 @@ let ``Test Optimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> shouldPairwiseEqual (Utils.filterHack expected) + |> Assert.shouldBePairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> shouldPairwiseEqual (Utils.filterHack expected2) + |> Assert.shouldBePairwiseEqual (Utils.filterHack expected2) () @@ -1043,8 +1034,8 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi printfn "%s Operator Tests error: <<<%s>>>" dnName e.Message errors.AppendLine e.Message |> ignore - errors.ToString() |> shouldEqual "" - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + errors.ToString() |> Assert.shouldBe "" + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 let resultUnoptimized = wholeProjectResults.AssemblyContents.ImplementationFiles[0].Declarations @@ -1109,14 +1100,14 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi // fail test on first line that fails, show difference in output window resultUnoptFiltered - |> shouldPairwiseEqual expectedUnoptFiltered + |> Assert.shouldBePairwiseEqual expectedUnoptFiltered // fail test on first line that fails, show difference in output window resultOptFiltered - |> shouldPairwiseEqual expectedOptFiltered + |> Assert.shouldBePairwiseEqual expectedOptFiltered end -[] +[] let ``Test Operator Declarations for Byte`` () = let excludedTests = [ "testByteUnaryNegOperator"; @@ -1226,7 +1217,7 @@ let ``Test Operator Declarations for Byte`` () = testOperators "Byte" "byte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for SByte`` () = let excludedTests = [ ] @@ -1335,7 +1326,7 @@ let ``Test Operator Declarations for SByte`` () = testOperators "SByte" "sbyte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int16`` () = let excludedTests = [ ] @@ -1444,7 +1435,7 @@ let ``Test Operator Declarations for Int16`` () = testOperators "Int16" "int16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt16`` () = let excludedTests = [ "testUInt16UnaryNegOperator"; @@ -1552,7 +1543,7 @@ let ``Test Operator Declarations for UInt16`` () = testOperators "UInt16" "uint16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int`` () = let excludedTests = [ ] @@ -1661,7 +1652,7 @@ let ``Test Operator Declarations for Int`` () = testOperators "Int" "int" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int32`` () = let excludedTests = [ ] @@ -1771,7 +1762,7 @@ let ``Test Operator Declarations for Int32`` () = testOperators "Int32" "int32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt32`` () = let excludedTests = [ "testUInt32UnaryNegOperator"; @@ -1879,7 +1870,7 @@ let ``Test Operator Declarations for UInt32`` () = testOperators "UInt32" "uint32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int64`` () = let excludedTests = [ ] @@ -1989,7 +1980,7 @@ let ``Test Operator Declarations for Int64`` () = testOperators "Int64" "int64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt64`` () = let excludedTests = [ "testUInt64UnaryNegOperator"; @@ -2097,7 +2088,7 @@ let ``Test Operator Declarations for UInt64`` () = testOperators "UInt64" "uint64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for IntPtr`` () = let excludedTests = [ ] @@ -2206,7 +2197,7 @@ let ``Test Operator Declarations for IntPtr`` () = testOperators "IntPtr" "nativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UIntPtr`` () = let excludedTests = [ "testUIntPtrUnaryNegOperator"; @@ -2314,7 +2305,7 @@ let ``Test Operator Declarations for UIntPtr`` () = testOperators "UIntPtr" "unativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single`` () = let excludedTests = [ "testSingleBitwiseAndOperator"; @@ -2419,7 +2410,7 @@ let ``Test Operator Declarations for Single`` () = testOperators "Single" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single with unit of measure`` () = let excludedTests = [ "testSingleUnitizedBitwiseAndOperator"; @@ -2524,7 +2515,7 @@ let ``Test Operator Declarations for Single with unit of measure`` () = testOperators "SingleUnitized" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Double`` () = let excludedTests = [ "testDoubleBitwiseAndOperator"; @@ -2630,7 +2621,7 @@ let ``Test Operator Declarations for Double`` () = testOperators "Double" "float" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal`` () = let excludedTests = [ // None of these are supported for decimals @@ -2729,7 +2720,7 @@ let ``Test Operator Declarations for Decimal`` () = testOperators "Decimal" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal unitized`` () = let excludedTests = [ // None of these are supported for unitized decimals @@ -2810,7 +2801,7 @@ let ``Test Operator Declarations for Decimal unitized`` () = ] testOperators "DecimalUnitized" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Char`` () = let excludedTests = [ "testCharSubtractionOperator"; @@ -2907,7 +2898,7 @@ let ``Test Operator Declarations for Char`` () = testOperators "Char" "char" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for String`` () = let excludedTests = [ "testStringSubtractionOperator"; @@ -3197,35 +3188,40 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) = let createOptions() = createOptionsAux [fileSource1] [] - -[] +#if !NETFRAMEWORK && DEBUG +[] +#else +[] +#endif let ``Test expressions of declarations stress big expressions`` () = - ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] // This should not stack overflow printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore -[] +#if !NETFRAMEWORK && DEBUG +[] +#else +[] +#endif let ``Test expressions of optimized declarations stress big expressions`` () = - ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] // This should not stack overflow @@ -3276,7 +3272,7 @@ let f8() = callXY (D()) (C()) let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses1`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3286,7 +3282,7 @@ let ``Test ProjectForWitnesses1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3317,10 +3313,10 @@ let ``Test ProjectForWitnesses1`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> shouldPairwiseEqual expected + |> Assert.shouldBePairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3342,10 +3338,10 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> shouldEqual "callX$W" - argTypes.Count |> shouldEqual 1 + nm |> Assert.shouldBe "callX$W" + argTypes.Count |> Assert.shouldBe 1 let argText = argTypes[0].Type.ToString() - argText |> shouldEqual "type ^T -> ^U -> ^V" + argText |> Assert.shouldBe "type ^T -> ^U -> ^V" end @@ -3361,14 +3357,14 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> shouldEqual "callXY$W" - argTypes.Count |> shouldEqual 2 + nm |> Assert.shouldBe "callXY$W" + argTypes.Count |> Assert.shouldBe 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argText1 |> shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" - argText2 |> shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText1 |> Assert.shouldBe "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText2 |> Assert.shouldBe "type ^T -> ^U -> Microsoft.FSharp.Core.unit" end @@ -3400,7 +3396,7 @@ type MyNumberWrapper = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses2`` () = let cleanup, options = ProjectForWitnesses2.createOptions() use _holder = cleanup @@ -3410,8 +3406,8 @@ let ``Test ProjectForWitnesses2`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses2 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3429,7 +3425,7 @@ let ``Test ProjectForWitnesses2`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> shouldPairwiseEqual expected + |> Assert.shouldBePairwiseEqual expected //--------------------------------------------------------------------------------------------------------- // This project is for witness arguments, testing for https://github.com/dotnet/fsharp/issues/10364 @@ -3455,7 +3451,7 @@ let s2 = sign p1 let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses3`` () = let cleanup, options = createOptionsAux [ ProjectForWitnesses3.fileSource1 ] ["--langversion:7.0"] use _holder = cleanup @@ -3465,8 +3461,8 @@ let ``Test ProjectForWitnesses3`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses3 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3484,9 +3480,9 @@ let ``Test ProjectForWitnesses3`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> shouldPairwiseEqual expected + |> Assert.shouldBePairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses3.createOptions() use _holder = cleanup @@ -3508,16 +3504,16 @@ let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> shouldEqual "Sum$W" - argTypes.Count |> shouldEqual 2 + nm |> Assert.shouldBe "Sum$W" + argTypes.Count |> Assert.shouldBe 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argName1 |> shouldEqual (Some "get_Zero") - argText1 |> shouldEqual "type Microsoft.FSharp.Core.unit -> ^T" - argName2 |> shouldEqual (Some "op_Addition") - argText2 |> shouldEqual "type ^T -> ^T -> ^T" + argName1 |> Assert.shouldBe (Some "get_Zero") + argText1 |> Assert.shouldBe "type Microsoft.FSharp.Core.unit -> ^T" + argName2 |> Assert.shouldBe (Some "op_Addition") + argText2 |> Assert.shouldBe "type ^T -> ^T -> ^T" end //--------------------------------------------------------------------------------------------------------- @@ -3549,7 +3545,7 @@ let isNullQuoted (ts : 't[]) = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses4.createOptions() use _holder = cleanup @@ -3559,9 +3555,9 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses4 error: <<<%s>>>" e.Message - Assert.AreEqual(wholeProjectResults.Diagnostics.Length, 0) + Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3575,4 +3571,4 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> shouldPairwiseEqual expected + |> Assert.shouldBePairwiseEqual expected diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 56f0ba990bf..4ea2e315d6c 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -57,9 +57,7 @@ CompilerService\InteractiveCheckerTests.fs - - CompilerService\ExprTests.fs - + CompilerService\CSharpProjectAnalysis.fs diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index dfed4bf123e..ba7566ac8c4 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -64,3 +64,21 @@ module Assert = sb.ToString () Some msg + + /// Same as 'shouldBe' but goes pairwise over the collections. Lengths must be equal. + let shouldBePairwiseEqual (x: seq<_>) (y: seq<_>) = + // using enumerators, because Seq.iter2 allows different lengths silently + let ex = x.GetEnumerator() + let ey = y.GetEnumerator() + let mutable countx = 0 + let mutable county = 0 + while ex.MoveNext() do + countx <- countx + 1 + if ey.MoveNext() then + county <- county + 1 + ey.Current |> shouldBe ex.Current + + while ex.MoveNext() do countx <- countx + 1 + while ey.MoveNext() do county <- county + 1 + if countx <> county then + failwithf $"Collections are of unequal lengths, expected length {countx}, actual length is {county}." diff --git a/tests/service/FsUnit.fs b/tests/service/FsUnit.fs index fc4964c574f..b85c3dfa3ab 100644 --- a/tests/service/FsUnit.fs +++ b/tests/service/FsUnit.fs @@ -18,24 +18,6 @@ let equal x = EqualConstraint(x) /// like "should equal", but validates same-type let shouldEqual (x: 'a) (y: 'a) = Assert.AreEqual(x, y, sprintf "Expected: %A\nActual: %A" x y) -/// Same as 'shouldEqual' but goes pairwise over the collections. Lengths must be equal. -let shouldPairwiseEqual (x: seq<_>) (y: seq<_>) = - // using enumerators, because Seq.iter2 allows different lengths silently - let ex = x.GetEnumerator() - let ey = y.GetEnumerator() - let mutable countx = 0 - let mutable county = 0 - while ex.MoveNext() do - countx <- countx + 1 - if ey.MoveNext() then - county <- county + 1 - ey.Current |> shouldEqual ex.Current - - while ex.MoveNext() do countx <- countx + 1 - while ey.MoveNext() do county <- county + 1 - if countx <> county then - Assert.Fail("Collections are of unequal lengths, expected length {0}, actual length is {1}.", countx, county) - let notEqual x = NotConstraint(EqualConstraint(x)) let contain x = ContainsConstraint(x) From 5b834492ae4ec8afeedaf1053cacf5b3967def15 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 19:38:01 +0200 Subject: [PATCH 05/32] five --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../ServiceUntypedParseTests.fs | 600 +++++++++--------- 3 files changed, 302 insertions(+), 305 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/ServiceUntypedParseTests.fs (72%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 3129e7553af..dd3ffae3dd0 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -58,9 +58,6 @@ CSharpProjectAnalysis.fs - - ServiceUntypedParseTests.fs - PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 4ea2e315d6c..28f567ce2bb 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -63,9 +63,7 @@ - - CompilerService\ServiceUntypedParseTests.fs - + diff --git a/tests/service/ServiceUntypedParseTests.fs b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs similarity index 72% rename from tests/service/ServiceUntypedParseTests.fs rename to tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs index ea2591b8bf9..3624ff2ce8f 100644 --- a/tests/service/ServiceUntypedParseTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs @@ -1,21 +1,19 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.ServiceUntypedParseTests #endif open System.IO -open FsUnit open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Text.Position -open NUnit.Framework +open Xunit +open FSharp.Test let [] private Marker = "(* marker *)" @@ -49,22 +47,23 @@ let private assertCompletionContext (checker: CompletionContext option -> bool) failwithf "Completion context '%A' was not expected" actual module AttributeCompletion = - [] + [] let ``at [<|, applied to nothing``() = """ [<(* marker *) """ |> assertCompletionContext (fun x -> x = Some CompletionContext.AttributeApplication) - [] - [] - [] - [] - [] - [] - [] - [][<(* marker *)", true)>] - [][< (* marker *)", true)>] + [] + [] + [] + [] + [] + [] + [] + [] + [][<(* marker *)", true)>] + [][< (* marker *)", true)>] let ``incomplete``(lineStr: string, expectAttributeApplicationContext: bool) = let code = $""" {lineStr} @@ -73,17 +72,18 @@ type T = """ code |> assertCompletionContext (fun x -> x = (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)) - []", true)>] - []", true)>] - []", true)>] - []", true)>] - []", true)>] - [][<(* marker *)>]", true)>] - [][< (* marker *)>]", true)>] - []", true)>] - []", true)>] - [][]", true)>] - []", false)>] + [] + []", true)>] + []", true)>] + []", true)>] + []", true)>] + []", true)>] + [][<(* marker *)>]", true)>] + [][< (* marker *)>]", true)>] + []", true)>] + []", true)>] + [][]", true)>] + []", false)>] let ``complete``(lineStr: string, expectAttributeApplicationContext: bool) = let code = $""" {lineStr} @@ -93,10 +93,11 @@ type T = code |> assertCompletionContext (fun x -> x = (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)) module AttributeConstructorCompletion = - [] - [] - [][] - [] + [] + [] + [] + [][] + [] let ``incomplete``(lineStr: string) = let code = $""" {lineStr} @@ -105,11 +106,12 @@ type T = """ code |> assertCompletionContext (fun x -> match x with Some (CompletionContext.ParameterList _) -> true | _ -> false) - []")>] - [][]")>] - []")>] - []")>] - [][]")>] + [] + []")>] + [][]")>] + []")>] + []")>] + [][]")>] let ``complete``(lineStr: string) = let code = $""" {lineStr} @@ -118,7 +120,7 @@ type T = """ code |> assertCompletionContext (fun x -> match x with Some (CompletionContext.ParameterList _) -> true | _ -> false) -[] +[] let ``Attribute lists`` () = let source = """ [] @@ -152,7 +154,7 @@ let foo8 = () | SynModuleDecl.Let (_, [SynBinding (attributes = attributeLists)], _) -> attributeLists |> List.map (fun list -> list.Attributes.Length, getRangeCoords list.Range) | _ -> failwith "Could not get binding") - |> shouldEqual + |> Assert.shouldBe [ [ (1, ((2, 0), (2, 5))) ] [ (1, ((5, 0), (5, 5))); (2, ((6, 0), (6, 7))) ] [ (1, ((9, 0), (9, 5))); (2, ((9, 6), (9, 13))) ] @@ -189,7 +191,7 @@ let rec getParenTypes (synType: SynType): SynType list = | _ -> () ] -[] +[] let ``SynType.Paren ranges`` () = let source = """ ((): int * (int * int)) @@ -203,7 +205,7 @@ let ``SynType.Paren ranges`` () = getParenTypes synType |> List.map (fun synType -> getRangeCoords synType.Range) | _ -> failwith "Could not get binding") - |> shouldEqual + |> Assert.shouldBe [ [ (2, 11), (2, 22) ] [ (3, 5), (3, 17) ] [ (4, 5), (4, 12); (4, 6), (4, 11) ] ] @@ -219,53 +221,53 @@ module TypeMemberRanges = | _ -> failwith "Could not get member" - [] + [] let ``Member range 01 - Simple``() = let source = """ type T = member x.Foo() = () """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 23) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 23) ] - [] + [] let ``Member range 02 - Static``() = let source = """ type T = static member Foo() = () """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 28) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 28) ] - [] + [] let ``Member range 03 - Attribute``() = let source = """ type T = [] static member Foo() = () """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (4, 28) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (4, 28) ] - [] + [] let ``Member range 04 - Property``() = let source = """ type T = member x.P = () """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 19) ] - [] + [] let ``Member range 05 - Setter only property``() = let source = """ type T = member x.P with set (value) = v <- value """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 44) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 44) ] - [] + [] let ``Member range 06 - Read-write property``() = let source = """ type T = @@ -273,56 +275,56 @@ type T = with get () = x and set (value) = x <- value """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (5, 36) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (5, 36) ] - [] + [] let ``Member range 07 - Auto property``() = let source = """ type T = member val Property1 = "" """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 29) ] - [] + [] let ``Member range 08 - Auto property with setter``() = let source = """ type T = member val Property1 = "" with get, set """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 29) ] - [] + [] let ``Member range 09 - Abstract slot``() = let source = """ type T = abstract P: int abstract M: unit -> unit """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) - (4, 4), (4, 28) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 19) + (4, 4), (4, 28) ] - [] + [] let ``Member range 10 - Val field``() = let source = """ type T = val x: int """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 14) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 14) ] - [] + [] let ``Member range 11 - Ctor``() = let source = """ type T = new (x:int) = () """ - getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 20) ] + getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 20) ] -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - simple``() = let source = """ let x = false @@ -335,11 +337,11 @@ let y = !x res |> tups |> fst - |> shouldEqual (3, 8) + |> Assert.shouldBe (3, 8) | None -> - Assert.Fail("No deref operator found in source.") + failwith "No deref operator found in source." -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - parens``() = let source = """ let x = false @@ -352,12 +354,12 @@ let y = !(x) res |> tups |> fst - |> shouldEqual (3, 8) + |> Assert.shouldBe (3, 8) | None -> - Assert.Fail("No deref operator found in source.") + failwith "No deref operator found in source." -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - binary expr``() = let source = """ let x = false @@ -370,11 +372,11 @@ let y = !(x = false) res |> tups |> fst - |> shouldEqual (3, 8) + |> Assert.shouldBe (3, 8) | None -> - Assert.Fail("No deref operator found in source.") + failwith "No deref operator found in source." -[] +[] let ``TryRangeOfRecordExpressionContainingPos - contained``() = let source = """ let x = { Name = "Hello" } @@ -385,11 +387,11 @@ let x = { Name = "Hello" } | Some res -> res |> tups - |> shouldEqual ((2, 8), (2, 26)) + |> Assert.shouldBe ((2, 8), (2, 26)) | None -> - Assert.Fail("No range of record found in source.") + failwith "No range of record found in source." -[] +[] let ``TryRangeOfRecordExpressionContainingPos - not contained``() = let source = """ let x = { Name = "Hello" } @@ -400,7 +402,7 @@ let x = { Name = "Hello" } module FunctionApplicationArguments = - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Single arg``() = let source = """ let f x = () @@ -412,11 +414,11 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 2)] + |> Assert.shouldBe [(3, 2)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg``() = let source = """ let f x y z = () @@ -428,11 +430,11 @@ f 1 2 3 | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 2); (3, 4); (3, 6)] + |> Assert.shouldBe [(3, 2); (3, 4); (3, 6)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg parentheses``() = let source = """ let f x y z = () @@ -444,11 +446,11 @@ f (1) (2) (3) | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 2); (3, 6); (3, 10)] + |> Assert.shouldBe [(3, 2); (3, 6); (3, 10)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg nested parentheses``() = let source = """ let f x y z = () @@ -460,11 +462,11 @@ f ((1)) (((2))) ((((3)))) | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 3); (3, 10); (3, 19)] + |> Assert.shouldBe [(3, 3); (3, 10); (3, 19)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - unit``() = let source = """ let f () = () @@ -472,9 +474,9 @@ f () """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.GetAllArgumentsForFunctionApplicationAtPosition (mkPos 3 0) - Assert.IsTrue(res.IsNone, "Found argument for unit-accepting function, which shouldn't be the case.") + Assert.True(res.IsNone, "Found argument for unit-accepting function, which shouldn't be the case.") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - curried function``() = let source = """ let f x y = x + y @@ -486,11 +488,11 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 2)] + |> Assert.shouldBe [(3, 2)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple value``() = let source = """ let f (t: int * int) = () @@ -503,11 +505,11 @@ f t | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(4, 2)] + |> Assert.shouldBe [(4, 2)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple literal``() = let source = """ let f (t: int * int) = () @@ -519,11 +521,11 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 3); (3, 6)] + |> Assert.shouldBe [(3, 3); (3, 6)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple value with definition that has explicit names``() = let source = """ let f ((x, y): int * int) = () @@ -536,11 +538,11 @@ f t | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(4, 2)] + |> Assert.shouldBe [(4, 2)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple literal inside parens``() = let source = """ let f (x, y) = () @@ -552,11 +554,11 @@ f ((1, 2)) | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 4); (3, 7)] + |> Assert.shouldBe [(3, 4); (3, 7)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuples with elements as arguments``() = let source = """ let f (a, b) = () @@ -568,11 +570,11 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 3); (3, 6)] + |> Assert.shouldBe [(3, 3); (3, 6)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - top-level arguments with nested function call``() = let source = """ let f x y = x + y @@ -584,11 +586,11 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 2); (3, 10)] + |> Assert.shouldBe [(3, 2); (3, 10)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function argument positions``() = let source = """ let f x y = x + y @@ -600,11 +602,11 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(3, 5); (3, 7)] + |> Assert.shouldBe [(3, 5); (3, 7)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function application in infix expression``() = let source = """ let addStr x y = string x + y @@ -615,11 +617,11 @@ let addStr x y = string x + y | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(2, 24)] + |> Assert.shouldBe [(2, 24)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function application outside of infix expression``() = let source = """ let addStr x y = x + string y @@ -630,11 +632,11 @@ let addStr x y = x + string y | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(2, 28)] + |> Assert.shouldBe [(2, 28)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function applications both inside and outside of infix expression``() = let source = """ let addStr x y = string x + string y @@ -645,9 +647,9 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(2, 24)] + |> Assert.shouldBe [(2, 24)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" let res = parseFileResults.GetAllArgumentsForFunctionApplicationAtPosition (mkPos 2 28) @@ -655,11 +657,11 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> shouldEqual [(2, 35)] + |> Assert.shouldBe [(2, 35)] | None -> - Assert.Fail("No arguments found in source code") + failwith "No arguments found in source code" - [] + [] let ``IsPosContainedInApplication - no``() = let source = """ sqrt x @@ -668,7 +670,7 @@ sqrt x let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 3 2), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - yes, single arg``() = let source = """ sqrt x @@ -676,7 +678,7 @@ sqrt x let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should be in application") - [] + [] let ``IsPosContainedInApplication - yes, multi arg``() = let source = """ let add2 x y = x + y @@ -685,7 +687,7 @@ add2 x y let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 3 6), "Pos should be in application") - [] + [] let ``IsPosContainedInApplication - inside computation expression - no``() = let source = """ async { @@ -695,7 +697,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside CE return - no``() = let source = """ async { @@ -705,7 +707,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside CE - yes``() = let source = """ let myAdd x y = x + y @@ -716,7 +718,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 3 18), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside type application``() = let source = """ let f<'x> x = () @@ -725,7 +727,7 @@ f let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 3 6), "A type application is an application, expected True.") - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - no application``() = let source = """ let add2 x y = x + y @@ -734,9 +736,9 @@ add2 x y """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 4 2) - Assert.IsTrue(res.IsNone, "Not in a function application but got one") + Assert.True(res.IsNone, "Not in a function application but got one") - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - single arg application``() = let source = """ sqrt 12.0 @@ -744,13 +746,13 @@ sqrt 12.0 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 9) match res with - | None -> Assert.Fail("Expected 'sqrt' but got nothing") + | None -> failwith "Expected 'sqrt' but got nothing" | Some range -> range |> tups - |> shouldEqual ((2, 0), (2, 4)) + |> Assert.shouldBe ((2, 0), (2, 4)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application``() = let source = """ let f x y z = () @@ -759,13 +761,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 5) match res with - | None -> Assert.Fail("Expected 'f' but got nothing") + | None -> failwith "Expected 'f' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 0), (3, 1)) + |> Assert.shouldBe ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application but at function itself``() = let source = """ let f x y z = () @@ -774,13 +776,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 1) match res with - | None -> Assert.Fail("Expected 'f' but got nothing") + | None -> failwith "Expected 'f' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 0), (3, 1)) + |> Assert.shouldBe ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in pipeline``() = let source = """ [1..10] |> List.map id @@ -788,13 +790,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 20) match res with - | None -> Assert.Fail("Expected 'List.map' but got nothing") + | None -> failwith "Expected 'List.map' but got nothing" | Some range -> range |> tups - |> shouldEqual ((2, 11), (2, 19)) + |> Assert.shouldBe ((2, 11), (2, 19)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline``() = let source = """ [1..10] @@ -804,13 +806,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 14) match res with - | None -> Assert.Fail("Expected 'List.filter' but got nothing") + | None -> failwith "Expected 'List.filter' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 3), (3, 14)) + |> Assert.shouldBe ((3, 3), (3, 14)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline, no qualification``() = let source = """ [1..10] @@ -819,13 +821,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 5) match res with - | None -> Assert.Fail("Expected 'id' but got nothing") + | None -> failwith "Expected 'id' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 3), (3, 5)) + |> Assert.shouldBe ((3, 3), (3, 5)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - incomplete infix app``() = let source = """ let add2 x y = x + y @@ -835,13 +837,13 @@ add2 1 2 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 18) match res with - | None -> Assert.Fail("Expected '*' but got nothing") + | None -> failwith "Expected '*' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 17), (3, 18)) + |> Assert.shouldBe ((3, 17), (3, 18)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE``() = let source = """ let myAdd x y = x + y @@ -852,13 +854,13 @@ async { let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 4 18) match res with - | None -> Assert.Fail("Expected 'myAdd' but got nothing") + | None -> failwith "Expected 'myAdd' but got nothing" | Some range -> range |> tups - |> shouldEqual ((4, 11), (4, 16)) + |> Assert.shouldBe ((4, 11), (4, 16)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - binding``() = let source = """ let add n1 n2 = n1 + n2 @@ -872,13 +874,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 6 21) match res with - | None -> Assert.Fail("Expected 'add' but got nothing") + | None -> failwith "Expected 'add' but got nothing" | Some range -> range |> tups - |> shouldEqual ((6, 18), (6, 21)) + |> Assert.shouldBe ((6, 18), (6, 21)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - if expression``() = let source = """ let add n1 n2 = n1 + n2 @@ -896,13 +898,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 7 15) match res with - | None -> Assert.Fail("Expected 'add' but got nothing") + | None -> failwith "Expected 'add' but got nothing" | Some range -> range |> tups - |> shouldEqual ((7, 12), (7, 15)) + |> Assert.shouldBe ((7, 12), (7, 15)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expression``() = let source = """ let add n1 n2 = n1 + n2 @@ -920,13 +922,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 7 15) match res with - | None -> Assert.Fail("Expected 'add' but got nothing") + | None -> failwith "Expected 'add' but got nothing" | Some range -> range |> tups - |> shouldEqual ((7, 12), (7, 15)) + |> Assert.shouldBe ((7, 12), (7, 15)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expr``() = let source = """ let add n1 n2 = n1 + n2 @@ -944,13 +946,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 9 21) match res with - | None -> Assert.Fail("Expected 'add' but got nothing") + | None -> failwith "Expected 'add' but got nothing" | Some range -> range |> tups - |> shouldEqual ((9, 18), (9, 21)) + |> Assert.shouldBe ((9, 18), (9, 21)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match case``() = let source = """ let add n1 n2 = n1 + n2 @@ -968,13 +970,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 11 22) match res with - | None -> Assert.Fail("Expected 'add' but got nothing") + | None -> failwith "Expected 'add' but got nothing" | Some range -> range |> tups - |> shouldEqual ((11, 19), (11, 22)) + |> Assert.shouldBe ((11, 19), (11, 22)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call``() = let source = """ type C() = static member Yeet(x, y, z) = () @@ -983,13 +985,13 @@ C.Yeet(1, 2, sqrt) let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 17) match res with - | None -> Assert.Fail("Expected 'sqrt' but got nothing") + | None -> failwith "Expected 'sqrt' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 13), (3, 17)) + |> Assert.shouldBe ((3, 13), (3, 17)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call - parenthesized lambda``() = let source = """ type C() = static member Yeet(x, y, z) = () @@ -998,13 +1000,13 @@ C.Yeet(1, 2, (fun x -> sqrt)) let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 27) match res with - | None -> Assert.Fail("Expected 'sqrt' but got nothing") + | None -> failwith "Expected 'sqrt' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 23), (3, 27)) + |> Assert.shouldBe ((3, 23), (3, 27)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - generic-typed app``() = let source = """ let f<'x> x = () @@ -1013,13 +1015,13 @@ f let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 6) match res with - | None -> Assert.Fail("Expected 'f' but got nothing") + | None -> failwith "Expected 'f' but got nothing" | Some range -> range |> tups - |> shouldEqual ((3, 0), (3, 1)) + |> Assert.shouldBe ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a list that is used as an argument - Sequential and ArrayOrListComputed``() = let source = """ let test () = div [] [ @@ -1033,13 +1035,13 @@ let test () = div [] [ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 5 15) match res with - | None -> Assert.Fail("Expected 'ofInt' but got nothing") + | None -> failwith "Expected 'ofInt' but got nothing" | Some range -> range |> tups - |> shouldEqual ((5, 8), (5, 13)) + |> Assert.shouldBe ((5, 8), (5, 13)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after semicolon - Sequential and ComputationExpr``() = let source = """ let div props children = () @@ -1055,7 +1057,7 @@ let test () = div [] [ // Once this particular case is implemented, the expected result should be the range of `div` Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after newline and semicolon - Sequential and ComputationExpr``() = let source = """ let div props children = () @@ -1072,7 +1074,7 @@ let test () = div [] [ // Once this particular case is implemented, the expected result should be the range of `div` Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a sequence that is used as an argument - Sequential and ComputationExpr``() = let source = """ seq { 5; int "6" } |> Seq.sum @@ -1080,15 +1082,15 @@ seq { 5; int "6" } |> Seq.sum let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 14) match res with - | None -> Assert.Fail("Expected 'int' but got nothing") + | None -> failwith "Expected 'int' but got nothing" | Some range -> range |> tups - |> shouldEqual ((2, 9), (2, 12)) + |> Assert.shouldBe ((2, 9), (2, 12)) module PipelinesAndArgs = - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - No pipeline, no infix app``() = let source = """ let f x = () @@ -1098,7 +1100,7 @@ f 12 let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 3 0) Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - No pipeline, but infix app``() = let source = """ let square x = x * @@ -1107,7 +1109,7 @@ let square x = x * let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 2 18) Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Single pipeline``() = let source = """ [1..10] |> List.map @@ -1117,11 +1119,11 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> shouldEqual ("op_PipeRight", 1) + |> Assert.shouldBe ("op_PipeRight", 1) | None -> - Assert.Fail("No pipeline found") + failwith "No pipeline found" - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Double pipeline``() = let source = """ ([1..10], 1) ||> List.fold @@ -1131,11 +1133,11 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> shouldEqual ("op_PipeRight2", 2) + |> Assert.shouldBe ("op_PipeRight2", 2) | None -> - Assert.Fail("No pipeline found") + failwith "No pipeline found" - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Triple pipeline``() = let source = """ ([1..10], [1..10], 3) |||> List.fold2 @@ -1145,11 +1147,11 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> shouldEqual ("op_PipeRight3", 3) + |> Assert.shouldBe ("op_PipeRight3", 3) | None -> - Assert.Fail("No pipeline found") + failwith "No pipeline found" - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - none when inside lambda``() = let source = """ let add n1 n2 = n1 + n2 @@ -1162,9 +1164,9 @@ let mapped = """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 6 22) - Assert.IsTrue(res.IsNone, "Inside a lambda but counted the pipeline outside of that lambda.") + Assert.True(res.IsNone, "Inside a lambda but counted the pipeline outside of that lambda.") -[] +[] let ``TryRangeOfExprInYieldOrReturn - not contained``() = let source = """ let f x = @@ -1174,7 +1176,7 @@ let f x = let res = parseFileResults.TryRangeOfExprInYieldOrReturn (mkPos 3 4) Assert.True(res.IsNone, "Expected not to find a range.") -[] +[] let ``TryRangeOfExprInYieldOrReturn - contained``() = let source = """ let f x = @@ -1186,11 +1188,11 @@ let f x = | Some range -> range |> tups - |> shouldEqual ((3, 11), (3, 12)) + |> Assert.shouldBe ((3, 11), (3, 12)) | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - not correct operator``() = let source = """ let x = y |> y + 1 @@ -1199,7 +1201,7 @@ let x = y |> y + 1 let res = parseFileResults.TryRangeOfParenEnclosingOpEqualsGreaterUsage (mkPos 2 8) Assert.True(res.IsNone, "Expected not to find any ranges.") -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - error arg pos``() = let source = """ let x = y => y + 1 @@ -1210,11 +1212,11 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> Assert.shouldBe [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - error expr pos``() = let source = """ let x = y => y + 1 @@ -1225,11 +1227,11 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> Assert.shouldBe [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = let source = """ [1..10] |> List.map (x => x + 1) @@ -1240,11 +1242,11 @@ let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> shouldEqual [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] + |> Assert.shouldBe [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - simple``() = let source = """ let x = nameof x @@ -1255,11 +1257,11 @@ let x = nameof x | Some range -> range |> tups - |> shouldEqual ((2, 4), (2, 5)) + |> Assert.shouldBe ((2, 4), (2, 5)) | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - inside match``() = let source = """ let mySum xs acc = @@ -1274,11 +1276,11 @@ let mySum xs acc = | Some range -> range |> tups - |> shouldEqual ((2, 4), (2, 9)) + |> Assert.shouldBe ((2, 4), (2, 9)) | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - nested binding``() = let source = """ let f x = @@ -1293,11 +1295,11 @@ let f x = | Some range -> range |> tups - |> shouldEqual ((4, 8), (4, 9)) + |> Assert.shouldBe ((4, 8), (4, 9)) | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - nested and after other statements``() = let source = """ let f x = @@ -1314,233 +1316,233 @@ let f x = | Some range -> range |> tups - |> shouldEqual ((6, 8), (6, 9)) + |> Assert.shouldBe ((6, 8), (6, 9)) | None -> - Assert.Fail("Expected to get a range back, but got none.") + failwith "Expected to get a range back, but got none." module TypeAnnotations = - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - no annotation``() = let source = """ let f x = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 6), "Expected no annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 6), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - single arg annotation``() = let source = """ let f (x: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - first arg annotated``() = let source = """ let f (x: int) y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - second arg annotated``() = let source = """ let f x (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 9), "Expected annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 9), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - all args annotated``() = let source = """ let f (x: int) (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 16), "Expected annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 16), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - lambda function - all args annotated``() = let source = """ let f = fun (x: int) (y: string) -> () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected a annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 22), "Expected a annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected a annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 22), "Expected a annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - arg no annotations``() = let source = """ type C(x) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - first arg unannotated``() = let source = """ type C(x, y: string) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 10), "Expected annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 10), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - second arg unannotated``() = let source = """ type C(x: int, y) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - both args annotated``() = let source = """ type C(x: int, y: int) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - args no unannotions``() = let source = """ type C() = member _.M(x, y) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected no annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - first arg annotated``() = let source = """ type C() = member _.M(x: int, y) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected no annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - second arg annotated``() = let source = """ type C() = member _.M(x, y: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - both args annotated``() = let source = """ type C() = member _.M(x: int, y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - args no unannotions``() = let source = """ type C() = member _.M x y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 17), "Expected no annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 17), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - first arg annotated``() = let source = """ type C() = member _.M (x: int) y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 24), "Expected no annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 24), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - second arg annotated``() = let source = """ type C() = member _.M x (y: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected no annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected no annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - both args annotated``() = let source = """ type C() = member _.M (x: int) (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 25), "Expected annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 25), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - only return type annotated``() = let source = """ type C() = member _.M(x): string = "hello" + x """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - no annotations``() = let source = """ let (x, y) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for value 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected no annotation for value 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for value 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected no annotation for value 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - first value annotated``() = let source = """ let (x: int, y) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected no annotation for argument 'y'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - second value annotated``() = let source = """ let (x, y: string) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for argument 'x'") - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected annotation for argument 'y'") + Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - binding - second value annotated``() = let source = """ let x: int = 12 """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") + Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") module LambdaRecognition = - [] + [] let ``IsBindingALambdaAtPosition - recognize a lambda``() = let source = """ let f = fun x y -> x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - recognize a nested lambda``() = let source = """ let f = @@ -1549,9 +1551,9 @@ let f = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - recognize a "partial" lambda``() = let source = """ let f x = @@ -1559,12 +1561,12 @@ let f x = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - not a lambda``() = let source = """ let f x y = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.IsFalse(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "'f' is not a lambda expression'") + Assert.False(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "'f' is not a lambda expression'") From 1a9f00c4280a5a341fc6a82edd7e3a95168671cf Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 31 Jul 2023 19:42:21 +0200 Subject: [PATCH 06/32] minor --- tests/FSharp.Compiler.UnitTests/ExprTests.fs | 2 +- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 2 +- tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs index c2763ffea08..c0bfaf4d0da 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -7,6 +7,7 @@ module FSharp.Compiler.Service.Tests.ExprTests #endif open Xunit +open FSharp.Test open System open System.IO open System.Text @@ -19,7 +20,6 @@ open FSharp.Compiler.IO open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns -open FSharp.Test open TestFramework type FSharpCore = diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index 5a7c5e56d6a..8fcabad26b9 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -6,13 +6,13 @@ module FSharp.Compiler.Service.Tests.PerfTests #endif open Xunit +open FSharp.Test open System.IO open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.IO open FSharp.Compiler.Text open FSharp.Compiler.Service.Tests.Common open TestFramework -open FSharp.Test // Create an interactive checker instance let internal checker = FSharpChecker.Create() diff --git a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs index 3624ff2ce8f..25dc82b4b2e 100644 --- a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs @@ -6,6 +6,7 @@ module Tests.Service.ServiceUntypedParseTests #endif open System.IO +open FSharp.Test open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax @@ -13,7 +14,6 @@ open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Text.Position open Xunit -open FSharp.Test let [] private Marker = "(* marker *)" From 9b6c76b9cd66360c2450ba4f69e910326d32b3be Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 1 Aug 2023 17:56:51 +0200 Subject: [PATCH 07/32] up --- tests/FSharp.Compiler.UnitTests/ExprTests.fs | 20 ++++++++++---------- tests/FSharp.Test.Utilities/Assert.fs | 8 +++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs index c0bfaf4d0da..2eaa7fdfcfc 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -849,12 +849,12 @@ let ``Test Unoptimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldBePairwiseEqual (Utils.filterHack expected) + |> Assert.shouldPairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldBePairwiseEqual (Utils.filterHack expected2) + |> Assert.shouldPairwiseEqual (Utils.filterHack expected2) () @@ -985,12 +985,12 @@ let ``Test Optimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldBePairwiseEqual (Utils.filterHack expected) + |> Assert.shouldPairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldBePairwiseEqual (Utils.filterHack expected2) + |> Assert.shouldPairwiseEqual (Utils.filterHack expected2) () @@ -1100,11 +1100,11 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi // fail test on first line that fails, show difference in output window resultUnoptFiltered - |> Assert.shouldBePairwiseEqual expectedUnoptFiltered + |> Assert.shouldPairwiseEqual expectedUnoptFiltered // fail test on first line that fails, show difference in output window resultOptFiltered - |> Assert.shouldBePairwiseEqual expectedOptFiltered + |> Assert.shouldPairwiseEqual expectedOptFiltered end [] @@ -3313,7 +3313,7 @@ let ``Test ProjectForWitnesses1`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldBePairwiseEqual expected + |> Assert.shouldPairwiseEqual expected [] @@ -3425,7 +3425,7 @@ let ``Test ProjectForWitnesses2`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldBePairwiseEqual expected + |> Assert.shouldPairwiseEqual expected //--------------------------------------------------------------------------------------------------------- // This project is for witness arguments, testing for https://github.com/dotnet/fsharp/issues/10364 @@ -3480,7 +3480,7 @@ let ``Test ProjectForWitnesses3`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldBePairwiseEqual expected + |> Assert.shouldPairwiseEqual expected [] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = @@ -3571,4 +3571,4 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldBePairwiseEqual expected + |> Assert.shouldPairwiseEqual expected diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index ba7566ac8c4..2e5a29e9b20 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -3,7 +3,6 @@ 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) = @@ -15,6 +14,9 @@ module Assert = let inline shouldBe (expected : ^T) (actual : ^U) = actual.Should().Be(expected, "") |> ignore + let inline shouldEqual (expected : ^T) (actual : ^T) = + actual.Should().Be(expected, "") |> ignore + let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) = actual.Should().BeEmpty("") |> ignore @@ -66,7 +68,7 @@ module Assert = Some msg /// Same as 'shouldBe' but goes pairwise over the collections. Lengths must be equal. - let shouldBePairwiseEqual (x: seq<_>) (y: seq<_>) = + let shouldPairwiseEqual (x: seq<_>) (y: seq<_>) = // using enumerators, because Seq.iter2 allows different lengths silently let ex = x.GetEnumerator() let ey = y.GetEnumerator() @@ -76,7 +78,7 @@ module Assert = countx <- countx + 1 if ey.MoveNext() then county <- county + 1 - ey.Current |> shouldBe ex.Current + ey.Current |> shouldEqual ex.Current while ex.MoveNext() do countx <- countx + 1 while ey.MoveNext() do county <- county + 1 From c70d9bb420b002e2e7c3f32727342828a236335c Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 1 Aug 2023 18:00:27 +0200 Subject: [PATCH 08/32] up --- tests/FSharp.Compiler.UnitTests/ExprTests.fs | 70 +++++----- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 20 +-- .../ServiceUntypedParseTests.fs | 122 +++++++++--------- 3 files changed, 106 insertions(+), 106 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs index 2eaa7fdfcfc..a50250b0f2d 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -733,12 +733,12 @@ let ``Test Unoptimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 2 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 2 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let file2 = wholeProjectResults.AssemblyContents.ImplementationFiles[1] @@ -868,12 +868,12 @@ let ``Test Optimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldBe FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldBe 2 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldEqual 2 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] let file2 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[1] @@ -1034,8 +1034,8 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi printfn "%s Operator Tests error: <<<%s>>>" dnName e.Message errors.AppendLine e.Message |> ignore - errors.ToString() |> Assert.shouldBe "" - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 + errors.ToString() |> Assert.shouldEqual "" + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 let resultUnoptimized = wholeProjectResults.AssemblyContents.ImplementationFiles[0].Declarations @@ -3199,9 +3199,9 @@ let ``Test expressions of declarations stress big expressions`` () = let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] // This should not stack overflow @@ -3219,9 +3219,9 @@ let ``Test expressions of optimized declarations stress big expressions`` () = let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] // This should not stack overflow @@ -3282,7 +3282,7 @@ let ``Test ProjectForWitnesses1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3338,10 +3338,10 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldBe "callX$W" - argTypes.Count |> Assert.shouldBe 1 + nm |> Assert.shouldEqual "callX$W" + argTypes.Count |> Assert.shouldEqual 1 let argText = argTypes[0].Type.ToString() - argText |> Assert.shouldBe "type ^T -> ^U -> ^V" + argText |> Assert.shouldEqual "type ^T -> ^U -> ^V" end @@ -3357,14 +3357,14 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldBe "callXY$W" - argTypes.Count |> Assert.shouldBe 2 + nm |> Assert.shouldEqual "callXY$W" + argTypes.Count |> Assert.shouldEqual 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argText1 |> Assert.shouldBe "type ^T -> ^U -> Microsoft.FSharp.Core.unit" - argText2 |> Assert.shouldBe "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText1 |> Assert.shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText2 |> Assert.shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" end @@ -3406,8 +3406,8 @@ let ``Test ProjectForWitnesses2`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses2 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3461,8 +3461,8 @@ let ``Test ProjectForWitnesses3`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses3 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldBe 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3504,16 +3504,16 @@ let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldBe "Sum$W" - argTypes.Count |> Assert.shouldBe 2 + nm |> Assert.shouldEqual "Sum$W" + argTypes.Count |> Assert.shouldEqual 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argName1 |> Assert.shouldBe (Some "get_Zero") - argText1 |> Assert.shouldBe "type Microsoft.FSharp.Core.unit -> ^T" - argName2 |> Assert.shouldBe (Some "op_Addition") - argText2 |> Assert.shouldBe "type ^T -> ^T -> ^T" + argName1 |> Assert.shouldEqual (Some "get_Zero") + argText1 |> Assert.shouldEqual "type Microsoft.FSharp.Core.unit -> ^T" + argName2 |> Assert.shouldEqual (Some "op_Addition") + argText2 |> Assert.shouldEqual "type ^T -> ^T -> ^T" end //--------------------------------------------------------------------------------------------------------- @@ -3557,7 +3557,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldBe 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index 8fcabad26b9..f528276c7d3 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -47,12 +47,12 @@ let ``Test request for parse and check doesn't check whole project`` () = printfn "ParseFile()..." let parseResults1 = checker.ParseFile(Project1.fileNames[5], Project1.fileSources2[5], Project1.parsingOptions) |> Async.RunImmediate let pC, tC = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount - (pC - pB) |> Assert.shouldBe 1 - (tC - tB) |> Assert.shouldBe 0 + (pC - pB) |> Assert.shouldEqual 1 + (tC - tB) |> Assert.shouldEqual 0 printfn "checking backgroundParseCount.Value = %d" backgroundParseCount.Value - backgroundParseCount.Value |> Assert.shouldBe 0 + backgroundParseCount.Value |> Assert.shouldEqual 0 printfn "checking backgroundCheckCount.Value = %d" backgroundCheckCount.Value - backgroundCheckCount.Value |> Assert.shouldBe 0 + backgroundCheckCount.Value |> Assert.shouldEqual 0 printfn "CheckFileInProject()..." let checkResults1 = checker.CheckFileInProject(parseResults1, Project1.fileNames[5], 0, Project1.fileSources2[5], Project1.options) |> Async.RunImmediate @@ -69,17 +69,17 @@ let ``Test request for parse and check doesn't check whole project`` () = (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - (pD - pC) |> Assert.shouldBe 0 + (pD - pC) |> Assert.shouldEqual 0 printfn "checking (tD - tC) = %d" (tD - tC) - (tD - tC) |> Assert.shouldBe 1 + (tD - tC) |> Assert.shouldEqual 1 printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pE, tE = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...., (pE - pD) = %d" (pE - pD) - (pE - pD) |> Assert.shouldBe 0 + (pE - pD) |> Assert.shouldEqual 0 printfn "checking one foreground typecheck...., tE - tD = %d" (tE - tD) - (tE - tD) |> Assert.shouldBe 1 + (tE - tD) |> Assert.shouldEqual 1 printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value @@ -90,9 +90,9 @@ let ``Test request for parse and check doesn't check whole project`` () = let checkResults2 = checker.ParseAndCheckFileInProject(Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pF, tF = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...." - (pF - pE) |> Assert.shouldBe 0 // note, no new parse of the file + (pF - pE) |> Assert.shouldEqual 0 // note, no new parse of the file printfn "checking no extra foreground typechecks...." - (tF - tE) |> Assert.shouldBe 0 // note, no new typecheck of the file + (tF - tE) |> Assert.shouldEqual 0 // note, no new typecheck of the file printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value diff --git a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs index 25dc82b4b2e..4a8ed49279d 100644 --- a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs @@ -227,7 +227,7 @@ module TypeMemberRanges = type T = member x.Foo() = () """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 23) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 23) ] [] @@ -236,7 +236,7 @@ type T = type T = static member Foo() = () """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 28) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 28) ] [] @@ -246,7 +246,7 @@ type T = [] static member Foo() = () """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (4, 28) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (4, 28) ] [] @@ -255,7 +255,7 @@ type T = type T = member x.P = () """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 19) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 19) ] [] @@ -264,7 +264,7 @@ type T = type T = member x.P with set (value) = v <- value """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 44) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 44) ] [] @@ -275,7 +275,7 @@ type T = with get () = x and set (value) = x <- value """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (5, 36) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (5, 36) ] [] @@ -284,7 +284,7 @@ type T = type T = member val Property1 = "" """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 29) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 29) ] [] @@ -293,7 +293,7 @@ type T = type T = member val Property1 = "" with get, set """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 29) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 29) ] [] @@ -303,8 +303,8 @@ type T = abstract P: int abstract M: unit -> unit """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 19) - (4, 4), (4, 28) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 19) + (4, 4), (4, 28) ] [] let ``Member range 10 - Val field``() = @@ -312,7 +312,7 @@ type T = type T = val x: int """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 14) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 14) ] [] @@ -321,7 +321,7 @@ type T = type T = new (x:int) = () """ - getTypeMemberRange source |> Assert.shouldBe [ (3, 4), (3, 20) ] + getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 20) ] [] @@ -337,7 +337,7 @@ let y = !x res |> tups |> fst - |> Assert.shouldBe (3, 8) + |> Assert.shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -354,7 +354,7 @@ let y = !(x) res |> tups |> fst - |> Assert.shouldBe (3, 8) + |> Assert.shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -372,7 +372,7 @@ let y = !(x = false) res |> tups |> fst - |> Assert.shouldBe (3, 8) + |> Assert.shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -387,7 +387,7 @@ let x = { Name = "Hello" } | Some res -> res |> tups - |> Assert.shouldBe ((2, 8), (2, 26)) + |> Assert.shouldEqual ((2, 8), (2, 26)) | None -> failwith "No range of record found in source." @@ -414,7 +414,7 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 2)] + |> Assert.shouldEqual [(3, 2)] | None -> failwith "No arguments found in source code" @@ -430,7 +430,7 @@ f 1 2 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 2); (3, 4); (3, 6)] + |> Assert.shouldEqual [(3, 2); (3, 4); (3, 6)] | None -> failwith "No arguments found in source code" @@ -446,7 +446,7 @@ f (1) (2) (3) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 2); (3, 6); (3, 10)] + |> Assert.shouldEqual [(3, 2); (3, 6); (3, 10)] | None -> failwith "No arguments found in source code" @@ -462,7 +462,7 @@ f ((1)) (((2))) ((((3)))) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 3); (3, 10); (3, 19)] + |> Assert.shouldEqual [(3, 3); (3, 10); (3, 19)] | None -> failwith "No arguments found in source code" @@ -488,7 +488,7 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 2)] + |> Assert.shouldEqual [(3, 2)] | None -> failwith "No arguments found in source code" @@ -505,7 +505,7 @@ f t | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(4, 2)] + |> Assert.shouldEqual [(4, 2)] | None -> failwith "No arguments found in source code" @@ -521,7 +521,7 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 3); (3, 6)] + |> Assert.shouldEqual [(3, 3); (3, 6)] | None -> failwith "No arguments found in source code" @@ -538,7 +538,7 @@ f t | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(4, 2)] + |> Assert.shouldEqual [(4, 2)] | None -> failwith "No arguments found in source code" @@ -554,7 +554,7 @@ f ((1, 2)) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 4); (3, 7)] + |> Assert.shouldEqual [(3, 4); (3, 7)] | None -> failwith "No arguments found in source code" @@ -570,7 +570,7 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 3); (3, 6)] + |> Assert.shouldEqual [(3, 3); (3, 6)] | None -> failwith "No arguments found in source code" @@ -586,7 +586,7 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 2); (3, 10)] + |> Assert.shouldEqual [(3, 2); (3, 10)] | None -> failwith "No arguments found in source code" @@ -602,7 +602,7 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(3, 5); (3, 7)] + |> Assert.shouldEqual [(3, 5); (3, 7)] | None -> failwith "No arguments found in source code" @@ -617,7 +617,7 @@ let addStr x y = string x + y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(2, 24)] + |> Assert.shouldEqual [(2, 24)] | None -> failwith "No arguments found in source code" @@ -632,7 +632,7 @@ let addStr x y = x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(2, 28)] + |> Assert.shouldEqual [(2, 28)] | None -> failwith "No arguments found in source code" @@ -647,7 +647,7 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(2, 24)] + |> Assert.shouldEqual [(2, 24)] | None -> failwith "No arguments found in source code" @@ -657,7 +657,7 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldBe [(2, 35)] + |> Assert.shouldEqual [(2, 35)] | None -> failwith "No arguments found in source code" @@ -750,7 +750,7 @@ sqrt 12.0 | Some range -> range |> tups - |> Assert.shouldBe ((2, 0), (2, 4)) + |> Assert.shouldEqual ((2, 0), (2, 4)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application``() = @@ -765,7 +765,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldBe ((3, 0), (3, 1)) + |> Assert.shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application but at function itself``() = @@ -780,7 +780,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldBe ((3, 0), (3, 1)) + |> Assert.shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in pipeline``() = @@ -794,7 +794,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldBe ((2, 11), (2, 19)) + |> Assert.shouldEqual ((2, 11), (2, 19)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline``() = @@ -810,7 +810,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldBe ((3, 3), (3, 14)) + |> Assert.shouldEqual ((3, 3), (3, 14)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline, no qualification``() = @@ -825,7 +825,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldBe ((3, 3), (3, 5)) + |> Assert.shouldEqual ((3, 3), (3, 5)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - incomplete infix app``() = @@ -841,7 +841,7 @@ add2 1 2 | Some range -> range |> tups - |> Assert.shouldBe ((3, 17), (3, 18)) + |> Assert.shouldEqual ((3, 17), (3, 18)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE``() = @@ -858,7 +858,7 @@ async { | Some range -> range |> tups - |> Assert.shouldBe ((4, 11), (4, 16)) + |> Assert.shouldEqual ((4, 11), (4, 16)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - binding``() = @@ -878,7 +878,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldBe ((6, 18), (6, 21)) + |> Assert.shouldEqual ((6, 18), (6, 21)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - if expression``() = @@ -902,7 +902,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldBe ((7, 12), (7, 15)) + |> Assert.shouldEqual ((7, 12), (7, 15)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expression``() = @@ -926,7 +926,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldBe ((7, 12), (7, 15)) + |> Assert.shouldEqual ((7, 12), (7, 15)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expr``() = @@ -950,7 +950,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldBe ((9, 18), (9, 21)) + |> Assert.shouldEqual ((9, 18), (9, 21)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match case``() = @@ -974,7 +974,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldBe ((11, 19), (11, 22)) + |> Assert.shouldEqual ((11, 19), (11, 22)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call``() = @@ -989,7 +989,7 @@ C.Yeet(1, 2, sqrt) | Some range -> range |> tups - |> Assert.shouldBe ((3, 13), (3, 17)) + |> Assert.shouldEqual ((3, 13), (3, 17)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call - parenthesized lambda``() = @@ -1004,7 +1004,7 @@ C.Yeet(1, 2, (fun x -> sqrt)) | Some range -> range |> tups - |> Assert.shouldBe ((3, 23), (3, 27)) + |> Assert.shouldEqual ((3, 23), (3, 27)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - generic-typed app``() = @@ -1019,7 +1019,7 @@ f | Some range -> range |> tups - |> Assert.shouldBe ((3, 0), (3, 1)) + |> Assert.shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a list that is used as an argument - Sequential and ArrayOrListComputed``() = @@ -1039,7 +1039,7 @@ let test () = div [] [ | Some range -> range |> tups - |> Assert.shouldBe ((5, 8), (5, 13)) + |> Assert.shouldEqual ((5, 8), (5, 13)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after semicolon - Sequential and ComputationExpr``() = @@ -1086,7 +1086,7 @@ seq { 5; int "6" } |> Seq.sum | Some range -> range |> tups - |> Assert.shouldBe ((2, 9), (2, 12)) + |> Assert.shouldEqual ((2, 9), (2, 12)) module PipelinesAndArgs = @@ -1119,7 +1119,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldBe ("op_PipeRight", 1) + |> Assert.shouldEqual ("op_PipeRight", 1) | None -> failwith "No pipeline found" @@ -1133,7 +1133,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldBe ("op_PipeRight2", 2) + |> Assert.shouldEqual ("op_PipeRight2", 2) | None -> failwith "No pipeline found" @@ -1147,7 +1147,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldBe ("op_PipeRight3", 3) + |> Assert.shouldEqual ("op_PipeRight3", 3) | None -> failwith "No pipeline found" @@ -1188,7 +1188,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldBe ((3, 11), (3, 12)) + |> Assert.shouldEqual ((3, 11), (3, 12)) | None -> failwith "Expected to get a range back, but got none." @@ -1212,7 +1212,7 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldBe [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> Assert.shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> failwith "Expected to get a range back, but got none." @@ -1227,7 +1227,7 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldBe [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> Assert.shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> failwith "Expected to get a range back, but got none." @@ -1242,7 +1242,7 @@ let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldBe [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] + |> Assert.shouldEqual [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] | None -> failwith "Expected to get a range back, but got none." @@ -1257,7 +1257,7 @@ let x = nameof x | Some range -> range |> tups - |> Assert.shouldBe ((2, 4), (2, 5)) + |> Assert.shouldEqual ((2, 4), (2, 5)) | None -> failwith "Expected to get a range back, but got none." @@ -1276,7 +1276,7 @@ let mySum xs acc = | Some range -> range |> tups - |> Assert.shouldBe ((2, 4), (2, 9)) + |> Assert.shouldEqual ((2, 4), (2, 9)) | None -> failwith "Expected to get a range back, but got none." @@ -1295,7 +1295,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldBe ((4, 8), (4, 9)) + |> Assert.shouldEqual ((4, 8), (4, 9)) | None -> failwith "Expected to get a range back, but got none." @@ -1316,7 +1316,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldBe ((6, 8), (6, 9)) + |> Assert.shouldEqual ((6, 8), (6, 9)) | None -> failwith "Expected to get a range back, but got none." From 1aefa67fd2a719d65e7d09fb781b0629f93aac1e Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 1 Aug 2023 18:05:11 +0200 Subject: [PATCH 09/32] up --- tests/FSharp.Compiler.UnitTests/ExprTests.fs | 91 ++++++------- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 37 ++--- .../ServiceUntypedParseTests.fs | 127 +++++++++--------- 3 files changed, 129 insertions(+), 126 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs index a50250b0f2d..4f08cbf724d 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -21,6 +21,7 @@ open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns open TestFramework +open Assert type FSharpCore = | FC45 @@ -733,12 +734,12 @@ let ``Test Unoptimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 2 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 2 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let file2 = wholeProjectResults.AssemblyContents.ImplementationFiles[1] @@ -849,12 +850,12 @@ let ``Test Unoptimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldPairwiseEqual (Utils.filterHack expected) + |> shouldPairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldPairwiseEqual (Utils.filterHack expected2) + |> shouldPairwiseEqual (Utils.filterHack expected2) () @@ -868,12 +869,12 @@ let ``Test Optimized Declarations Project1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 3 // recursive value warning - wholeProjectResults.Diagnostics[0].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[1].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.Diagnostics[2].Severity |> Assert.shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning + wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning + wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldEqual 2 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> shouldEqual 2 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] let file2 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[1] @@ -985,12 +986,12 @@ let ``Test Optimized Declarations Project1`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldPairwiseEqual (Utils.filterHack expected) + |> shouldPairwiseEqual (Utils.filterHack expected) printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList |> Utils.filterHack - |> Assert.shouldPairwiseEqual (Utils.filterHack expected2) + |> shouldPairwiseEqual (Utils.filterHack expected2) () @@ -1034,8 +1035,8 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi printfn "%s Operator Tests error: <<<%s>>>" dnName e.Message errors.AppendLine e.Message |> ignore - errors.ToString() |> Assert.shouldEqual "" - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 + errors.ToString() |> shouldEqual "" + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 let resultUnoptimized = wholeProjectResults.AssemblyContents.ImplementationFiles[0].Declarations @@ -1100,11 +1101,11 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi // fail test on first line that fails, show difference in output window resultUnoptFiltered - |> Assert.shouldPairwiseEqual expectedUnoptFiltered + |> shouldPairwiseEqual expectedUnoptFiltered // fail test on first line that fails, show difference in output window resultOptFiltered - |> Assert.shouldPairwiseEqual expectedOptFiltered + |> shouldPairwiseEqual expectedOptFiltered end [] @@ -3199,9 +3200,9 @@ let ``Test expressions of declarations stress big expressions`` () = let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] // This should not stack overflow @@ -3219,9 +3220,9 @@ let ``Test expressions of optimized declarations stress big expressions`` () = let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 - wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0] // This should not stack overflow @@ -3282,7 +3283,7 @@ let ``Test ProjectForWitnesses1`` () = for e in wholeProjectResults.Diagnostics do printfn "Project1 error: <<<%s>>>" e.Message - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3313,7 +3314,7 @@ let ``Test ProjectForWitnesses1`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldPairwiseEqual expected + |> shouldPairwiseEqual expected [] @@ -3338,10 +3339,10 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldEqual "callX$W" - argTypes.Count |> Assert.shouldEqual 1 + nm |> shouldEqual "callX$W" + argTypes.Count |> shouldEqual 1 let argText = argTypes[0].Type.ToString() - argText |> Assert.shouldEqual "type ^T -> ^U -> ^V" + argText |> shouldEqual "type ^T -> ^U -> ^V" end @@ -3357,14 +3358,14 @@ let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldEqual "callXY$W" - argTypes.Count |> Assert.shouldEqual 2 + nm |> shouldEqual "callXY$W" + argTypes.Count |> shouldEqual 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argText1 |> Assert.shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" - argText2 |> Assert.shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText1 |> shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" + argText2 |> shouldEqual "type ^T -> ^U -> Microsoft.FSharp.Core.unit" end @@ -3406,8 +3407,8 @@ let ``Test ProjectForWitnesses2`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses2 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3425,7 +3426,7 @@ let ``Test ProjectForWitnesses2`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldPairwiseEqual expected + |> shouldPairwiseEqual expected //--------------------------------------------------------------------------------------------------------- // This project is for witness arguments, testing for https://github.com/dotnet/fsharp/issues/10364 @@ -3461,8 +3462,8 @@ let ``Test ProjectForWitnesses3`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses3 error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> Assert.shouldEqual 0 - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3480,7 +3481,7 @@ let ``Test ProjectForWitnesses3`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldPairwiseEqual expected + |> shouldPairwiseEqual expected [] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = @@ -3504,16 +3505,16 @@ let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = match wpi with | None -> failwith "witness passing info expected" | Some (nm, argTypes) -> - nm |> Assert.shouldEqual "Sum$W" - argTypes.Count |> Assert.shouldEqual 2 + nm |> shouldEqual "Sum$W" + argTypes.Count |> shouldEqual 2 let argName1 = argTypes[0].Name let argText1 = argTypes[0].Type.ToString() let argName2 = argTypes[1].Name let argText2 = argTypes[1].Type.ToString() - argName1 |> Assert.shouldEqual (Some "get_Zero") - argText1 |> Assert.shouldEqual "type Microsoft.FSharp.Core.unit -> ^T" - argName2 |> Assert.shouldEqual (Some "op_Addition") - argText2 |> Assert.shouldEqual "type ^T -> ^T -> ^T" + argName1 |> shouldEqual (Some "get_Zero") + argText1 |> shouldEqual "type Microsoft.FSharp.Core.unit -> ^T" + argName2 |> shouldEqual (Some "op_Addition") + argText2 |> shouldEqual "type ^T -> ^T -> ^T" end //--------------------------------------------------------------------------------------------------------- @@ -3557,7 +3558,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) - wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> Assert.shouldEqual 1 + wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] let expected = @@ -3571,4 +3572,4 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = |> Seq.toList printfn "actual:\n\n%A" actual actual - |> Assert.shouldPairwiseEqual expected + |> shouldPairwiseEqual expected diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index f528276c7d3..a6b1aaaf6fd 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -13,6 +13,7 @@ open FSharp.Compiler.IO open FSharp.Compiler.Text open FSharp.Compiler.Service.Tests.Common open TestFramework +open Assert // Create an interactive checker instance let internal checker = FSharpChecker.Create() @@ -47,54 +48,54 @@ let ``Test request for parse and check doesn't check whole project`` () = printfn "ParseFile()..." let parseResults1 = checker.ParseFile(Project1.fileNames[5], Project1.fileSources2[5], Project1.parsingOptions) |> Async.RunImmediate let pC, tC = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount - (pC - pB) |> Assert.shouldEqual 1 - (tC - tB) |> Assert.shouldEqual 0 + (pC - pB) |> shouldEqual 1 + (tC - tB) |> shouldEqual 0 printfn "checking backgroundParseCount.Value = %d" backgroundParseCount.Value - backgroundParseCount.Value |> Assert.shouldEqual 0 + backgroundParseCount.Value |> shouldEqual 0 printfn "checking backgroundCheckCount.Value = %d" backgroundCheckCount.Value - backgroundCheckCount.Value |> Assert.shouldEqual 0 + backgroundCheckCount.Value |> shouldEqual 0 printfn "CheckFileInProject()..." let checkResults1 = checker.CheckFileInProject(parseResults1, Project1.fileNames[5], 0, Project1.fileSources2[5], Project1.options) |> Async.RunImmediate let pD, tD = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking background parsing happened...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value >= 5) |> Assert.shouldBeTrue // but note, the project does not get reparsed + (backgroundParseCount.Value >= 5) |> shouldEqual true // but note, the project does not get reparsed printfn "checking background typechecks happened...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value >= 5) |> Assert.shouldBeTrue // only two extra typechecks of files + (backgroundCheckCount.Value >= 5) |> shouldEqual true // only two extra typechecks of files printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - (pD - pC) |> Assert.shouldEqual 0 + (pD - pC) |> shouldEqual 0 printfn "checking (tD - tC) = %d" (tD - tC) - (tD - tC) |> Assert.shouldEqual 1 + (tD - tC) |> shouldEqual 1 printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pE, tE = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...., (pE - pD) = %d" (pE - pD) - (pE - pD) |> Assert.shouldEqual 0 + (pE - pD) |> shouldEqual 0 printfn "checking one foreground typecheck...., tE - tD = %d" (tE - tD) - (tE - tD) |> Assert.shouldEqual 1 + (tE - tD) |> shouldEqual 1 printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files printfn "ParseAndCheckFileInProject()..." // A subsequent ParseAndCheck of identical source code doesn't do any more anything let checkResults2 = checker.ParseAndCheckFileInProject(Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate let pF, tF = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount printfn "checking no extra foreground parsing...." - (pF - pE) |> Assert.shouldEqual 0 // note, no new parse of the file + (pF - pE) |> shouldEqual 0 // note, no new parse of the file printfn "checking no extra foreground typechecks...." - (tF - tE) |> Assert.shouldEqual 0 // note, no new typecheck of the file + (tF - tE) |> shouldEqual 0 // note, no new typecheck of the file printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value - (backgroundParseCount.Value <= 10) |> Assert.shouldBeTrue // but note, the project does not get reparsed + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value - (backgroundCheckCount.Value <= 10) |> Assert.shouldBeTrue // only two extra typechecks of files + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files () diff --git a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs index 4a8ed49279d..d5a84b9121a 100644 --- a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs @@ -14,6 +14,7 @@ open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Text.Position open Xunit +open Assert let [] private Marker = "(* marker *)" @@ -154,7 +155,7 @@ let foo8 = () | SynModuleDecl.Let (_, [SynBinding (attributes = attributeLists)], _) -> attributeLists |> List.map (fun list -> list.Attributes.Length, getRangeCoords list.Range) | _ -> failwith "Could not get binding") - |> Assert.shouldBe + |> shouldEqual [ [ (1, ((2, 0), (2, 5))) ] [ (1, ((5, 0), (5, 5))); (2, ((6, 0), (6, 7))) ] [ (1, ((9, 0), (9, 5))); (2, ((9, 6), (9, 13))) ] @@ -205,7 +206,7 @@ let ``SynType.Paren ranges`` () = getParenTypes synType |> List.map (fun synType -> getRangeCoords synType.Range) | _ -> failwith "Could not get binding") - |> Assert.shouldBe + |> shouldEqual [ [ (2, 11), (2, 22) ] [ (3, 5), (3, 17) ] [ (4, 5), (4, 12); (4, 6), (4, 11) ] ] @@ -227,7 +228,7 @@ module TypeMemberRanges = type T = member x.Foo() = () """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 23) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 23) ] [] @@ -236,7 +237,7 @@ type T = type T = static member Foo() = () """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 28) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 28) ] [] @@ -246,7 +247,7 @@ type T = [] static member Foo() = () """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (4, 28) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (4, 28) ] [] @@ -255,7 +256,7 @@ type T = type T = member x.P = () """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 19) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) ] [] @@ -264,7 +265,7 @@ type T = type T = member x.P with set (value) = v <- value """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 44) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 44) ] [] @@ -275,7 +276,7 @@ type T = with get () = x and set (value) = x <- value """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (5, 36) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (5, 36) ] [] @@ -284,7 +285,7 @@ type T = type T = member val Property1 = "" """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 29) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] [] @@ -293,7 +294,7 @@ type T = type T = member val Property1 = "" with get, set """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 29) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] [] @@ -303,8 +304,8 @@ type T = abstract P: int abstract M: unit -> unit """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 19) - (4, 4), (4, 28) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) + (4, 4), (4, 28) ] [] let ``Member range 10 - Val field``() = @@ -312,7 +313,7 @@ type T = type T = val x: int """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 14) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 14) ] [] @@ -321,7 +322,7 @@ type T = type T = new (x:int) = () """ - getTypeMemberRange source |> Assert.shouldEqual [ (3, 4), (3, 20) ] + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 20) ] [] @@ -337,7 +338,7 @@ let y = !x res |> tups |> fst - |> Assert.shouldEqual (3, 8) + |> shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -354,7 +355,7 @@ let y = !(x) res |> tups |> fst - |> Assert.shouldEqual (3, 8) + |> shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -372,7 +373,7 @@ let y = !(x = false) res |> tups |> fst - |> Assert.shouldEqual (3, 8) + |> shouldEqual (3, 8) | None -> failwith "No deref operator found in source." @@ -387,7 +388,7 @@ let x = { Name = "Hello" } | Some res -> res |> tups - |> Assert.shouldEqual ((2, 8), (2, 26)) + |> shouldEqual ((2, 8), (2, 26)) | None -> failwith "No range of record found in source." @@ -414,7 +415,7 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 2)] + |> shouldEqual [(3, 2)] | None -> failwith "No arguments found in source code" @@ -430,7 +431,7 @@ f 1 2 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 2); (3, 4); (3, 6)] + |> shouldEqual [(3, 2); (3, 4); (3, 6)] | None -> failwith "No arguments found in source code" @@ -446,7 +447,7 @@ f (1) (2) (3) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 2); (3, 6); (3, 10)] + |> shouldEqual [(3, 2); (3, 6); (3, 10)] | None -> failwith "No arguments found in source code" @@ -462,7 +463,7 @@ f ((1)) (((2))) ((((3)))) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 3); (3, 10); (3, 19)] + |> shouldEqual [(3, 3); (3, 10); (3, 19)] | None -> failwith "No arguments found in source code" @@ -488,7 +489,7 @@ f 12 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 2)] + |> shouldEqual [(3, 2)] | None -> failwith "No arguments found in source code" @@ -505,7 +506,7 @@ f t | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(4, 2)] + |> shouldEqual [(4, 2)] | None -> failwith "No arguments found in source code" @@ -521,7 +522,7 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 3); (3, 6)] + |> shouldEqual [(3, 3); (3, 6)] | None -> failwith "No arguments found in source code" @@ -538,7 +539,7 @@ f t | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(4, 2)] + |> shouldEqual [(4, 2)] | None -> failwith "No arguments found in source code" @@ -554,7 +555,7 @@ f ((1, 2)) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 4); (3, 7)] + |> shouldEqual [(3, 4); (3, 7)] | None -> failwith "No arguments found in source code" @@ -570,7 +571,7 @@ f (1, 2) | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 3); (3, 6)] + |> shouldEqual [(3, 3); (3, 6)] | None -> failwith "No arguments found in source code" @@ -586,7 +587,7 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 2); (3, 10)] + |> shouldEqual [(3, 2); (3, 10)] | None -> failwith "No arguments found in source code" @@ -602,7 +603,7 @@ f (f 1 2) 3 | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(3, 5); (3, 7)] + |> shouldEqual [(3, 5); (3, 7)] | None -> failwith "No arguments found in source code" @@ -617,7 +618,7 @@ let addStr x y = string x + y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(2, 24)] + |> shouldEqual [(2, 24)] | None -> failwith "No arguments found in source code" @@ -632,7 +633,7 @@ let addStr x y = x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(2, 28)] + |> shouldEqual [(2, 28)] | None -> failwith "No arguments found in source code" @@ -647,7 +648,7 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(2, 24)] + |> shouldEqual [(2, 24)] | None -> failwith "No arguments found in source code" @@ -657,7 +658,7 @@ let addStr x y = string x + string y | Some res -> res |> List.map (tups >> fst) - |> Assert.shouldEqual [(2, 35)] + |> shouldEqual [(2, 35)] | None -> failwith "No arguments found in source code" @@ -750,7 +751,7 @@ sqrt 12.0 | Some range -> range |> tups - |> Assert.shouldEqual ((2, 0), (2, 4)) + |> shouldEqual ((2, 0), (2, 4)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application``() = @@ -765,7 +766,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldEqual ((3, 0), (3, 1)) + |> shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application but at function itself``() = @@ -780,7 +781,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldEqual ((3, 0), (3, 1)) + |> shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in pipeline``() = @@ -794,7 +795,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldEqual ((2, 11), (2, 19)) + |> shouldEqual ((2, 11), (2, 19)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline``() = @@ -810,7 +811,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldEqual ((3, 3), (3, 14)) + |> shouldEqual ((3, 3), (3, 14)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline, no qualification``() = @@ -825,7 +826,7 @@ f 1 2 3 | Some range -> range |> tups - |> Assert.shouldEqual ((3, 3), (3, 5)) + |> shouldEqual ((3, 3), (3, 5)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - incomplete infix app``() = @@ -841,7 +842,7 @@ add2 1 2 | Some range -> range |> tups - |> Assert.shouldEqual ((3, 17), (3, 18)) + |> shouldEqual ((3, 17), (3, 18)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE``() = @@ -858,7 +859,7 @@ async { | Some range -> range |> tups - |> Assert.shouldEqual ((4, 11), (4, 16)) + |> shouldEqual ((4, 11), (4, 16)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - binding``() = @@ -878,7 +879,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldEqual ((6, 18), (6, 21)) + |> shouldEqual ((6, 18), (6, 21)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - if expression``() = @@ -902,7 +903,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldEqual ((7, 12), (7, 15)) + |> shouldEqual ((7, 12), (7, 15)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expression``() = @@ -926,7 +927,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldEqual ((7, 12), (7, 15)) + |> shouldEqual ((7, 12), (7, 15)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expr``() = @@ -950,7 +951,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldEqual ((9, 18), (9, 21)) + |> shouldEqual ((9, 18), (9, 21)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match case``() = @@ -974,7 +975,7 @@ let mapped = | Some range -> range |> tups - |> Assert.shouldEqual ((11, 19), (11, 22)) + |> shouldEqual ((11, 19), (11, 22)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call``() = @@ -989,7 +990,7 @@ C.Yeet(1, 2, sqrt) | Some range -> range |> tups - |> Assert.shouldEqual ((3, 13), (3, 17)) + |> shouldEqual ((3, 13), (3, 17)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call - parenthesized lambda``() = @@ -1004,7 +1005,7 @@ C.Yeet(1, 2, (fun x -> sqrt)) | Some range -> range |> tups - |> Assert.shouldEqual ((3, 23), (3, 27)) + |> shouldEqual ((3, 23), (3, 27)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - generic-typed app``() = @@ -1019,7 +1020,7 @@ f | Some range -> range |> tups - |> Assert.shouldEqual ((3, 0), (3, 1)) + |> shouldEqual ((3, 0), (3, 1)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a list that is used as an argument - Sequential and ArrayOrListComputed``() = @@ -1039,7 +1040,7 @@ let test () = div [] [ | Some range -> range |> tups - |> Assert.shouldEqual ((5, 8), (5, 13)) + |> shouldEqual ((5, 8), (5, 13)) [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after semicolon - Sequential and ComputationExpr``() = @@ -1086,7 +1087,7 @@ seq { 5; int "6" } |> Seq.sum | Some range -> range |> tups - |> Assert.shouldEqual ((2, 9), (2, 12)) + |> shouldEqual ((2, 9), (2, 12)) module PipelinesAndArgs = @@ -1119,7 +1120,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldEqual ("op_PipeRight", 1) + |> shouldEqual ("op_PipeRight", 1) | None -> failwith "No pipeline found" @@ -1133,7 +1134,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldEqual ("op_PipeRight2", 2) + |> shouldEqual ("op_PipeRight2", 2) | None -> failwith "No pipeline found" @@ -1147,7 +1148,7 @@ let square x = x * match res with | Some (ident, numArgs) -> (ident.idText, numArgs) - |> Assert.shouldEqual ("op_PipeRight3", 3) + |> shouldEqual ("op_PipeRight3", 3) | None -> failwith "No pipeline found" @@ -1188,7 +1189,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldEqual ((3, 11), (3, 12)) + |> shouldEqual ((3, 11), (3, 12)) | None -> failwith "Expected to get a range back, but got none." @@ -1212,7 +1213,7 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> failwith "Expected to get a range back, but got none." @@ -1227,7 +1228,7 @@ let x = y => y + 1 | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] + |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> failwith "Expected to get a range back, but got none." @@ -1242,7 +1243,7 @@ let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = | Some (overallRange, argRange, exprRange) -> [overallRange; argRange; exprRange] |> List.map tups - |> Assert.shouldEqual [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] + |> shouldEqual [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] | None -> failwith "Expected to get a range back, but got none." @@ -1257,7 +1258,7 @@ let x = nameof x | Some range -> range |> tups - |> Assert.shouldEqual ((2, 4), (2, 5)) + |> shouldEqual ((2, 4), (2, 5)) | None -> failwith "Expected to get a range back, but got none." @@ -1276,7 +1277,7 @@ let mySum xs acc = | Some range -> range |> tups - |> Assert.shouldEqual ((2, 4), (2, 9)) + |> shouldEqual ((2, 4), (2, 9)) | None -> failwith "Expected to get a range back, but got none." @@ -1295,7 +1296,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldEqual ((4, 8), (4, 9)) + |> shouldEqual ((4, 8), (4, 9)) | None -> failwith "Expected to get a range back, but got none." @@ -1316,7 +1317,7 @@ let f x = | Some range -> range |> tups - |> Assert.shouldEqual ((6, 8), (6, 9)) + |> shouldEqual ((6, 8), (6, 9)) | None -> failwith "Expected to get a range back, but got none." From 312c38a1a7fbf3dad40ef78a4f077e7bbf711c4d Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 2 Aug 2023 14:49:15 +0200 Subject: [PATCH 10/32] Update PerfTests.fs --- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index a6b1aaaf6fd..258a4c00bf2 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -33,7 +33,6 @@ module internal Project1 = let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) let parsingOptions, _ = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args) - [] let ``Test request for parse and check doesn't check whole project`` () = printfn "starting test..." From fdf9357dfa9973c59d2f3537137c0e5c7c717f25 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 2 Aug 2023 16:50:06 +0200 Subject: [PATCH 11/32] Update Build.ps1 --- eng/Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index a545a193f43..a92920d01e2 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -565,7 +565,7 @@ try { $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" From 09e29c5895061108212a6a0dbcd106eeba20e567 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 2 Aug 2023 19:00:45 +0200 Subject: [PATCH 12/32] up --- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 4 ++-- tests/FSharp.Test.Utilities/Assert.fs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index 258a4c00bf2..ea868cfe99b 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -69,9 +69,9 @@ let ``Test request for parse and check doesn't check whole project`` () = (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - (pD - pC) |> shouldEqual 0 + Assert.Equal(0, pD - pC) printfn "checking (tD - tC) = %d" (tD - tC) - (tD - tC) |> shouldEqual 1 + Assert.Equal(1, tD - tC) printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index 2e5a29e9b20..46aa7dc8684 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -68,7 +68,7 @@ module Assert = Some msg /// Same as 'shouldBe' but goes pairwise over the collections. Lengths must be equal. - let shouldPairwiseEqual (x: seq<_>) (y: seq<_>) = + let shouldPairwiseEqual (x: seq<'T>) (y: seq<'T>) = // using enumerators, because Seq.iter2 allows different lengths silently let ex = x.GetEnumerator() let ey = y.GetEnumerator() From d496fd8bc8712c0f94c6bc021d128d80f0407fd8 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 2 Aug 2023 19:55:48 +0200 Subject: [PATCH 13/32] handle race --- tests/FSharp.Compiler.UnitTests/PerfTests.fs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/FSharp.Compiler.UnitTests/PerfTests.fs index ea868cfe99b..0f243382f3a 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/FSharp.Compiler.UnitTests/PerfTests.fs @@ -17,6 +17,7 @@ open Assert // Create an interactive checker instance let internal checker = FSharpChecker.Create() +let internal syncRoot = obj() module internal Project1 = @@ -38,8 +39,8 @@ let ``Test request for parse and check doesn't check whole project`` () = printfn "starting test..." let backgroundParseCount = ref 0 let backgroundCheckCount = ref 0 - checker.FileChecked.Add (fun x -> incr backgroundCheckCount) - checker.FileParsed.Add (fun x -> incr backgroundParseCount) + checker.FileChecked.Add (fun _ -> lock syncRoot (fun () -> incr backgroundCheckCount)) + checker.FileParsed.Add (fun _ -> lock syncRoot (fun () -> incr backgroundParseCount)) checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() let pB, tB = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount @@ -69,9 +70,9 @@ let ``Test request for parse and check doesn't check whole project`` () = (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - Assert.Equal(0, pD - pC) + pD - pC |> shouldEqual 0 printfn "checking (tD - tC) = %d" (tD - tC) - Assert.Equal(1, tD - tC) + tD - tC |> shouldEqual 1 printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate From f7f947a7647f0a741971a6182e48fec27f5f41f3 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 2 Aug 2023 22:07:52 +0200 Subject: [PATCH 14/32] okay I am tired, perf tests next time --- .../FSharp.Compiler.Service.Tests.fsproj | 3 +++ .../FSharp.Compiler.UnitTests.fsproj | 4 +++- .../PerfTests.fs | 23 +++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/PerfTests.fs (93%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index dd3ffae3dd0..9d7f72a210a 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -52,6 +52,9 @@ MultiProjectAnalysisTests.fs + + PerfTests.fs + InteractiveCheckerTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 28f567ce2bb..7cdef4cb7a8 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -53,7 +53,9 @@ CompilerService\MultiProjectAnalysisTests.fs --> - + + CompilerService\PerfTests.fs + CompilerService\InteractiveCheckerTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/PerfTests.fs b/tests/service/PerfTests.fs similarity index 93% rename from tests/FSharp.Compiler.UnitTests/PerfTests.fs rename to tests/service/PerfTests.fs index 0f243382f3a..b3c47903283 100644 --- a/tests/FSharp.Compiler.UnitTests/PerfTests.fs +++ b/tests/service/PerfTests.fs @@ -1,23 +1,24 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module FSharp.Compiler.Service.Tests.PerfTests #endif -open Xunit -open FSharp.Test + +open NUnit.Framework +open FsUnit open System.IO open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.IO open FSharp.Compiler.Text open FSharp.Compiler.Service.Tests.Common open TestFramework -open Assert // Create an interactive checker instance let internal checker = FSharpChecker.Create() -let internal syncRoot = obj() module internal Project1 = @@ -34,13 +35,15 @@ module internal Project1 = let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) let parsingOptions, _ = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args) -[] + +[] let ``Test request for parse and check doesn't check whole project`` () = + printfn "starting test..." let backgroundParseCount = ref 0 let backgroundCheckCount = ref 0 - checker.FileChecked.Add (fun _ -> lock syncRoot (fun () -> incr backgroundCheckCount)) - checker.FileParsed.Add (fun _ -> lock syncRoot (fun () -> incr backgroundParseCount)) + checker.FileChecked.Add (fun x -> incr backgroundCheckCount) + checker.FileParsed.Add (fun x -> incr backgroundParseCount) checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() let pB, tB = FSharpChecker.ActualParseFileCount, FSharpChecker.ActualCheckFileCount @@ -70,9 +73,9 @@ let ``Test request for parse and check doesn't check whole project`` () = (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files printfn "checking (pD - pC) = %d" (pD - pC) - pD - pC |> shouldEqual 0 + (pD - pC) |> shouldEqual 0 printfn "checking (tD - tC) = %d" (tD - tC) - tD - tC |> shouldEqual 1 + (tD - tC) |> shouldEqual 1 printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames[7], 0, Project1.fileSources2[7], Project1.options) |> Async.RunImmediate From 30190849a844508d2ca3abd1332d00a55ff9a3ad Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 3 Aug 2023 12:39:15 +0200 Subject: [PATCH 15/32] up --- .../FSharp.Compiler.UnitTests.fsproj | 4 +++- .../AssemblyContentProviderTests.fs | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/AssemblyContentProviderTests.fs (96%) diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 7cdef4cb7a8..8e1949e1be0 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -64,7 +64,9 @@ CompilerService\CSharpProjectAnalysis.fs - + + CompilerService\AssemblyContentProviderTests.fs + diff --git a/tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs b/tests/service/AssemblyContentProviderTests.fs similarity index 96% rename from tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs rename to tests/service/AssemblyContentProviderTests.fs index e87ee58ec4a..41d6a8c660f 100644 --- a/tests/FSharp.Compiler.UnitTests/AssemblyContentProviderTests.fs +++ b/tests/service/AssemblyContentProviderTests.fs @@ -1,12 +1,14 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.AssemblyContentProviderTests #endif open System -open Xunit +open NUnit.Framework open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common @@ -67,7 +69,7 @@ let private getSymbolMap (getSymbolProperty: AssemblySymbol -> 'a) (source: stri |> List.map (fun s -> getCleanedFullName s, getSymbolProperty s) |> Map.ofList -[] +[] let ``implicitly added Module suffix is removed``() = """ type MyType = { F: int } @@ -80,7 +82,7 @@ module MyType = "Test.MyType" "Test.MyType.func123"] -[] +[] let ``Module suffix added by an explicitly applied ModuleSuffix attribute is removed``() = """ [] @@ -91,7 +93,7 @@ module MyType = "Test.MyType" "Test.MyType.func123" ] -[] +[] let ``Property getters and setters are removed``() = """ type MyType() = @@ -101,7 +103,7 @@ let ``Property getters and setters are removed``() = "Test.MyType" "Test.MyType.MyProperty" ] -[] +[] let ``TopRequireQualifiedAccessParent property should be valid``() = let source = """ module M1 = From 426b00641f3321be78a016c00b4b5af774983939 Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 3 Aug 2023 16:27:26 +0200 Subject: [PATCH 16/32] Trying something out --- eng/Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index a92920d01e2..a545a193f43 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -565,7 +565,7 @@ try { $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" From b96cc053d7fd8ecc6a0cd149abc06fea04497d90 Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 3 Aug 2023 17:41:17 +0200 Subject: [PATCH 17/32] up --- eng/Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index a545a193f43..a92920d01e2 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -565,7 +565,7 @@ try { $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" From 52ddb40db153fa7a09b4eceebac017caae15d4a1 Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 3 Aug 2023 17:44:01 +0200 Subject: [PATCH 18/32] trying something out --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d7b49c26c32..c0a1ad53bf8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -477,6 +477,7 @@ stages: - job: Linux pool: vmImage: $(UbuntuMachineQueueName) + timeoutInMinutes: 90 variables: - name: _SignType value: Test @@ -517,6 +518,7 @@ stages: - job: MacOS pool: vmImage: macos-11 + timeoutInMinutes: 90 variables: - name: _SignType value: Test From 1f2a6b3c73cec9adad33c112a3e2535e9c07bfad Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 7 Aug 2023 16:01:06 +0200 Subject: [PATCH 19/32] Revert "trying something out" This reverts commit 52ddb40db153fa7a09b4eceebac017caae15d4a1. --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c0a1ad53bf8..d7b49c26c32 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -477,7 +477,6 @@ stages: - job: Linux pool: vmImage: $(UbuntuMachineQueueName) - timeoutInMinutes: 90 variables: - name: _SignType value: Test @@ -518,7 +517,6 @@ stages: - job: MacOS pool: vmImage: macos-11 - timeoutInMinutes: 90 variables: - name: _SignType value: Test From dc3b41bc332d637cead1c9afe637582b228f9cff Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 12:35:44 +0200 Subject: [PATCH 20/32] trying something out --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../ExprTests.fs | 85 ++++++++++--------- 3 files changed, 50 insertions(+), 42 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/ExprTests.fs (99%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 9d7f72a210a..6fca44a1a53 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -58,6 +58,9 @@ InteractiveCheckerTests.fs + + ExprTests.fs + CSharpProjectAnalysis.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 8e1949e1be0..f73d795a427 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -59,7 +59,9 @@ CompilerService\InteractiveCheckerTests.fs - + + CompilerService\ExprTests.fs + CompilerService\CSharpProjectAnalysis.fs diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/service/ExprTests.fs similarity index 99% rename from tests/FSharp.Compiler.UnitTests/ExprTests.fs rename to tests/service/ExprTests.fs index 4f08cbf724d..8c8128eca18 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -1,13 +1,15 @@  #if INTERACTIVE #r "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0/FSharp.Compiler.Service.dll" -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/FSharp.Compiler.UnitTests/Debug/net472/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module FSharp.Compiler.Service.Tests.ExprTests #endif -open Xunit -open FSharp.Test +open NUnit.Framework +open FsUnit open System open System.IO open System.Text @@ -21,7 +23,6 @@ open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns open TestFramework -open Assert type FSharpCore = | FC45 @@ -723,8 +724,15 @@ let test{0}ToStringOperator (e1:{1}) = string e1 """ +let ignoreTestIfStackOverflowExpected () = +#if !NETFRAMEWORK && DEBUG + Assert.Ignore("Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.") +#else + () +#endif + /// This test is run in unison with its optimized counterpart below -[] +[] let ``Test Unoptimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -859,7 +867,7 @@ let ``Test Unoptimized Declarations Project1`` () = () -[] +[] let ``Test Optimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -1108,7 +1116,7 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi |> shouldPairwiseEqual expectedOptFiltered end -[] +[] let ``Test Operator Declarations for Byte`` () = let excludedTests = [ "testByteUnaryNegOperator"; @@ -1218,7 +1226,7 @@ let ``Test Operator Declarations for Byte`` () = testOperators "Byte" "byte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for SByte`` () = let excludedTests = [ ] @@ -1327,7 +1335,7 @@ let ``Test Operator Declarations for SByte`` () = testOperators "SByte" "sbyte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int16`` () = let excludedTests = [ ] @@ -1436,7 +1444,7 @@ let ``Test Operator Declarations for Int16`` () = testOperators "Int16" "int16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt16`` () = let excludedTests = [ "testUInt16UnaryNegOperator"; @@ -1544,7 +1552,7 @@ let ``Test Operator Declarations for UInt16`` () = testOperators "UInt16" "uint16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int`` () = let excludedTests = [ ] @@ -1653,7 +1661,7 @@ let ``Test Operator Declarations for Int`` () = testOperators "Int" "int" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int32`` () = let excludedTests = [ ] @@ -1763,7 +1771,7 @@ let ``Test Operator Declarations for Int32`` () = testOperators "Int32" "int32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt32`` () = let excludedTests = [ "testUInt32UnaryNegOperator"; @@ -1871,7 +1879,7 @@ let ``Test Operator Declarations for UInt32`` () = testOperators "UInt32" "uint32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int64`` () = let excludedTests = [ ] @@ -1981,7 +1989,7 @@ let ``Test Operator Declarations for Int64`` () = testOperators "Int64" "int64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt64`` () = let excludedTests = [ "testUInt64UnaryNegOperator"; @@ -2089,7 +2097,7 @@ let ``Test Operator Declarations for UInt64`` () = testOperators "UInt64" "uint64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for IntPtr`` () = let excludedTests = [ ] @@ -2198,7 +2206,7 @@ let ``Test Operator Declarations for IntPtr`` () = testOperators "IntPtr" "nativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UIntPtr`` () = let excludedTests = [ "testUIntPtrUnaryNegOperator"; @@ -2306,7 +2314,7 @@ let ``Test Operator Declarations for UIntPtr`` () = testOperators "UIntPtr" "unativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single`` () = let excludedTests = [ "testSingleBitwiseAndOperator"; @@ -2411,7 +2419,7 @@ let ``Test Operator Declarations for Single`` () = testOperators "Single" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single with unit of measure`` () = let excludedTests = [ "testSingleUnitizedBitwiseAndOperator"; @@ -2516,7 +2524,7 @@ let ``Test Operator Declarations for Single with unit of measure`` () = testOperators "SingleUnitized" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Double`` () = let excludedTests = [ "testDoubleBitwiseAndOperator"; @@ -2622,7 +2630,7 @@ let ``Test Operator Declarations for Double`` () = testOperators "Double" "float" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal`` () = let excludedTests = [ // None of these are supported for decimals @@ -2721,7 +2729,7 @@ let ``Test Operator Declarations for Decimal`` () = testOperators "Decimal" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal unitized`` () = let excludedTests = [ // None of these are supported for unitized decimals @@ -2802,7 +2810,7 @@ let ``Test Operator Declarations for Decimal unitized`` () = ] testOperators "DecimalUnitized" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Char`` () = let excludedTests = [ "testCharSubtractionOperator"; @@ -2899,7 +2907,7 @@ let ``Test Operator Declarations for Char`` () = testOperators "Char" "char" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for String`` () = let excludedTests = [ "testStringSubtractionOperator"; @@ -3189,12 +3197,10 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) = let createOptions() = createOptionsAux [fileSource1] [] -#if !NETFRAMEWORK && DEBUG -[] -#else -[] -#endif + +[] let ``Test expressions of declarations stress big expressions`` () = + ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3209,12 +3215,9 @@ let ``Test expressions of declarations stress big expressions`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore -#if !NETFRAMEWORK && DEBUG -[] -#else -[] -#endif +[] let ``Test expressions of optimized declarations stress big expressions`` () = + ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3273,7 +3276,7 @@ let f8() = callXY (D()) (C()) let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses1`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3317,7 +3320,7 @@ let ``Test ProjectForWitnesses1`` () = |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3397,7 +3400,7 @@ type MyNumberWrapper = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses2`` () = let cleanup, options = ProjectForWitnesses2.createOptions() use _holder = cleanup @@ -3452,7 +3455,7 @@ let s2 = sign p1 let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses3`` () = let cleanup, options = createOptionsAux [ ProjectForWitnesses3.fileSource1 ] ["--langversion:7.0"] use _holder = cleanup @@ -3483,7 +3486,7 @@ let ``Test ProjectForWitnesses3`` () = actual |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses3.createOptions() use _holder = cleanup @@ -3546,7 +3549,7 @@ let isNullQuoted (ts : 't[]) = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses4.createOptions() use _holder = cleanup @@ -3556,7 +3559,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses4 error: <<<%s>>>" e.Message - Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) + Assert.AreEqual(wholeProjectResults.Diagnostics.Length, 0) wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] From 8493857d6c33dc42e52f15d40320e546becd4fc3 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 12:42:15 +0200 Subject: [PATCH 21/32] Revert "trying something out" This reverts commit dc3b41bc332d637cead1c9afe637582b228f9cff. --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../ExprTests.fs | 85 +++++++++---------- .../FSharp.Compiler.UnitTests.fsproj | 4 +- 3 files changed, 42 insertions(+), 50 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/ExprTests.fs (99%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6fca44a1a53..9d7f72a210a 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -58,9 +58,6 @@ InteractiveCheckerTests.fs - - ExprTests.fs - CSharpProjectAnalysis.fs diff --git a/tests/service/ExprTests.fs b/tests/FSharp.Compiler.UnitTests/ExprTests.fs similarity index 99% rename from tests/service/ExprTests.fs rename to tests/FSharp.Compiler.UnitTests/ExprTests.fs index 8c8128eca18..4f08cbf724d 100644 --- a/tests/service/ExprTests.fs +++ b/tests/FSharp.Compiler.UnitTests/ExprTests.fs @@ -1,15 +1,13 @@  #if INTERACTIVE #r "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0/FSharp.Compiler.Service.dll" -#r "../../artifacts/bin/FSharp.Compiler.UnitTests/Debug/net472/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module FSharp.Compiler.Service.Tests.ExprTests #endif -open NUnit.Framework -open FsUnit +open Xunit +open FSharp.Test open System open System.IO open System.Text @@ -23,6 +21,7 @@ open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns open TestFramework +open Assert type FSharpCore = | FC45 @@ -724,15 +723,8 @@ let test{0}ToStringOperator (e1:{1}) = string e1 """ -let ignoreTestIfStackOverflowExpected () = -#if !NETFRAMEWORK && DEBUG - Assert.Ignore("Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.") -#else - () -#endif - /// This test is run in unison with its optimized counterpart below -[] +[] let ``Test Unoptimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -867,7 +859,7 @@ let ``Test Unoptimized Declarations Project1`` () = () -[] +[] let ``Test Optimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -1116,7 +1108,7 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi |> shouldPairwiseEqual expectedOptFiltered end -[] +[] let ``Test Operator Declarations for Byte`` () = let excludedTests = [ "testByteUnaryNegOperator"; @@ -1226,7 +1218,7 @@ let ``Test Operator Declarations for Byte`` () = testOperators "Byte" "byte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for SByte`` () = let excludedTests = [ ] @@ -1335,7 +1327,7 @@ let ``Test Operator Declarations for SByte`` () = testOperators "SByte" "sbyte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int16`` () = let excludedTests = [ ] @@ -1444,7 +1436,7 @@ let ``Test Operator Declarations for Int16`` () = testOperators "Int16" "int16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt16`` () = let excludedTests = [ "testUInt16UnaryNegOperator"; @@ -1552,7 +1544,7 @@ let ``Test Operator Declarations for UInt16`` () = testOperators "UInt16" "uint16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int`` () = let excludedTests = [ ] @@ -1661,7 +1653,7 @@ let ``Test Operator Declarations for Int`` () = testOperators "Int" "int" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int32`` () = let excludedTests = [ ] @@ -1771,7 +1763,7 @@ let ``Test Operator Declarations for Int32`` () = testOperators "Int32" "int32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt32`` () = let excludedTests = [ "testUInt32UnaryNegOperator"; @@ -1879,7 +1871,7 @@ let ``Test Operator Declarations for UInt32`` () = testOperators "UInt32" "uint32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int64`` () = let excludedTests = [ ] @@ -1989,7 +1981,7 @@ let ``Test Operator Declarations for Int64`` () = testOperators "Int64" "int64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt64`` () = let excludedTests = [ "testUInt64UnaryNegOperator"; @@ -2097,7 +2089,7 @@ let ``Test Operator Declarations for UInt64`` () = testOperators "UInt64" "uint64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for IntPtr`` () = let excludedTests = [ ] @@ -2206,7 +2198,7 @@ let ``Test Operator Declarations for IntPtr`` () = testOperators "IntPtr" "nativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UIntPtr`` () = let excludedTests = [ "testUIntPtrUnaryNegOperator"; @@ -2314,7 +2306,7 @@ let ``Test Operator Declarations for UIntPtr`` () = testOperators "UIntPtr" "unativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single`` () = let excludedTests = [ "testSingleBitwiseAndOperator"; @@ -2419,7 +2411,7 @@ let ``Test Operator Declarations for Single`` () = testOperators "Single" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single with unit of measure`` () = let excludedTests = [ "testSingleUnitizedBitwiseAndOperator"; @@ -2524,7 +2516,7 @@ let ``Test Operator Declarations for Single with unit of measure`` () = testOperators "SingleUnitized" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Double`` () = let excludedTests = [ "testDoubleBitwiseAndOperator"; @@ -2630,7 +2622,7 @@ let ``Test Operator Declarations for Double`` () = testOperators "Double" "float" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal`` () = let excludedTests = [ // None of these are supported for decimals @@ -2729,7 +2721,7 @@ let ``Test Operator Declarations for Decimal`` () = testOperators "Decimal" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal unitized`` () = let excludedTests = [ // None of these are supported for unitized decimals @@ -2810,7 +2802,7 @@ let ``Test Operator Declarations for Decimal unitized`` () = ] testOperators "DecimalUnitized" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Char`` () = let excludedTests = [ "testCharSubtractionOperator"; @@ -2907,7 +2899,7 @@ let ``Test Operator Declarations for Char`` () = testOperators "Char" "char" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for String`` () = let excludedTests = [ "testStringSubtractionOperator"; @@ -3197,10 +3189,12 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) = let createOptions() = createOptionsAux [fileSource1] [] - -[] +#if !NETFRAMEWORK && DEBUG +[] +#else +[] +#endif let ``Test expressions of declarations stress big expressions`` () = - ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3215,9 +3209,12 @@ let ``Test expressions of declarations stress big expressions`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore -[] +#if !NETFRAMEWORK && DEBUG +[] +#else +[] +#endif let ``Test expressions of optimized declarations stress big expressions`` () = - ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3276,7 +3273,7 @@ let f8() = callXY (D()) (C()) let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses1`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3320,7 +3317,7 @@ let ``Test ProjectForWitnesses1`` () = |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3400,7 +3397,7 @@ type MyNumberWrapper = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses2`` () = let cleanup, options = ProjectForWitnesses2.createOptions() use _holder = cleanup @@ -3455,7 +3452,7 @@ let s2 = sign p1 let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses3`` () = let cleanup, options = createOptionsAux [ ProjectForWitnesses3.fileSource1 ] ["--langversion:7.0"] use _holder = cleanup @@ -3486,7 +3483,7 @@ let ``Test ProjectForWitnesses3`` () = actual |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses3.createOptions() use _holder = cleanup @@ -3549,7 +3546,7 @@ let isNullQuoted (ts : 't[]) = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses4.createOptions() use _holder = cleanup @@ -3559,7 +3556,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses4 error: <<<%s>>>" e.Message - Assert.AreEqual(wholeProjectResults.Diagnostics.Length, 0) + Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index f73d795a427..8e1949e1be0 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -59,9 +59,7 @@ CompilerService\InteractiveCheckerTests.fs - - CompilerService\ExprTests.fs - + CompilerService\CSharpProjectAnalysis.fs From 52bab351597839cb8aeed6bda3845ec821327491 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 12:43:26 +0200 Subject: [PATCH 22/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 ++++++++++--------- 3 files changed, 49 insertions(+), 41 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 9d7f72a210a..676dcba4732 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -61,6 +61,9 @@ CSharpProjectAnalysis.fs + + StructureTests.fs + PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 8e1949e1be0..83519317989 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -63,7 +63,9 @@ CompilerService\CSharpProjectAnalysis.fs - + + CompilerService\StructureTests.fs + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/StructureTests.fs b/tests/service/StructureTests.fs similarity index 96% rename from tests/FSharp.Compiler.UnitTests/StructureTests.fs rename to tests/service/StructureTests.fs index 17a2508f43b..9d0541f579f 100644 --- a/tests/FSharp.Compiler.UnitTests/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -1,12 +1,15 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.StructureTests #endif open System.IO -open Xunit +open NUnit.Framework +open FSharp.Compiler.EditorServices open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -52,10 +55,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -68,7 +71,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -79,7 +82,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -90,7 +93,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -108,7 +111,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -130,7 +133,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -145,7 +148,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -191,7 +194,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -228,7 +231,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -257,7 +260,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -272,7 +275,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -290,7 +293,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -311,7 +314,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -327,7 +330,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -338,7 +341,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -349,7 +352,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -367,7 +370,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -383,7 +386,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -400,7 +403,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -409,7 +412,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -418,7 +421,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -428,7 +431,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -441,7 +444,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -450,7 +453,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -460,7 +463,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -469,7 +472,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -478,7 +481,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -495,7 +498,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -520,7 +523,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -542,7 +545,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -559,7 +562,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -574,7 +577,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -585,7 +588,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -595,7 +598,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -611,7 +614,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -635,7 +638,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -658,7 +661,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From 14f439da581abc0b04fd69f031afb9dbe47e4743 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 15:07:04 +0200 Subject: [PATCH 23/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- tests/FSharp.Test.Utilities/Assert.fs | 22 +---- .../ExprTests.fs | 85 ++++++++++--------- tests/service/FsUnit.fs | 18 ++++ 5 files changed, 69 insertions(+), 63 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/ExprTests.fs (99%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 676dcba4732..6b5150a568e 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -58,6 +58,9 @@ InteractiveCheckerTests.fs + + ExprTests.fs + CSharpProjectAnalysis.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 83519317989..eb9ad85ec90 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -59,7 +59,9 @@ CompilerService\InteractiveCheckerTests.fs - + + CompilerService\ExprTests.fs + CompilerService\CSharpProjectAnalysis.fs diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index 46aa7dc8684..dfed4bf123e 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -3,6 +3,7 @@ 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) = @@ -14,9 +15,6 @@ module Assert = let inline shouldBe (expected : ^T) (actual : ^U) = actual.Should().Be(expected, "") |> ignore - let inline shouldEqual (expected : ^T) (actual : ^T) = - actual.Should().Be(expected, "") |> ignore - let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) = actual.Should().BeEmpty("") |> ignore @@ -66,21 +64,3 @@ module Assert = sb.ToString () Some msg - - /// Same as 'shouldBe' but goes pairwise over the collections. Lengths must be equal. - let shouldPairwiseEqual (x: seq<'T>) (y: seq<'T>) = - // using enumerators, because Seq.iter2 allows different lengths silently - let ex = x.GetEnumerator() - let ey = y.GetEnumerator() - let mutable countx = 0 - let mutable county = 0 - while ex.MoveNext() do - countx <- countx + 1 - if ey.MoveNext() then - county <- county + 1 - ey.Current |> shouldEqual ex.Current - - while ex.MoveNext() do countx <- countx + 1 - while ey.MoveNext() do county <- county + 1 - if countx <> county then - failwithf $"Collections are of unequal lengths, expected length {countx}, actual length is {county}." diff --git a/tests/FSharp.Compiler.UnitTests/ExprTests.fs b/tests/service/ExprTests.fs similarity index 99% rename from tests/FSharp.Compiler.UnitTests/ExprTests.fs rename to tests/service/ExprTests.fs index 4f08cbf724d..8c8128eca18 100644 --- a/tests/FSharp.Compiler.UnitTests/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -1,13 +1,15 @@  #if INTERACTIVE #r "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0/FSharp.Compiler.Service.dll" -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/FSharp.Compiler.UnitTests/Debug/net472/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module FSharp.Compiler.Service.Tests.ExprTests #endif -open Xunit -open FSharp.Test +open NUnit.Framework +open FsUnit open System open System.IO open System.Text @@ -21,7 +23,6 @@ open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Symbols.FSharpExprPatterns open TestFramework -open Assert type FSharpCore = | FC45 @@ -723,8 +724,15 @@ let test{0}ToStringOperator (e1:{1}) = string e1 """ +let ignoreTestIfStackOverflowExpected () = +#if !NETFRAMEWORK && DEBUG + Assert.Ignore("Test is known to fail in DEBUG when not using NetFramework. Use RELEASE configuration or NetFramework to run it.") +#else + () +#endif + /// This test is run in unison with its optimized counterpart below -[] +[] let ``Test Unoptimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -859,7 +867,7 @@ let ``Test Unoptimized Declarations Project1`` () = () -[] +[] let ``Test Optimized Declarations Project1`` () = let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ] use _holder = cleanup @@ -1108,7 +1116,7 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi |> shouldPairwiseEqual expectedOptFiltered end -[] +[] let ``Test Operator Declarations for Byte`` () = let excludedTests = [ "testByteUnaryNegOperator"; @@ -1218,7 +1226,7 @@ let ``Test Operator Declarations for Byte`` () = testOperators "Byte" "byte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for SByte`` () = let excludedTests = [ ] @@ -1327,7 +1335,7 @@ let ``Test Operator Declarations for SByte`` () = testOperators "SByte" "sbyte" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int16`` () = let excludedTests = [ ] @@ -1436,7 +1444,7 @@ let ``Test Operator Declarations for Int16`` () = testOperators "Int16" "int16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt16`` () = let excludedTests = [ "testUInt16UnaryNegOperator"; @@ -1544,7 +1552,7 @@ let ``Test Operator Declarations for UInt16`` () = testOperators "UInt16" "uint16" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int`` () = let excludedTests = [ ] @@ -1653,7 +1661,7 @@ let ``Test Operator Declarations for Int`` () = testOperators "Int" "int" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int32`` () = let excludedTests = [ ] @@ -1763,7 +1771,7 @@ let ``Test Operator Declarations for Int32`` () = testOperators "Int32" "int32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt32`` () = let excludedTests = [ "testUInt32UnaryNegOperator"; @@ -1871,7 +1879,7 @@ let ``Test Operator Declarations for UInt32`` () = testOperators "UInt32" "uint32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Int64`` () = let excludedTests = [ ] @@ -1981,7 +1989,7 @@ let ``Test Operator Declarations for Int64`` () = testOperators "Int64" "int64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UInt64`` () = let excludedTests = [ "testUInt64UnaryNegOperator"; @@ -2089,7 +2097,7 @@ let ``Test Operator Declarations for UInt64`` () = testOperators "UInt64" "uint64" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for IntPtr`` () = let excludedTests = [ ] @@ -2198,7 +2206,7 @@ let ``Test Operator Declarations for IntPtr`` () = testOperators "IntPtr" "nativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for UIntPtr`` () = let excludedTests = [ "testUIntPtrUnaryNegOperator"; @@ -2306,7 +2314,7 @@ let ``Test Operator Declarations for UIntPtr`` () = testOperators "UIntPtr" "unativeint" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single`` () = let excludedTests = [ "testSingleBitwiseAndOperator"; @@ -2411,7 +2419,7 @@ let ``Test Operator Declarations for Single`` () = testOperators "Single" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Single with unit of measure`` () = let excludedTests = [ "testSingleUnitizedBitwiseAndOperator"; @@ -2516,7 +2524,7 @@ let ``Test Operator Declarations for Single with unit of measure`` () = testOperators "SingleUnitized" "float32" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Double`` () = let excludedTests = [ "testDoubleBitwiseAndOperator"; @@ -2622,7 +2630,7 @@ let ``Test Operator Declarations for Double`` () = testOperators "Double" "float" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal`` () = let excludedTests = [ // None of these are supported for decimals @@ -2721,7 +2729,7 @@ let ``Test Operator Declarations for Decimal`` () = testOperators "Decimal" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Decimal unitized`` () = let excludedTests = [ // None of these are supported for unitized decimals @@ -2802,7 +2810,7 @@ let ``Test Operator Declarations for Decimal unitized`` () = ] testOperators "DecimalUnitized" "decimal" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for Char`` () = let excludedTests = [ "testCharSubtractionOperator"; @@ -2899,7 +2907,7 @@ let ``Test Operator Declarations for Char`` () = testOperators "Char" "char" excludedTests expectedUnoptimized expectedOptimized -[] +[] let ``Test Operator Declarations for String`` () = let excludedTests = [ "testStringSubtractionOperator"; @@ -3189,12 +3197,10 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) = let createOptions() = createOptionsAux [fileSource1] [] -#if !NETFRAMEWORK && DEBUG -[] -#else -[] -#endif + +[] let ``Test expressions of declarations stress big expressions`` () = + ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3209,12 +3215,9 @@ let ``Test expressions of declarations stress big expressions`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore -#if !NETFRAMEWORK && DEBUG -[] -#else -[] -#endif +[] let ``Test expressions of optimized declarations stress big expressions`` () = + ignoreTestIfStackOverflowExpected () let cleanup, options = ProjectStressBigExpressions.createOptions() use _holder = cleanup let exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -3273,7 +3276,7 @@ let f8() = callXY (D()) (C()) let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses1`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3317,7 +3320,7 @@ let ``Test ProjectForWitnesses1`` () = |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses1 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses1.createOptions() use _holder = cleanup @@ -3397,7 +3400,7 @@ type MyNumberWrapper = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses2`` () = let cleanup, options = ProjectForWitnesses2.createOptions() use _holder = cleanup @@ -3452,7 +3455,7 @@ let s2 = sign p1 let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses3`` () = let cleanup, options = createOptionsAux [ ProjectForWitnesses3.fileSource1 ] ["--langversion:7.0"] use _holder = cleanup @@ -3483,7 +3486,7 @@ let ``Test ProjectForWitnesses3`` () = actual |> shouldPairwiseEqual expected -[] +[] let ``Test ProjectForWitnesses3 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses3.createOptions() use _holder = cleanup @@ -3546,7 +3549,7 @@ let isNullQuoted (ts : 't[]) = let createOptions() = createOptionsAux [fileSource1] ["--langversion:7.0"] -[] +[] let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = let cleanup, options = ProjectForWitnesses4.createOptions() use _holder = cleanup @@ -3556,7 +3559,7 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` () = for e in wholeProjectResults.Diagnostics do printfn "ProjectForWitnesses4 error: <<<%s>>>" e.Message - Assert.Equal(wholeProjectResults.Diagnostics.Length, 0) + Assert.AreEqual(wholeProjectResults.Diagnostics.Length, 0) wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 1 let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0] diff --git a/tests/service/FsUnit.fs b/tests/service/FsUnit.fs index b85c3dfa3ab..fc4964c574f 100644 --- a/tests/service/FsUnit.fs +++ b/tests/service/FsUnit.fs @@ -18,6 +18,24 @@ let equal x = EqualConstraint(x) /// like "should equal", but validates same-type let shouldEqual (x: 'a) (y: 'a) = Assert.AreEqual(x, y, sprintf "Expected: %A\nActual: %A" x y) +/// Same as 'shouldEqual' but goes pairwise over the collections. Lengths must be equal. +let shouldPairwiseEqual (x: seq<_>) (y: seq<_>) = + // using enumerators, because Seq.iter2 allows different lengths silently + let ex = x.GetEnumerator() + let ey = y.GetEnumerator() + let mutable countx = 0 + let mutable county = 0 + while ex.MoveNext() do + countx <- countx + 1 + if ey.MoveNext() then + county <- county + 1 + ey.Current |> shouldEqual ex.Current + + while ex.MoveNext() do countx <- countx + 1 + while ey.MoveNext() do county <- county + 1 + if countx <> county then + Assert.Fail("Collections are of unequal lengths, expected length {0}, actual length is {1}.", countx, county) + let notEqual x = NotConstraint(EqualConstraint(x)) let contain x = ContainsConstraint(x) From 6f5d3eb03b57a702ecd5ba0ecdbd73d97777cb8c Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 15:31:52 +0200 Subject: [PATCH 24/32] oops --- tests/FSharp.Test.Utilities/Assert.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index dfed4bf123e..7102715d984 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -3,7 +3,6 @@ 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) = @@ -15,6 +14,9 @@ module Assert = let inline shouldBe (expected : ^T) (actual : ^U) = actual.Should().Be(expected, "") |> ignore + let inline shouldEqual (expected : ^T) (actual : ^T) = + actual.Should().Be(expected, "") |> ignore + let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) = actual.Should().BeEmpty("") |> ignore From 98073fbe26d5401ebd6993ca1394e70990979a21 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 16:32:58 +0200 Subject: [PATCH 25/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 +++++++++---------- 3 files changed, 41 insertions(+), 49 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6b5150a568e..6fca44a1a53 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -64,9 +64,6 @@ CSharpProjectAnalysis.fs - - StructureTests.fs - PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index eb9ad85ec90..f73d795a427 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -65,9 +65,7 @@ CompilerService\CSharpProjectAnalysis.fs - - CompilerService\StructureTests.fs - + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/service/StructureTests.fs b/tests/FSharp.Compiler.UnitTests/StructureTests.fs similarity index 96% rename from tests/service/StructureTests.fs rename to tests/FSharp.Compiler.UnitTests/StructureTests.fs index 9d0541f579f..17a2508f43b 100644 --- a/tests/service/StructureTests.fs +++ b/tests/FSharp.Compiler.UnitTests/StructureTests.fs @@ -1,15 +1,12 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.StructureTests #endif open System.IO -open NUnit.Framework -open FSharp.Compiler.EditorServices +open Xunit open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -55,10 +52,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -71,7 +68,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -82,7 +79,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -93,7 +90,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -111,7 +108,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -133,7 +130,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -148,7 +145,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -194,7 +191,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -231,7 +228,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -260,7 +257,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -275,7 +272,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -293,7 +290,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -314,7 +311,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -330,7 +327,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -341,7 +338,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -352,7 +349,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -370,7 +367,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -386,7 +383,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -403,7 +400,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -412,7 +409,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -421,7 +418,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -431,7 +428,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -444,7 +441,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -453,7 +450,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -463,7 +460,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -472,7 +469,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -481,7 +478,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -498,7 +495,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -523,7 +520,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -545,7 +542,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -562,7 +559,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -577,7 +574,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -588,7 +585,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -598,7 +595,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -614,7 +611,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -638,7 +635,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -661,7 +658,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From 0c03c7a3e6e0a3e6fc8c031f3ef5ef639108cd16 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 17:47:49 +0200 Subject: [PATCH 26/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 --- .../FSharp.Compiler.UnitTests.fsproj | 4 +--- .../InteractiveCheckerTests.fs | 15 +++++++-------- 3 files changed, 8 insertions(+), 14 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/InteractiveCheckerTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6fca44a1a53..141b5aa47ed 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -55,9 +55,6 @@ PerfTests.fs - - InteractiveCheckerTests.fs - ExprTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index f73d795a427..f7c811e4352 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -56,9 +56,7 @@ CompilerService\PerfTests.fs - - CompilerService\InteractiveCheckerTests.fs - + CompilerService\ExprTests.fs diff --git a/tests/service/InteractiveCheckerTests.fs b/tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs similarity index 96% rename from tests/service/InteractiveCheckerTests.fs rename to tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs index d8494d490ed..86eb7fd6721 100644 --- a/tests/service/InteractiveCheckerTests.fs +++ b/tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs @@ -1,20 +1,19 @@  #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module FSharp.Compiler.Service.Tests.InteractiveChecker #endif -open NUnit.Framework -open FsUnit +open Xunit +open FSharp.Test open System open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax open FSharp.Compiler.Text open FSharp.Compiler.Text.Range +open Assert let internal longIdentToString (longIdent: LongIdent) = String.Join(".", longIdent |> List.map (fun ident -> ident.ToString())) @@ -70,7 +69,7 @@ let input = type Sample () = class end """ -[] +[] let ``Test ranges - namespace`` () = let res = parseAndExtractRanges input printfn "Test ranges - namespace, res = %A" res @@ -83,7 +82,7 @@ let input2 = type Sample () = class end """ -[] +[] let ``Test ranges - module`` () = let res = parseAndExtractRanges input2 printfn "Test ranges - module, res = %A" res @@ -96,7 +95,7 @@ let input3 = type Sample () = class end """ -[] +[] let ``Test ranges - global namespace`` () = let res = parseAndExtractRanges input3 printfn "Test ranges - global namespace, res = %A" res From c12343de2d6bb0d4b8563113d777f6336e0635e0 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 17:49:45 +0200 Subject: [PATCH 27/32] Revert "up" This reverts commit 98073fbe26d5401ebd6993ca1394e70990979a21. --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 ++++++++++--------- 3 files changed, 49 insertions(+), 41 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 141b5aa47ed..c8190a6b607 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -61,6 +61,9 @@ CSharpProjectAnalysis.fs + + StructureTests.fs + PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index f7c811e4352..a6c8aabf333 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -63,7 +63,9 @@ CompilerService\CSharpProjectAnalysis.fs - + + CompilerService\StructureTests.fs + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/StructureTests.fs b/tests/service/StructureTests.fs similarity index 96% rename from tests/FSharp.Compiler.UnitTests/StructureTests.fs rename to tests/service/StructureTests.fs index 17a2508f43b..9d0541f579f 100644 --- a/tests/FSharp.Compiler.UnitTests/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -1,12 +1,15 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.StructureTests #endif open System.IO -open Xunit +open NUnit.Framework +open FSharp.Compiler.EditorServices open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -52,10 +55,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -68,7 +71,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -79,7 +82,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -90,7 +93,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -108,7 +111,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -130,7 +133,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -145,7 +148,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -191,7 +194,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -228,7 +231,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -257,7 +260,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -272,7 +275,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -290,7 +293,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -311,7 +314,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -327,7 +330,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -338,7 +341,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -349,7 +352,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -367,7 +370,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -383,7 +386,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -400,7 +403,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -409,7 +412,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -418,7 +421,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -428,7 +431,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -441,7 +444,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -450,7 +453,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -460,7 +463,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -469,7 +472,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -478,7 +481,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -495,7 +498,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -520,7 +523,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -542,7 +545,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -559,7 +562,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -574,7 +577,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -585,7 +588,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -595,7 +598,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -611,7 +614,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -635,7 +638,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -658,7 +661,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From ba5e7ce3e644495c6c2668c4792739e4f86e0dfd Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 18:46:05 +0200 Subject: [PATCH 28/32] Update Symbols.fs test --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../Symbols.fs | 242 +++++++++--------- 3 files changed, 122 insertions(+), 127 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/Symbols.fs (84%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index c8190a6b607..d19a8108896 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -36,9 +36,6 @@ EditorTests.fs - - Symbols.fs - diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index a6c8aabf333..07a8388a8b2 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -34,9 +34,7 @@ CompilerService\Common.fs - - CompilerService\Symbols.fs - + CompilerService\EditorTests.fs diff --git a/tests/service/Symbols.fs b/tests/FSharp.Compiler.UnitTests/Symbols.fs similarity index 84% rename from tests/service/Symbols.fs rename to tests/FSharp.Compiler.UnitTests/Symbols.fs index 18a8b208fbf..b067dbd4b10 100644 --- a/tests/service/Symbols.fs +++ b/tests/FSharp.Compiler.UnitTests/Symbols.fs @@ -1,20 +1,17 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.Symbols #endif -open System -open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTrivia -open FsUnit -open NUnit.Framework +open FSharp.Test +open Xunit +open Assert module ActivePatterns = @@ -46,14 +43,14 @@ match "foo" with |> Array.filter (fun su -> su.Range.StartLine = line && su.Symbol :? FSharpActivePatternCase) |> Array.map (fun su -> su.Symbol :?> FSharpActivePatternCase) - [] + [] let ``Active pattern case indices`` () = let getIndices = Array.map (fun (case: FSharpActivePatternCase) -> case.Index) - getCaseUsages completePatternInput 7 |> getIndices |> shouldEqual [| 0; 1 |] - getCaseUsages partialPatternInput 7 |> getIndices |> shouldEqual [| 0 |] + getCaseUsages completePatternInput 7 |> getIndices |> shouldBeEquivalentTo [| 0; 1 |] + getCaseUsages partialPatternInput 7 |> getIndices |> shouldBeEquivalentTo [| 0 |] - [] + [] let ``Active pattern group names`` () = let getGroupName (case: FSharpActivePatternCase) = case.Group.Name.Value @@ -61,7 +58,7 @@ match "foo" with getCaseUsages partialPatternInput 7 |> Array.head |> getGroupName |> shouldEqual "|String|_|" module ExternDeclarations = - [] + [] let ``Access modifier`` () = let parseResults, checkResults = getParseAndCheckResults """ extern int a() @@ -76,8 +73,8 @@ extern int private c() |> List.zip decls |> List.iter (fun (actual, expected) -> match actual with - | SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> should equal expected - | decl -> Assert.Fail (sprintf "unexpected decl: %O" decl)) + | SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> shouldBe expected + | decl -> failwith (sprintf "unexpected decl: %O" decl)) [ "a", (true, false, false, false) "b", (true, false, false, false) @@ -87,10 +84,10 @@ extern int private c() | :? FSharpMemberOrFunctionOrValue as mfv -> let access = mfv.Accessibility (access.IsPublic, access.IsProtected, access.IsInternal, access.IsPrivate) - |> should equal expected - | _ -> Assert.Fail (sprintf "Couldn't get mfv: %s" name)) + |> shouldBe expected + | _ -> failwith (sprintf "Couldn't get mfv: %s" name)) - [] + [] let ``Range of attribute should be included in SynDecl.Let and SynBinding`` () = let parseResults = getParseResults @@ -104,9 +101,9 @@ extern int AccessibleChildren()""" ]) ])) -> assertRange (2, 0) (3, 31) ml assertRange (2, 0) (3, 31) mb - | _ -> Assert.Fail "Could not get valid AST" + | _ -> failwith "Could not get valid AST" - [] + [] let ``void keyword in extern`` () = let ast = getParseResults """ [] @@ -122,11 +119,11 @@ extern void setCallbridgeSupportTarget(IntPtr newTarget) SynType.LongIdent(SynLongIdent([unitIdent], [], [Some (IdentTrivia.OriginalNotation "void")])))))) ] , _) ]) ])) -> - Assert.AreEqual("unit", unitIdent.idText) + Assert.Equal("unit", unitIdent.idText) | _ -> - Assert.Fail $"Could not get valid AST, got {ast}" + failwith $"Could not get valid AST, got {ast}" - [] + [] let ``nativeptr in extern`` () = let ast = getParseResults """ [] @@ -146,11 +143,11 @@ extern int AccessibleChildren(int* x) ])) ], _) ]) ])) -> - Assert.AreEqual("nativeptr", nativeptrIdent.idText) + Assert.Equal("nativeptr", nativeptrIdent.idText) | _ -> - Assert.Fail $"Could not get valid AST, got {ast}" + failwith $"Could not get valid AST, got {ast}" - [] + [] let ``byref in extern`` () = let ast = getParseResults """ [] @@ -170,11 +167,11 @@ extern int AccessibleChildren(obj& x) ])) ], _) ]) ])) -> - Assert.AreEqual("byref", byrefIdent.idText) + Assert.Equal("byref", byrefIdent.idText) | _ -> - Assert.Fail $"Could not get valid AST, got {ast}" + failwith $"Could not get valid AST, got {ast}" - [] + [] let ``nativeint in extern`` () = let ast = getParseResults """ [] @@ -194,13 +191,13 @@ extern int AccessibleChildren(void* x) ])) ], _) ]) ])) -> - Assert.AreEqual("nativeint", nativeintIdent.idText) + Assert.Equal("nativeint", nativeintIdent.idText) | _ -> - Assert.Fail $"Could not get valid AST, got {ast}" + failwith $"Could not get valid AST, got {ast}" module XmlDocSig = - [] + [] let ``XmlDocSig of modules in namespace`` () = let source = """ namespace Ns1 @@ -221,7 +218,7 @@ module Mod1 = mod1val1.XmlDocSig |> shouldEqual "P:Ns1.Mod1.val1" mod2func2.XmlDocSig |> shouldEqual "M:Ns1.Mod1.Mod2.func2" - [] + [] let ``XmlDocSig of modules`` () = let source = """ module Mod1 @@ -242,7 +239,7 @@ module Mod2 = mod2func2.XmlDocSig |> shouldEqual "M:Mod1.Mod2.func2" module Attributes = - [] + [] let ``Emit conditional attributes`` () = let source = """ open System @@ -266,7 +263,7 @@ let x = 123 |> Option.iter (fun symbol -> symbol.Attributes.Count |> shouldEqual 1) module Types = - [] + [] let ``FSharpType.Print parent namespace qualifiers`` () = let _, checkResults = getParseAndCheckResults """ namespace Ns1.Ns2 @@ -297,11 +294,11 @@ type E = Ns1.Ns2.T match symbolUse.Symbol with | :? FSharpEntity as entity -> entity.AbbreviatedType.Format(symbolUse.DisplayContext) - |> should equal expectedPrintedType + |> shouldBe expectedPrintedType - | _ -> Assert.Fail (sprintf "Couldn't get entity: %s" symbolName)) + | _ -> failwith (sprintf "Couldn't get entity: %s" symbolName)) - [] + [] let ``FSharpType.Format can use prefix representations`` () = let _, checkResults = getParseAndCheckResults """ type 't folks = @@ -316,10 +313,10 @@ let tester: int folks = Cons(1, Nil) match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format (symbolUse.DisplayContext.WithPrefixGenericParameters()) - |> should equal prefixForm - | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entity) + |> shouldBe prefixForm + | _ -> failwith (sprintf "Couldn't get member: %s" entity) - [] + [] let ``FSharpType.Format can use suffix representations`` () = let _, checkResults = getParseAndCheckResults """ type Folks<'t> = @@ -334,10 +331,10 @@ let tester: Folks = Cons(1, Nil) match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format (symbolUse.DisplayContext.WithSuffixGenericParameters()) - |> should equal suffixForm - | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entity) + |> shouldBe suffixForm + | _ -> failwith (sprintf "Couldn't get member: %s" entity) - [] + [] let ``FSharpType.Format defaults to derived suffix representations`` () = let _, checkResults = getParseAndCheckResults """ type Folks<'t> = @@ -359,12 +356,15 @@ let tester2: int Group = [] match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format symbolUse.DisplayContext - |> should equal expectedTypeFormat - | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entityName) + |> shouldBe expectedTypeFormat + | _ -> failwith (sprintf "Couldn't get member: %s" entityName) ) - [] - let ``FsharpType.Format default to arrayNd shorthands for multidimensional arrays`` ([]rank) = + [] + [] + [] + [] + let ``FsharpType.Format default to arrayNd shorthands for multidimensional arrays`` rank = let commas = System.String(',', rank - 1) let _, checkResults = getParseAndCheckResults $""" let myArr : int[{commas}] = Unchecked.defaultOf<_>""" let symbolUse = findSymbolUseByName "myArr" checkResults @@ -373,9 +373,9 @@ let tester2: int Group = [] v.FullType.Format symbolUse.DisplayContext |> shouldEqual $"int array{rank}d" - | other -> Assert.Fail(sprintf "myArr was supposed to be a value, but is %A" other) + | other -> failwith(sprintf "myArr was supposed to be a value, but is %A" other) - [] + [] let ``Unfinished long ident type `` () = let _, checkResults = getParseAndCheckResults """ let g (s: string) = () @@ -422,15 +422,15 @@ let f2 b1 b2 b3 b4 b5 = | :? FSharpMemberOrFunctionOrValue as mfv -> match symbolTypes.TryGetValue(mfv.DisplayName) with | true, Some expectedType -> - mfv.FullType.TypeDefinition.DisplayName |> should equal expectedType + mfv.FullType.TypeDefinition.DisplayName |> shouldBe expectedType | true, None -> - mfv.FullType.IsGenericParameter |> should equal true - mfv.FullType.AllInterfaces.Count |> should equal 0 + mfv.FullType.IsGenericParameter |> shouldBe true + mfv.FullType.AllInterfaces.Count |> shouldBe 0 | _ -> () | _ -> () module FSharpMemberOrFunctionOrValue = - [] + [] let ``Both Set and Get symbols are present`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -450,21 +450,21 @@ type Foo = Assert.True mfv.IsProperty Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod - | symbol-> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + | symbol-> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" let getSymbol = findSymbolUseByName "get_X" checkResults match getSymbol.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - Assert.AreEqual(1, mfv.CurriedParameterGroups.[0].Count) - | symbol -> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + Assert.Equal(1, mfv.CurriedParameterGroups.[0].Count) + | symbol -> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" let setSymbol = findSymbolUseByName "set_X" checkResults match setSymbol.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - Assert.AreEqual(2, mfv.CurriedParameterGroups.[0].Count) - | symbol -> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + Assert.Equal(2, mfv.CurriedParameterGroups.[0].Count) + | symbol -> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" - [] + [] let ``AutoProperty with get,set has a single symbol!`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -486,7 +486,7 @@ type Foo = Assert.True (mfv.SetterMethod.CompiledName.StartsWith("set_")) assertRange (5, 15) (5, 29) autoPropertySymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpMemberOrFunctionOrValue" + | _ -> failwith "Symbol was not FSharpMemberOrFunctionOrValue" let getSymbol = checkResults.GetSymbolUsesAtLocation(5, 42, " member val AutoPropGetSet = 0 with get, set", ["get"]) @@ -503,11 +503,11 @@ type Foo = [ :? FSharpMemberOrFunctionOrValue as setVMfv :? FSharpMemberOrFunctionOrValue as setMfv ] -> Assert.True(getMfv.CompiledName.StartsWith("get_")) - Assert.AreEqual("v", setVMfv.DisplayName) + Assert.Equal("v", setVMfv.DisplayName) Assert.True(setMfv.CompiledName.StartsWith("set_")) - | _ -> Assert.Fail "Expected symbols to be FSharpMemberOrFunctionOrValue" + | _ -> failwith "Expected symbols to be FSharpMemberOrFunctionOrValue" - [] + [] let ``Single symbol is resolved for property`` () = let source = """ type X(y: string) = @@ -525,9 +525,9 @@ type X(y: string) = Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod assertRange (3, 15) (3, 16) mfv.SignatureLocation.Value - | _ -> Assert.Fail "Expected symbols" + | _ -> failwith "Expected symbols" - [] + [] let ``Multiple relevant symbols for type name`` () = let _, checkResults = getParseAndCheckResults """ // This is a generated file; the original input is 'FSInteractiveSettings.txt' @@ -551,12 +551,12 @@ type internal SR () = | [ :? FSharpMemberOrFunctionOrValue as cctor :? FSharpMemberOrFunctionOrValue as ctor :? FSharpEntity as entity ] -> - Assert.AreEqual(".cctor", cctor.CompiledName) - Assert.AreEqual(".ctor", ctor.CompiledName) - Assert.AreEqual("SR", entity.DisplayName) - | _ -> Assert.Fail "Expected symbols" + Assert.Equal(".cctor", cctor.CompiledName) + Assert.Equal(".ctor", ctor.CompiledName) + Assert.Equal("SR", entity.DisplayName) + | _ -> failwith "Expected symbols" - [] + [] let ``AutoProperty with get has get symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -573,9 +573,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertyGetterMethod assertRange (5, 15) (5, 18) mfv.SignatureLocation.Value - | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" + | symbols -> failwith $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with get has symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -593,9 +593,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertyGetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" + | symbols -> failwith $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with set has symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -615,9 +615,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertySetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" + | symbols -> failwith $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with set/get has property symbol`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -637,9 +637,9 @@ type Foo() = Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" + | symbols -> failwith $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property usage is reported properly`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -659,7 +659,7 @@ ignore (Foo().Name) |> List.exactlyOne let usages = checkResults.GetUsesOfSymbolInFile(propertySymbolUse) - Assert.AreEqual(3, usages.Length) + Assert.Equal(3, usages.Length) Assert.True usages.[0].IsFromDefinition Assert.True usages.[1].IsFromDefinition Assert.True usages.[2].IsFromUse @@ -669,23 +669,23 @@ module GetValSignatureText = let _, checkResults = getParseAndCheckResults source let symbolUseOpt = checkResults.GetSymbolUseAtLocation(lineNumber, column, line, [ identifier ]) match symbolUseOpt with - | None -> Assert.Fail "Expected symbol" + | None -> failwith "Expected symbol" | Some symbolUse -> match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> let expected = expected.Replace("\r", "") let signature = mfv.GetValSignatureText(symbolUse.DisplayContext, symbolUse.Range) - Assert.AreEqual(expected, signature.Value) - | symbol -> Assert.Fail $"Expected FSharpMemberOrFunctionOrValue, got %A{symbol}" + Assert.Equal(expected, signature.Value) + | symbol -> failwith $"Expected FSharpMemberOrFunctionOrValue, got %A{symbol}" - [] + [] let ``Signature text for let binding`` () = assertSignature "val a: b: int -> c: int -> int" "let a b c = b + c" (1, 4, "let a b c = b + c", "a") - [] + [] let ``Signature text for member binding`` () = assertSignature "member Bar: a: int -> b: int -> int" @@ -696,7 +696,7 @@ type Foo() = (3, 19, " member this.Bar (a:int) (b:int) : int = 0", "Bar") #if NETCOREAPP - [] + [] let ``Signature text for type with generic parameter in path`` () = assertSignature "new: builder: ImmutableArray<'T>.Builder -> ImmutableArrayViaBuilder<'T>" @@ -713,7 +713,7 @@ type ImmutableArrayViaBuilder<'T>(builder: ImmutableArray<'T>.Builder) = (8, 29, "type ImmutableArrayViaBuilder<'T>(builder: ImmutableArray<'T>.Builder) =", ".ctor") #endif - [] + [] let ``Includes attribute for parameter`` () = assertSignature "val a: [] c: int -> int" @@ -727,7 +727,7 @@ let a ([] c: int) : int = 0 """ (7, 5, "let a ([] c: int) : int = 0", "a") - [] + [] let ``Signature text for auto property`` () = assertSignature "member AutoPropGetSet: int with get, set" @@ -739,7 +739,7 @@ type Foo() = """ (5, 29, " member val AutoPropGetSet = 0 with get, set", "AutoPropGetSet") - [] + [] let ``Signature text for property`` () = assertSignature "member X: y: int -> string with get\nmember X: a: int -> float with set" @@ -754,7 +754,7 @@ type Foo() = (5, 14, " member _.X", "X") module AnonymousRecord = - [] + [] let ``Anonymous record copy-and-update symbols usage`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -769,9 +769,9 @@ let f (x: {| A: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.AreEqual(2, getSymbolUses.Length) + Assert.Equal(2, getSymbolUses.Length) - [] + [] let ``Anonymous anon record copy-and-update symbols usage`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -786,9 +786,9 @@ let f (x: {| A: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.AreEqual(2, getSymbolUses.Length) + Assert.Equal(2, getSymbolUses.Length) - [] + [] let ``Anonymous record copy-and-update symbols usages`` () = let _, checkResults = getParseAndCheckResults """ @@ -805,9 +805,9 @@ let f (r: {| A: int; C: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.AreEqual(4, getSymbolUses.Length) + Assert.Equal(4, getSymbolUses.Length) - [] + [] let ``Anonymous anon record copy-and-update symbols usages`` () = let _, checkResults = getParseAndCheckResults """ @@ -824,9 +824,9 @@ let f (r: {| A: int; C: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.AreEqual(5, getSymbolUses.Length) + Assert.Equal(5, getSymbolUses.Length) - [] + [] let ``Symbols for fields in nested copy-and-update are present`` () = let _, checkResults = getParseAndCheckResults """ type RecordA<'a> = { Foo: 'a; Bar: int; Zoo: RecordA<'a> } @@ -842,11 +842,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Zoo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Zoo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 44) (4, 47) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -855,11 +855,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Foo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Foo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 48) (4, 51) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -868,11 +868,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Zoo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Zoo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 57) (4, 60) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -881,11 +881,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Zoo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Zoo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 61) (4, 64) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -894,11 +894,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Bar", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Bar", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 65) (4, 68) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -907,11 +907,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Zoo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Zoo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 74) (4, 77) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -920,11 +920,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Bar", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Bar", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 78) (4, 81) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" + | _ -> failwith "Symbol was not FSharpField" let fieldSymbolUse = @@ -933,8 +933,8 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.AreEqual ("Foo", field.Name) - Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.Equal ("Foo", field.Name) + Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 87) (4, 90) fieldSymbolUse.Range - | _ -> Assert.Fail "Symbol was not FSharpField" \ No newline at end of file + | _ -> failwith "Symbol was not FSharpField" \ No newline at end of file From 3b0bd3bdfbce146d6a0ad80dafe59d74e718788f Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 8 Aug 2023 22:47:34 +0200 Subject: [PATCH 29/32] Revert "Update Symbols.fs" This reverts commit ba5e7ce3e644495c6c2668c4792739e4f86e0dfd. Revert "Revert "up"" This reverts commit c12343de2d6bb0d4b8563113d777f6336e0635e0. Revert "up" This reverts commit 0c03c7a3e6e0a3e6fc8c031f3ef5ef639108cd16. --- .../FSharp.Compiler.Service.Tests.fsproj | 9 +- .../FSharp.Compiler.UnitTests.fsproj | 12 +- .../StructureTests.fs | 83 +++--- .../InteractiveCheckerTests.fs | 15 +- .../Symbols.fs | 242 +++++++++--------- 5 files changed, 182 insertions(+), 179 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/StructureTests.fs (96%) rename tests/{FSharp.Compiler.UnitTests => service}/InteractiveCheckerTests.fs (96%) rename tests/{FSharp.Compiler.UnitTests => service}/Symbols.fs (84%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index d19a8108896..6fca44a1a53 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -36,6 +36,9 @@ EditorTests.fs + + Symbols.fs + @@ -52,15 +55,15 @@ PerfTests.fs + + InteractiveCheckerTests.fs + ExprTests.fs CSharpProjectAnalysis.fs - - StructureTests.fs - PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 07a8388a8b2..f73d795a427 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -34,7 +34,9 @@ CompilerService\Common.fs - + + CompilerService\Symbols.fs + CompilerService\EditorTests.fs @@ -54,16 +56,16 @@ CompilerService\PerfTests.fs - + + CompilerService\InteractiveCheckerTests.fs + CompilerService\ExprTests.fs CompilerService\CSharpProjectAnalysis.fs - - CompilerService\StructureTests.fs - + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/service/StructureTests.fs b/tests/FSharp.Compiler.UnitTests/StructureTests.fs similarity index 96% rename from tests/service/StructureTests.fs rename to tests/FSharp.Compiler.UnitTests/StructureTests.fs index 9d0541f579f..17a2508f43b 100644 --- a/tests/service/StructureTests.fs +++ b/tests/FSharp.Compiler.UnitTests/StructureTests.fs @@ -1,15 +1,12 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.StructureTests #endif open System.IO -open NUnit.Framework -open FSharp.Compiler.EditorServices +open Xunit open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -55,10 +52,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -71,7 +68,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -82,7 +79,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -93,7 +90,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -111,7 +108,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -133,7 +130,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -148,7 +145,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -194,7 +191,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -231,7 +228,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -260,7 +257,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -275,7 +272,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -293,7 +290,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -314,7 +311,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -330,7 +327,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -341,7 +338,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -352,7 +349,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -370,7 +367,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -386,7 +383,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -403,7 +400,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -412,7 +409,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -421,7 +418,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -431,7 +428,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -444,7 +441,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -453,7 +450,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -463,7 +460,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -472,7 +469,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -481,7 +478,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -498,7 +495,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -523,7 +520,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -545,7 +542,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -562,7 +559,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -577,7 +574,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -588,7 +585,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -598,7 +595,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -614,7 +611,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -638,7 +635,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -661,7 +658,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = diff --git a/tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs b/tests/service/InteractiveCheckerTests.fs similarity index 96% rename from tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs rename to tests/service/InteractiveCheckerTests.fs index 86eb7fd6721..d8494d490ed 100644 --- a/tests/FSharp.Compiler.UnitTests/InteractiveCheckerTests.fs +++ b/tests/service/InteractiveCheckerTests.fs @@ -1,19 +1,20 @@  #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module FSharp.Compiler.Service.Tests.InteractiveChecker #endif -open Xunit -open FSharp.Test +open NUnit.Framework +open FsUnit open System open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax open FSharp.Compiler.Text open FSharp.Compiler.Text.Range -open Assert let internal longIdentToString (longIdent: LongIdent) = String.Join(".", longIdent |> List.map (fun ident -> ident.ToString())) @@ -69,7 +70,7 @@ let input = type Sample () = class end """ -[] +[] let ``Test ranges - namespace`` () = let res = parseAndExtractRanges input printfn "Test ranges - namespace, res = %A" res @@ -82,7 +83,7 @@ let input2 = type Sample () = class end """ -[] +[] let ``Test ranges - module`` () = let res = parseAndExtractRanges input2 printfn "Test ranges - module, res = %A" res @@ -95,7 +96,7 @@ let input3 = type Sample () = class end """ -[] +[] let ``Test ranges - global namespace`` () = let res = parseAndExtractRanges input3 printfn "Test ranges - global namespace, res = %A" res diff --git a/tests/FSharp.Compiler.UnitTests/Symbols.fs b/tests/service/Symbols.fs similarity index 84% rename from tests/FSharp.Compiler.UnitTests/Symbols.fs rename to tests/service/Symbols.fs index b067dbd4b10..18a8b208fbf 100644 --- a/tests/FSharp.Compiler.UnitTests/Symbols.fs +++ b/tests/service/Symbols.fs @@ -1,17 +1,20 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.Symbols #endif +open System +open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTrivia -open FSharp.Test -open Xunit -open Assert +open FsUnit +open NUnit.Framework module ActivePatterns = @@ -43,14 +46,14 @@ match "foo" with |> Array.filter (fun su -> su.Range.StartLine = line && su.Symbol :? FSharpActivePatternCase) |> Array.map (fun su -> su.Symbol :?> FSharpActivePatternCase) - [] + [] let ``Active pattern case indices`` () = let getIndices = Array.map (fun (case: FSharpActivePatternCase) -> case.Index) - getCaseUsages completePatternInput 7 |> getIndices |> shouldBeEquivalentTo [| 0; 1 |] - getCaseUsages partialPatternInput 7 |> getIndices |> shouldBeEquivalentTo [| 0 |] + getCaseUsages completePatternInput 7 |> getIndices |> shouldEqual [| 0; 1 |] + getCaseUsages partialPatternInput 7 |> getIndices |> shouldEqual [| 0 |] - [] + [] let ``Active pattern group names`` () = let getGroupName (case: FSharpActivePatternCase) = case.Group.Name.Value @@ -58,7 +61,7 @@ match "foo" with getCaseUsages partialPatternInput 7 |> Array.head |> getGroupName |> shouldEqual "|String|_|" module ExternDeclarations = - [] + [] let ``Access modifier`` () = let parseResults, checkResults = getParseAndCheckResults """ extern int a() @@ -73,8 +76,8 @@ extern int private c() |> List.zip decls |> List.iter (fun (actual, expected) -> match actual with - | SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> shouldBe expected - | decl -> failwith (sprintf "unexpected decl: %O" decl)) + | SynModuleDecl.Let (_, [SynBinding (accessibility = access)], _) -> Option.map string access |> should equal expected + | decl -> Assert.Fail (sprintf "unexpected decl: %O" decl)) [ "a", (true, false, false, false) "b", (true, false, false, false) @@ -84,10 +87,10 @@ extern int private c() | :? FSharpMemberOrFunctionOrValue as mfv -> let access = mfv.Accessibility (access.IsPublic, access.IsProtected, access.IsInternal, access.IsPrivate) - |> shouldBe expected - | _ -> failwith (sprintf "Couldn't get mfv: %s" name)) + |> should equal expected + | _ -> Assert.Fail (sprintf "Couldn't get mfv: %s" name)) - [] + [] let ``Range of attribute should be included in SynDecl.Let and SynBinding`` () = let parseResults = getParseResults @@ -101,9 +104,9 @@ extern int AccessibleChildren()""" ]) ])) -> assertRange (2, 0) (3, 31) ml assertRange (2, 0) (3, 31) mb - | _ -> failwith "Could not get valid AST" + | _ -> Assert.Fail "Could not get valid AST" - [] + [] let ``void keyword in extern`` () = let ast = getParseResults """ [] @@ -119,11 +122,11 @@ extern void setCallbridgeSupportTarget(IntPtr newTarget) SynType.LongIdent(SynLongIdent([unitIdent], [], [Some (IdentTrivia.OriginalNotation "void")])))))) ] , _) ]) ])) -> - Assert.Equal("unit", unitIdent.idText) + Assert.AreEqual("unit", unitIdent.idText) | _ -> - failwith $"Could not get valid AST, got {ast}" + Assert.Fail $"Could not get valid AST, got {ast}" - [] + [] let ``nativeptr in extern`` () = let ast = getParseResults """ [] @@ -143,11 +146,11 @@ extern int AccessibleChildren(int* x) ])) ], _) ]) ])) -> - Assert.Equal("nativeptr", nativeptrIdent.idText) + Assert.AreEqual("nativeptr", nativeptrIdent.idText) | _ -> - failwith $"Could not get valid AST, got {ast}" + Assert.Fail $"Could not get valid AST, got {ast}" - [] + [] let ``byref in extern`` () = let ast = getParseResults """ [] @@ -167,11 +170,11 @@ extern int AccessibleChildren(obj& x) ])) ], _) ]) ])) -> - Assert.Equal("byref", byrefIdent.idText) + Assert.AreEqual("byref", byrefIdent.idText) | _ -> - failwith $"Could not get valid AST, got {ast}" + Assert.Fail $"Could not get valid AST, got {ast}" - [] + [] let ``nativeint in extern`` () = let ast = getParseResults """ [] @@ -191,13 +194,13 @@ extern int AccessibleChildren(void* x) ])) ], _) ]) ])) -> - Assert.Equal("nativeint", nativeintIdent.idText) + Assert.AreEqual("nativeint", nativeintIdent.idText) | _ -> - failwith $"Could not get valid AST, got {ast}" + Assert.Fail $"Could not get valid AST, got {ast}" module XmlDocSig = - [] + [] let ``XmlDocSig of modules in namespace`` () = let source = """ namespace Ns1 @@ -218,7 +221,7 @@ module Mod1 = mod1val1.XmlDocSig |> shouldEqual "P:Ns1.Mod1.val1" mod2func2.XmlDocSig |> shouldEqual "M:Ns1.Mod1.Mod2.func2" - [] + [] let ``XmlDocSig of modules`` () = let source = """ module Mod1 @@ -239,7 +242,7 @@ module Mod2 = mod2func2.XmlDocSig |> shouldEqual "M:Mod1.Mod2.func2" module Attributes = - [] + [] let ``Emit conditional attributes`` () = let source = """ open System @@ -263,7 +266,7 @@ let x = 123 |> Option.iter (fun symbol -> symbol.Attributes.Count |> shouldEqual 1) module Types = - [] + [] let ``FSharpType.Print parent namespace qualifiers`` () = let _, checkResults = getParseAndCheckResults """ namespace Ns1.Ns2 @@ -294,11 +297,11 @@ type E = Ns1.Ns2.T match symbolUse.Symbol with | :? FSharpEntity as entity -> entity.AbbreviatedType.Format(symbolUse.DisplayContext) - |> shouldBe expectedPrintedType + |> should equal expectedPrintedType - | _ -> failwith (sprintf "Couldn't get entity: %s" symbolName)) + | _ -> Assert.Fail (sprintf "Couldn't get entity: %s" symbolName)) - [] + [] let ``FSharpType.Format can use prefix representations`` () = let _, checkResults = getParseAndCheckResults """ type 't folks = @@ -313,10 +316,10 @@ let tester: int folks = Cons(1, Nil) match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format (symbolUse.DisplayContext.WithPrefixGenericParameters()) - |> shouldBe prefixForm - | _ -> failwith (sprintf "Couldn't get member: %s" entity) + |> should equal prefixForm + | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entity) - [] + [] let ``FSharpType.Format can use suffix representations`` () = let _, checkResults = getParseAndCheckResults """ type Folks<'t> = @@ -331,10 +334,10 @@ let tester: Folks = Cons(1, Nil) match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format (symbolUse.DisplayContext.WithSuffixGenericParameters()) - |> shouldBe suffixForm - | _ -> failwith (sprintf "Couldn't get member: %s" entity) + |> should equal suffixForm + | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entity) - [] + [] let ``FSharpType.Format defaults to derived suffix representations`` () = let _, checkResults = getParseAndCheckResults """ type Folks<'t> = @@ -356,15 +359,12 @@ let tester2: int Group = [] match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as v -> v.FullType.Format symbolUse.DisplayContext - |> shouldBe expectedTypeFormat - | _ -> failwith (sprintf "Couldn't get member: %s" entityName) + |> should equal expectedTypeFormat + | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entityName) ) - [] - [] - [] - [] - let ``FsharpType.Format default to arrayNd shorthands for multidimensional arrays`` rank = + [] + let ``FsharpType.Format default to arrayNd shorthands for multidimensional arrays`` ([]rank) = let commas = System.String(',', rank - 1) let _, checkResults = getParseAndCheckResults $""" let myArr : int[{commas}] = Unchecked.defaultOf<_>""" let symbolUse = findSymbolUseByName "myArr" checkResults @@ -373,9 +373,9 @@ let tester2: int Group = [] v.FullType.Format symbolUse.DisplayContext |> shouldEqual $"int array{rank}d" - | other -> failwith(sprintf "myArr was supposed to be a value, but is %A" other) + | other -> Assert.Fail(sprintf "myArr was supposed to be a value, but is %A" other) - [] + [] let ``Unfinished long ident type `` () = let _, checkResults = getParseAndCheckResults """ let g (s: string) = () @@ -422,15 +422,15 @@ let f2 b1 b2 b3 b4 b5 = | :? FSharpMemberOrFunctionOrValue as mfv -> match symbolTypes.TryGetValue(mfv.DisplayName) with | true, Some expectedType -> - mfv.FullType.TypeDefinition.DisplayName |> shouldBe expectedType + mfv.FullType.TypeDefinition.DisplayName |> should equal expectedType | true, None -> - mfv.FullType.IsGenericParameter |> shouldBe true - mfv.FullType.AllInterfaces.Count |> shouldBe 0 + mfv.FullType.IsGenericParameter |> should equal true + mfv.FullType.AllInterfaces.Count |> should equal 0 | _ -> () | _ -> () module FSharpMemberOrFunctionOrValue = - [] + [] let ``Both Set and Get symbols are present`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -450,21 +450,21 @@ type Foo = Assert.True mfv.IsProperty Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod - | symbol-> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + | symbol-> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" let getSymbol = findSymbolUseByName "get_X" checkResults match getSymbol.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - Assert.Equal(1, mfv.CurriedParameterGroups.[0].Count) - | symbol -> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + Assert.AreEqual(1, mfv.CurriedParameterGroups.[0].Count) + | symbol -> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" let setSymbol = findSymbolUseByName "set_X" checkResults match setSymbol.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - Assert.Equal(2, mfv.CurriedParameterGroups.[0].Count) - | symbol -> failwith $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" + Assert.AreEqual(2, mfv.CurriedParameterGroups.[0].Count) + | symbol -> Assert.Fail $"Expected {symbol} to be FSharpMemberOrFunctionOrValue" - [] + [] let ``AutoProperty with get,set has a single symbol!`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -486,7 +486,7 @@ type Foo = Assert.True (mfv.SetterMethod.CompiledName.StartsWith("set_")) assertRange (5, 15) (5, 29) autoPropertySymbolUse.Range - | _ -> failwith "Symbol was not FSharpMemberOrFunctionOrValue" + | _ -> Assert.Fail "Symbol was not FSharpMemberOrFunctionOrValue" let getSymbol = checkResults.GetSymbolUsesAtLocation(5, 42, " member val AutoPropGetSet = 0 with get, set", ["get"]) @@ -503,11 +503,11 @@ type Foo = [ :? FSharpMemberOrFunctionOrValue as setVMfv :? FSharpMemberOrFunctionOrValue as setMfv ] -> Assert.True(getMfv.CompiledName.StartsWith("get_")) - Assert.Equal("v", setVMfv.DisplayName) + Assert.AreEqual("v", setVMfv.DisplayName) Assert.True(setMfv.CompiledName.StartsWith("set_")) - | _ -> failwith "Expected symbols to be FSharpMemberOrFunctionOrValue" + | _ -> Assert.Fail "Expected symbols to be FSharpMemberOrFunctionOrValue" - [] + [] let ``Single symbol is resolved for property`` () = let source = """ type X(y: string) = @@ -525,9 +525,9 @@ type X(y: string) = Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod assertRange (3, 15) (3, 16) mfv.SignatureLocation.Value - | _ -> failwith "Expected symbols" + | _ -> Assert.Fail "Expected symbols" - [] + [] let ``Multiple relevant symbols for type name`` () = let _, checkResults = getParseAndCheckResults """ // This is a generated file; the original input is 'FSInteractiveSettings.txt' @@ -551,12 +551,12 @@ type internal SR () = | [ :? FSharpMemberOrFunctionOrValue as cctor :? FSharpMemberOrFunctionOrValue as ctor :? FSharpEntity as entity ] -> - Assert.Equal(".cctor", cctor.CompiledName) - Assert.Equal(".ctor", ctor.CompiledName) - Assert.Equal("SR", entity.DisplayName) - | _ -> failwith "Expected symbols" + Assert.AreEqual(".cctor", cctor.CompiledName) + Assert.AreEqual(".ctor", ctor.CompiledName) + Assert.AreEqual("SR", entity.DisplayName) + | _ -> Assert.Fail "Expected symbols" - [] + [] let ``AutoProperty with get has get symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace Foo @@ -573,9 +573,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertyGetterMethod assertRange (5, 15) (5, 18) mfv.SignatureLocation.Value - | symbols -> failwith $"Unexpected symbols, got %A{symbols}" + | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with get has symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -593,9 +593,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertyGetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> failwith $"Unexpected symbols, got %A{symbols}" + | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with set has symbol attached to property name`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -615,9 +615,9 @@ type Foo() = | [ :? FSharpMemberOrFunctionOrValue as mfv ] -> Assert.True mfv.IsPropertySetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> failwith $"Unexpected symbols, got %A{symbols}" + | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property with set/get has property symbol`` () = let _, checkResults = getParseAndCheckResults """ namespace F @@ -637,9 +637,9 @@ type Foo() = Assert.True mfv.HasGetterMethod Assert.True mfv.HasSetterMethod assertRange (6, 16) (6, 21) mfv.SignatureLocation.Value - | symbols -> failwith $"Unexpected symbols, got %A{symbols}" + | symbols -> Assert.Fail $"Unexpected symbols, got %A{symbols}" - [] + [] let ``Property usage is reported properly`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -659,7 +659,7 @@ ignore (Foo().Name) |> List.exactlyOne let usages = checkResults.GetUsesOfSymbolInFile(propertySymbolUse) - Assert.Equal(3, usages.Length) + Assert.AreEqual(3, usages.Length) Assert.True usages.[0].IsFromDefinition Assert.True usages.[1].IsFromDefinition Assert.True usages.[2].IsFromUse @@ -669,23 +669,23 @@ module GetValSignatureText = let _, checkResults = getParseAndCheckResults source let symbolUseOpt = checkResults.GetSymbolUseAtLocation(lineNumber, column, line, [ identifier ]) match symbolUseOpt with - | None -> failwith "Expected symbol" + | None -> Assert.Fail "Expected symbol" | Some symbolUse -> match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> let expected = expected.Replace("\r", "") let signature = mfv.GetValSignatureText(symbolUse.DisplayContext, symbolUse.Range) - Assert.Equal(expected, signature.Value) - | symbol -> failwith $"Expected FSharpMemberOrFunctionOrValue, got %A{symbol}" + Assert.AreEqual(expected, signature.Value) + | symbol -> Assert.Fail $"Expected FSharpMemberOrFunctionOrValue, got %A{symbol}" - [] + [] let ``Signature text for let binding`` () = assertSignature "val a: b: int -> c: int -> int" "let a b c = b + c" (1, 4, "let a b c = b + c", "a") - [] + [] let ``Signature text for member binding`` () = assertSignature "member Bar: a: int -> b: int -> int" @@ -696,7 +696,7 @@ type Foo() = (3, 19, " member this.Bar (a:int) (b:int) : int = 0", "Bar") #if NETCOREAPP - [] + [] let ``Signature text for type with generic parameter in path`` () = assertSignature "new: builder: ImmutableArray<'T>.Builder -> ImmutableArrayViaBuilder<'T>" @@ -713,7 +713,7 @@ type ImmutableArrayViaBuilder<'T>(builder: ImmutableArray<'T>.Builder) = (8, 29, "type ImmutableArrayViaBuilder<'T>(builder: ImmutableArray<'T>.Builder) =", ".ctor") #endif - [] + [] let ``Includes attribute for parameter`` () = assertSignature "val a: [] c: int -> int" @@ -727,7 +727,7 @@ let a ([] c: int) : int = 0 """ (7, 5, "let a ([] c: int) : int = 0", "a") - [] + [] let ``Signature text for auto property`` () = assertSignature "member AutoPropGetSet: int with get, set" @@ -739,7 +739,7 @@ type Foo() = """ (5, 29, " member val AutoPropGetSet = 0 with get, set", "AutoPropGetSet") - [] + [] let ``Signature text for property`` () = assertSignature "member X: y: int -> string with get\nmember X: a: int -> float with set" @@ -754,7 +754,7 @@ type Foo() = (5, 14, " member _.X", "X") module AnonymousRecord = - [] + [] let ``Anonymous record copy-and-update symbols usage`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -769,9 +769,9 @@ let f (x: {| A: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.Equal(2, getSymbolUses.Length) + Assert.AreEqual(2, getSymbolUses.Length) - [] + [] let ``Anonymous anon record copy-and-update symbols usage`` () = let _, checkResults = getParseAndCheckResults """ module X @@ -786,9 +786,9 @@ let f (x: {| A: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.Equal(2, getSymbolUses.Length) + Assert.AreEqual(2, getSymbolUses.Length) - [] + [] let ``Anonymous record copy-and-update symbols usages`` () = let _, checkResults = getParseAndCheckResults """ @@ -805,9 +805,9 @@ let f (r: {| A: int; C: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.Equal(4, getSymbolUses.Length) + Assert.AreEqual(4, getSymbolUses.Length) - [] + [] let ``Anonymous anon record copy-and-update symbols usages`` () = let _, checkResults = getParseAndCheckResults """ @@ -824,9 +824,9 @@ let f (r: {| A: int; C: int |}) = | :? FSharpField as f when f.IsAnonRecordField -> true | _ -> false) - Assert.Equal(5, getSymbolUses.Length) + Assert.AreEqual(5, getSymbolUses.Length) - [] + [] let ``Symbols for fields in nested copy-and-update are present`` () = let _, checkResults = getParseAndCheckResults """ type RecordA<'a> = { Foo: 'a; Bar: int; Zoo: RecordA<'a> } @@ -842,11 +842,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Zoo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Zoo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 44) (4, 47) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -855,11 +855,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Foo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Foo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 48) (4, 51) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -868,11 +868,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Zoo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Zoo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 57) (4, 60) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -881,11 +881,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Zoo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Zoo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 61) (4, 64) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -894,11 +894,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Bar", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Bar", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 65) (4, 68) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -907,11 +907,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Zoo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Zoo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 74) (4, 77) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -920,11 +920,11 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Bar", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Bar", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 78) (4, 81) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" + | _ -> Assert.Fail "Symbol was not FSharpField" let fieldSymbolUse = @@ -933,8 +933,8 @@ let nestedFunc (a: RecordA) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba match fieldSymbolUse.Symbol with | :? FSharpField as field -> - Assert.Equal ("Foo", field.Name) - Assert.Equal ("RecordA`1", field.DeclaringEntity.Value.CompiledName) + Assert.AreEqual ("Foo", field.Name) + Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName) assertRange (4, 87) (4, 90) fieldSymbolUse.Range - | _ -> failwith "Symbol was not FSharpField" \ No newline at end of file + | _ -> Assert.Fail "Symbol was not FSharpField" \ No newline at end of file From 263f7d6d2e4abaf83f09227d796893708f59d50c Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 9 Aug 2023 13:28:57 +0200 Subject: [PATCH 30/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 ++++++++++--------- 3 files changed, 49 insertions(+), 41 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6fca44a1a53..6b5150a568e 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -64,6 +64,9 @@ CSharpProjectAnalysis.fs + + StructureTests.fs + PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index f73d795a427..eb9ad85ec90 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -65,7 +65,9 @@ CompilerService\CSharpProjectAnalysis.fs - + + CompilerService\StructureTests.fs + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/StructureTests.fs b/tests/service/StructureTests.fs similarity index 96% rename from tests/FSharp.Compiler.UnitTests/StructureTests.fs rename to tests/service/StructureTests.fs index 17a2508f43b..9d0541f579f 100644 --- a/tests/FSharp.Compiler.UnitTests/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -1,12 +1,15 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.StructureTests #endif open System.IO -open Xunit +open NUnit.Framework +open FSharp.Compiler.EditorServices open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -52,10 +55,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -68,7 +71,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -79,7 +82,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -90,7 +93,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -108,7 +111,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -130,7 +133,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -145,7 +148,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -191,7 +194,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -228,7 +231,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -257,7 +260,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -272,7 +275,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -290,7 +293,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -311,7 +314,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -327,7 +330,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -338,7 +341,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -349,7 +352,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -367,7 +370,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -383,7 +386,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -400,7 +403,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -409,7 +412,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -418,7 +421,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -428,7 +431,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -441,7 +444,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -450,7 +453,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -460,7 +463,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -469,7 +472,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -478,7 +481,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -495,7 +498,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -520,7 +523,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -542,7 +545,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -559,7 +562,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -574,7 +577,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -585,7 +588,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -595,7 +598,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -611,7 +614,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -635,7 +638,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -658,7 +661,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From d25225b681c4c96ab614ba5f2e8ece7d34431c9a Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 9 Aug 2023 15:40:38 +0200 Subject: [PATCH 31/32] Revert "up" This reverts commit 263f7d6d2e4abaf83f09227d796893708f59d50c. --- .../FSharp.Compiler.Service.Tests.fsproj | 3 - .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../StructureTests.fs | 83 +++++++++---------- 3 files changed, 41 insertions(+), 49 deletions(-) rename tests/{service => FSharp.Compiler.UnitTests}/StructureTests.fs (96%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6b5150a568e..6fca44a1a53 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -64,9 +64,6 @@ CSharpProjectAnalysis.fs - - StructureTests.fs - PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index eb9ad85ec90..f73d795a427 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -65,9 +65,7 @@ CompilerService\CSharpProjectAnalysis.fs - - CompilerService\StructureTests.fs - + CompilerService\AssemblyContentProviderTests.fs diff --git a/tests/service/StructureTests.fs b/tests/FSharp.Compiler.UnitTests/StructureTests.fs similarity index 96% rename from tests/service/StructureTests.fs rename to tests/FSharp.Compiler.UnitTests/StructureTests.fs index 9d0541f579f..17a2508f43b 100644 --- a/tests/service/StructureTests.fs +++ b/tests/FSharp.Compiler.UnitTests/StructureTests.fs @@ -1,15 +1,12 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" -#load "FsUnit.fs" -#load "Common.fs" +#r "../../artifacts/bin/fcs/net461/xunit.dll" #else module Tests.Service.StructureTests #endif open System.IO -open NUnit.Framework -open FSharp.Compiler.EditorServices +open Xunit open FSharp.Compiler.EditorServices.Structure open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text @@ -55,10 +52,10 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = printfn "AST:\n%+A" ast reraise() -[] +[] let ``empty file``() = "" => [] -[] +[] let ``nested module``() = """ module MyModule = @@ -71,7 +68,7 @@ module Module = => [ (2, 0, 3, 6), (2, 15, 3, 6) (5, 0, 7, 6), (6, 13, 7, 6) ] -[] +[] let ``module with multiline function``() = """ module MyModule = @@ -82,7 +79,7 @@ module MyModule = (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] -[] +[] let ``DU``() = """ type Color = @@ -93,7 +90,7 @@ type Color = => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] -[] +[] let ``DU with interface``() = """ type Color = @@ -111,7 +108,7 @@ type Color = (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] -[] +[] let ``record with interface``() = """ type Color = @@ -133,7 +130,7 @@ type Color = (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] -[] +[] let ``type with a do block``() = """ type Color() = // 2 @@ -148,7 +145,7 @@ type Color() = // 2 (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] -[] +[] let ``complex outlining test``() = """ module MyModule = // 2 @@ -194,7 +191,7 @@ module MyModule = // 2 (26, 23, 27, 63), (26, 35, 27, 63) ] -[] +[] let ``open statements``() = """ open M @@ -231,7 +228,7 @@ open H (17, 8, 18, 14), (17, 8, 18, 14) (21, 0, 26, 6), (21, 0, 26, 6) ] -[] +[] let ``hash directives``() = """ #r @"a" @@ -260,7 +257,7 @@ let x = 1 => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] -[] +[] let ``nested let bindings``() = """ let f x = // 2 @@ -275,7 +272,7 @@ let f x = // 2 (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] -[] +[] let ``match``() = """ match None with // 2 @@ -293,7 +290,7 @@ match None with // 2 (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] -[] +[] let ``matchbang``() = """ async { // 2 @@ -314,7 +311,7 @@ async { // 2 (7, 8, 11, 14), (7, 23, 11, 14) (10, 12, 11, 14), (9, 14, 11, 14) ] -[] +[] let ``computation expressions``() = """ seq { // 2 @@ -330,7 +327,7 @@ seq { // 2 (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] -[] +[] let ``list``() = """ let _ = @@ -341,7 +338,7 @@ let _ = (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] -[] +[] let ``object expressions``() = """ let _ = @@ -352,7 +349,7 @@ let _ = (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] -[] +[] let ``try - with``() = """ try // 2 @@ -370,7 +367,7 @@ with _ -> // 5 (6, 4, 8, 6), (5, 6, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``try - finally``() = """ try // 2 @@ -386,7 +383,7 @@ finally // 5 (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] -[] +[] let ``if - then - else``() = """ if true then @@ -403,7 +400,7 @@ else (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] -[] +[] let ``code quotation``() = """ <@ @@ -412,7 +409,7 @@ let ``code quotation``() = """ => [ (2, 0, 4, 10), (2, 2, 4, 8) ] -[] +[] let ``raw code quotation``() = """ <@@ @@ -421,7 +418,7 @@ let ``raw code quotation``() = """ => [ (2, 0, 4, 11), (2, 3, 4, 8) ] -[] +[] let ``match lambda aka function``() = """ function @@ -431,7 +428,7 @@ function => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] -[] +[] let ``match guarded clause``() = """ let matchwith num = @@ -444,7 +441,7 @@ let matchwith num = (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] -[] +[] let ``for loop``() = """ for x = 100 downto 10 do @@ -453,7 +450,7 @@ for x = 100 downto 10 do """ => [ (2, 0, 4, 6), (2, 0, 4, 6) ] -[] +[] let ``for each``() = """ for x in 0 .. 100 -> @@ -463,7 +460,7 @@ for x in 0 .. 100 -> => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] -[] +[] let ``tuple``() = """ ( 20340 @@ -472,7 +469,7 @@ let ``tuple``() = """ => [ (2, 2, 4, 8), (2, 2, 4, 8) ] -[] +[] let ``do!``() = """ do! @@ -481,7 +478,7 @@ do! """ => [ (2, 0, 4, 18), (2, 3, 4, 18) ] -[] +[] let ``cexpr yield yield!``() = """ cexpr{ @@ -498,7 +495,7 @@ cexpr{ (4, 8, 8, 17), (4, 14, 8, 16) (5, 20, 7, 26), (5, 20, 7, 26) ] -[] +[] let ``XML doc comments``() = """ /// Line 1 @@ -523,7 +520,7 @@ module M = (12, 4, 13, 15), (13, 11, 13, 15) (12, 4, 13, 15), (13, 11, 13, 15) ] -[] +[] let ``regular comments``() = """ // Line 1 @@ -545,7 +542,7 @@ module M = (7, 9, 11, 19), (7, 11, 11, 19) (8, 8, 10, 17), (8, 8, 10, 17) ] -[] +[] let ``XML doc and regular comments in one block``() = """ // Line 1 @@ -562,7 +559,7 @@ let ``XML doc and regular comments in one block``() = (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] -[] +[] let ``constructor call``() = """ module M = @@ -577,7 +574,7 @@ module M = (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] -[] +[] let ``Top level module`` () = """ module TopLevelModule @@ -588,7 +585,7 @@ module Nested = => [ (2, 7, 5, 15), (2, 21, 5, 15) (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Top level namespace`` () = """ namespace TopLevelNamespace.Another @@ -598,7 +595,7 @@ module Nested = """ => [ (4, 0, 5, 15), (4, 13, 5, 15) ] -[] +[] let ``Multiple namespaces`` () = """ namespace TopLevelNamespace.Another @@ -614,7 +611,7 @@ module NestedModule = => [ (4, 0, 5, 15), (4, 13, 5, 15) (9, 0, 10, 15), (9, 19, 10, 15) ] -[] +[] let ``Member val`` () = """ type T() = @@ -638,7 +635,7 @@ type T() = (10, 4, 11, 10), (10, 4, 11, 10) (13, 4, 15, 10), (13, 4, 15, 10) ] -[] +[] let ``Secondary constructors`` () = """ type T() = @@ -661,7 +658,7 @@ type T() = (9, 4, 11, 12), (10, 10, 11, 12) ] -[] +[] let ``Abstract members`` () = """ type T() = From bfc6a3b171e6f7416a1e161c7181a4b8cfae83ea Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 9 Aug 2023 15:44:15 +0200 Subject: [PATCH 32/32] up --- .../FSharp.Compiler.Service.Tests.fsproj | 3 + .../FSharp.Compiler.UnitTests.fsproj | 4 +- tests/FSharp.Test.Utilities/Assert.fs | 4 +- .../ServiceUntypedParseTests.fs | 475 +++++++++--------- 4 files changed, 243 insertions(+), 243 deletions(-) rename tests/{FSharp.Compiler.UnitTests => service}/ServiceUntypedParseTests.fs (78%) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 6fca44a1a53..b761ced68fd 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -64,6 +64,9 @@ CSharpProjectAnalysis.fs + + ServiceUntypedParseTests.fs + PatternMatchCompilationTests.fs diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index f73d795a427..66e3d1b7c94 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -69,7 +69,9 @@ CompilerService\AssemblyContentProviderTests.fs - + + CompilerService\ServiceUntypedParseTests.fs + diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index 7102715d984..dfed4bf123e 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -3,6 +3,7 @@ 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) = @@ -14,9 +15,6 @@ module Assert = let inline shouldBe (expected : ^T) (actual : ^U) = actual.Should().Be(expected, "") |> ignore - let inline shouldEqual (expected : ^T) (actual : ^T) = - actual.Should().Be(expected, "") |> ignore - let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) = actual.Should().BeEmpty("") |> ignore diff --git a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs b/tests/service/ServiceUntypedParseTests.fs similarity index 78% rename from tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs rename to tests/service/ServiceUntypedParseTests.fs index d5a84b9121a..ea2591b8bf9 100644 --- a/tests/FSharp.Compiler.UnitTests/ServiceUntypedParseTests.fs +++ b/tests/service/ServiceUntypedParseTests.fs @@ -1,20 +1,21 @@ #if INTERACTIVE #r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../artifacts/bin/fcs/net461/xunit.dll" +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" #else module Tests.Service.ServiceUntypedParseTests #endif open System.IO -open FSharp.Test +open FsUnit open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Text.Position -open Xunit -open Assert +open NUnit.Framework let [] private Marker = "(* marker *)" @@ -48,23 +49,22 @@ let private assertCompletionContext (checker: CompletionContext option -> bool) failwithf "Completion context '%A' was not expected" actual module AttributeCompletion = - [] + [] let ``at [<|, applied to nothing``() = """ [<(* marker *) """ |> assertCompletionContext (fun x -> x = Some CompletionContext.AttributeApplication) - [] - [] - [] - [] - [] - [] - [] - [] - [][<(* marker *)", true)>] - [][< (* marker *)", true)>] + [] + [] + [] + [] + [] + [] + [] + [][<(* marker *)", true)>] + [][< (* marker *)", true)>] let ``incomplete``(lineStr: string, expectAttributeApplicationContext: bool) = let code = $""" {lineStr} @@ -73,18 +73,17 @@ type T = """ code |> assertCompletionContext (fun x -> x = (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)) - [] - []", true)>] - []", true)>] - []", true)>] - []", true)>] - []", true)>] - [][<(* marker *)>]", true)>] - [][< (* marker *)>]", true)>] - []", true)>] - []", true)>] - [][]", true)>] - []", false)>] + []", true)>] + []", true)>] + []", true)>] + []", true)>] + []", true)>] + [][<(* marker *)>]", true)>] + [][< (* marker *)>]", true)>] + []", true)>] + []", true)>] + [][]", true)>] + []", false)>] let ``complete``(lineStr: string, expectAttributeApplicationContext: bool) = let code = $""" {lineStr} @@ -94,11 +93,10 @@ type T = code |> assertCompletionContext (fun x -> x = (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)) module AttributeConstructorCompletion = - [] - [] - [] - [][] - [] + [] + [] + [][] + [] let ``incomplete``(lineStr: string) = let code = $""" {lineStr} @@ -107,12 +105,11 @@ type T = """ code |> assertCompletionContext (fun x -> match x with Some (CompletionContext.ParameterList _) -> true | _ -> false) - [] - []")>] - [][]")>] - []")>] - []")>] - [][]")>] + []")>] + [][]")>] + []")>] + []")>] + [][]")>] let ``complete``(lineStr: string) = let code = $""" {lineStr} @@ -121,7 +118,7 @@ type T = """ code |> assertCompletionContext (fun x -> match x with Some (CompletionContext.ParameterList _) -> true | _ -> false) -[] +[] let ``Attribute lists`` () = let source = """ [] @@ -192,7 +189,7 @@ let rec getParenTypes (synType: SynType): SynType list = | _ -> () ] -[] +[] let ``SynType.Paren ranges`` () = let source = """ ((): int * (int * int)) @@ -222,7 +219,7 @@ module TypeMemberRanges = | _ -> failwith "Could not get member" - [] + [] let ``Member range 01 - Simple``() = let source = """ type T = @@ -231,7 +228,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 23) ] - [] + [] let ``Member range 02 - Static``() = let source = """ type T = @@ -240,7 +237,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 28) ] - [] + [] let ``Member range 03 - Attribute``() = let source = """ type T = @@ -250,7 +247,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (4, 28) ] - [] + [] let ``Member range 04 - Property``() = let source = """ type T = @@ -259,7 +256,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) ] - [] + [] let ``Member range 05 - Setter only property``() = let source = """ type T = @@ -268,7 +265,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 44) ] - [] + [] let ``Member range 06 - Read-write property``() = let source = """ type T = @@ -279,7 +276,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (5, 36) ] - [] + [] let ``Member range 07 - Auto property``() = let source = """ type T = @@ -288,7 +285,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] - [] + [] let ``Member range 08 - Auto property with setter``() = let source = """ type T = @@ -297,7 +294,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] - [] + [] let ``Member range 09 - Abstract slot``() = let source = """ type T = @@ -307,7 +304,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) (4, 4), (4, 28) ] - [] + [] let ``Member range 10 - Val field``() = let source = """ type T = @@ -316,7 +313,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 14) ] - [] + [] let ``Member range 11 - Ctor``() = let source = """ type T = @@ -325,7 +322,7 @@ type T = getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 20) ] -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - simple``() = let source = """ let x = false @@ -340,9 +337,9 @@ let y = !x |> fst |> shouldEqual (3, 8) | None -> - failwith "No deref operator found in source." + Assert.Fail("No deref operator found in source.") -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - parens``() = let source = """ let x = false @@ -357,10 +354,10 @@ let y = !(x) |> fst |> shouldEqual (3, 8) | None -> - failwith "No deref operator found in source." + Assert.Fail("No deref operator found in source.") -[] +[] let ``TryRangeOfRefCellDereferenceContainingPos - binary expr``() = let source = """ let x = false @@ -375,9 +372,9 @@ let y = !(x = false) |> fst |> shouldEqual (3, 8) | None -> - failwith "No deref operator found in source." + Assert.Fail("No deref operator found in source.") -[] +[] let ``TryRangeOfRecordExpressionContainingPos - contained``() = let source = """ let x = { Name = "Hello" } @@ -390,9 +387,9 @@ let x = { Name = "Hello" } |> tups |> shouldEqual ((2, 8), (2, 26)) | None -> - failwith "No range of record found in source." + Assert.Fail("No range of record found in source.") -[] +[] let ``TryRangeOfRecordExpressionContainingPos - not contained``() = let source = """ let x = { Name = "Hello" } @@ -403,7 +400,7 @@ let x = { Name = "Hello" } module FunctionApplicationArguments = - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Single arg``() = let source = """ let f x = () @@ -417,9 +414,9 @@ f 12 |> List.map (tups >> fst) |> shouldEqual [(3, 2)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg``() = let source = """ let f x y z = () @@ -433,9 +430,9 @@ f 1 2 3 |> List.map (tups >> fst) |> shouldEqual [(3, 2); (3, 4); (3, 6)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg parentheses``() = let source = """ let f x y z = () @@ -449,9 +446,9 @@ f (1) (2) (3) |> List.map (tups >> fst) |> shouldEqual [(3, 2); (3, 6); (3, 10)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - Multi arg nested parentheses``() = let source = """ let f x y z = () @@ -465,9 +462,9 @@ f ((1)) (((2))) ((((3)))) |> List.map (tups >> fst) |> shouldEqual [(3, 3); (3, 10); (3, 19)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - unit``() = let source = """ let f () = () @@ -475,9 +472,9 @@ f () """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.GetAllArgumentsForFunctionApplicationAtPosition (mkPos 3 0) - Assert.True(res.IsNone, "Found argument for unit-accepting function, which shouldn't be the case.") + Assert.IsTrue(res.IsNone, "Found argument for unit-accepting function, which shouldn't be the case.") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - curried function``() = let source = """ let f x y = x + y @@ -491,9 +488,9 @@ f 12 |> List.map (tups >> fst) |> shouldEqual [(3, 2)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple value``() = let source = """ let f (t: int * int) = () @@ -508,9 +505,9 @@ f t |> List.map (tups >> fst) |> shouldEqual [(4, 2)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple literal``() = let source = """ let f (t: int * int) = () @@ -524,9 +521,9 @@ f (1, 2) |> List.map (tups >> fst) |> shouldEqual [(3, 3); (3, 6)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple value with definition that has explicit names``() = let source = """ let f ((x, y): int * int) = () @@ -541,9 +538,9 @@ f t |> List.map (tups >> fst) |> shouldEqual [(4, 2)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuple literal inside parens``() = let source = """ let f (x, y) = () @@ -557,9 +554,9 @@ f ((1, 2)) |> List.map (tups >> fst) |> shouldEqual [(3, 4); (3, 7)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - tuples with elements as arguments``() = let source = """ let f (a, b) = () @@ -573,9 +570,9 @@ f (1, 2) |> List.map (tups >> fst) |> shouldEqual [(3, 3); (3, 6)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - top-level arguments with nested function call``() = let source = """ let f x y = x + y @@ -589,9 +586,9 @@ f (f 1 2) 3 |> List.map (tups >> fst) |> shouldEqual [(3, 2); (3, 10)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function argument positions``() = let source = """ let f x y = x + y @@ -605,9 +602,9 @@ f (f 1 2) 3 |> List.map (tups >> fst) |> shouldEqual [(3, 5); (3, 7)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function application in infix expression``() = let source = """ let addStr x y = string x + y @@ -620,9 +617,9 @@ let addStr x y = string x + y |> List.map (tups >> fst) |> shouldEqual [(2, 24)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function application outside of infix expression``() = let source = """ let addStr x y = x + string y @@ -635,9 +632,9 @@ let addStr x y = x + string y |> List.map (tups >> fst) |> shouldEqual [(2, 28)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``GetAllArgumentsForFunctionApplicationAtPosition - nested function applications both inside and outside of infix expression``() = let source = """ let addStr x y = string x + string y @@ -650,7 +647,7 @@ let addStr x y = string x + string y |> List.map (tups >> fst) |> shouldEqual [(2, 24)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") let res = parseFileResults.GetAllArgumentsForFunctionApplicationAtPosition (mkPos 2 28) @@ -660,9 +657,9 @@ let addStr x y = string x + string y |> List.map (tups >> fst) |> shouldEqual [(2, 35)] | None -> - failwith "No arguments found in source code" + Assert.Fail("No arguments found in source code") - [] + [] let ``IsPosContainedInApplication - no``() = let source = """ sqrt x @@ -671,7 +668,7 @@ sqrt x let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 3 2), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - yes, single arg``() = let source = """ sqrt x @@ -679,7 +676,7 @@ sqrt x let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should be in application") - [] + [] let ``IsPosContainedInApplication - yes, multi arg``() = let source = """ let add2 x y = x + y @@ -688,7 +685,7 @@ add2 x y let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 3 6), "Pos should be in application") - [] + [] let ``IsPosContainedInApplication - inside computation expression - no``() = let source = """ async { @@ -698,7 +695,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside CE return - no``() = let source = """ async { @@ -708,7 +705,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside CE - yes``() = let source = """ let myAdd x y = x + y @@ -719,7 +716,7 @@ async { let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 3 18), "Pos should not be in application") - [] + [] let ``IsPosContainedInApplication - inside type application``() = let source = """ let f<'x> x = () @@ -728,7 +725,7 @@ f let parseFileResults, _ = getParseAndCheckResults source Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 3 6), "A type application is an application, expected True.") - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - no application``() = let source = """ let add2 x y = x + y @@ -737,9 +734,9 @@ add2 x y """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 4 2) - Assert.True(res.IsNone, "Not in a function application but got one") + Assert.IsTrue(res.IsNone, "Not in a function application but got one") - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - single arg application``() = let source = """ sqrt 12.0 @@ -747,13 +744,13 @@ sqrt 12.0 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 9) match res with - | None -> failwith "Expected 'sqrt' but got nothing" + | None -> Assert.Fail("Expected 'sqrt' but got nothing") | Some range -> range |> tups |> shouldEqual ((2, 0), (2, 4)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application``() = let source = """ let f x y z = () @@ -762,13 +759,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 5) match res with - | None -> failwith "Expected 'f' but got nothing" + | None -> Assert.Fail("Expected 'f' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multi arg application but at function itself``() = let source = """ let f x y z = () @@ -777,13 +774,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 1) match res with - | None -> failwith "Expected 'f' but got nothing" + | None -> Assert.Fail("Expected 'f' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in pipeline``() = let source = """ [1..10] |> List.map id @@ -791,13 +788,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 20) match res with - | None -> failwith "Expected 'List.map' but got nothing" + | None -> Assert.Fail("Expected 'List.map' but got nothing") | Some range -> range |> tups |> shouldEqual ((2, 11), (2, 19)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline``() = let source = """ [1..10] @@ -807,13 +804,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 14) match res with - | None -> failwith "Expected 'List.filter' but got nothing" + | None -> Assert.Fail("Expected 'List.filter' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 3), (3, 14)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - function in middle of pipeline, no qualification``() = let source = """ [1..10] @@ -822,13 +819,13 @@ f 1 2 3 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 5) match res with - | None -> failwith "Expected 'id' but got nothing" + | None -> Assert.Fail("Expected 'id' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 3), (3, 5)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - incomplete infix app``() = let source = """ let add2 x y = x + y @@ -838,13 +835,13 @@ add2 1 2 let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 18) match res with - | None -> failwith "Expected '*' but got nothing" + | None -> Assert.Fail("Expected '*' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 17), (3, 18)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE``() = let source = """ let myAdd x y = x + y @@ -855,13 +852,13 @@ async { let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 4 18) match res with - | None -> failwith "Expected 'myAdd' but got nothing" + | None -> Assert.Fail("Expected 'myAdd' but got nothing") | Some range -> range |> tups |> shouldEqual ((4, 11), (4, 16)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - binding``() = let source = """ let add n1 n2 = n1 + n2 @@ -875,13 +872,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 6 21) match res with - | None -> failwith "Expected 'add' but got nothing" + | None -> Assert.Fail("Expected 'add' but got nothing") | Some range -> range |> tups |> shouldEqual ((6, 18), (6, 21)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - if expression``() = let source = """ let add n1 n2 = n1 + n2 @@ -899,13 +896,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 7 15) match res with - | None -> failwith "Expected 'add' but got nothing" + | None -> Assert.Fail("Expected 'add' but got nothing") | Some range -> range |> tups |> shouldEqual ((7, 12), (7, 15)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expression``() = let source = """ let add n1 n2 = n1 + n2 @@ -923,13 +920,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 7 15) match res with - | None -> failwith "Expected 'add' but got nothing" + | None -> Assert.Fail("Expected 'add' but got nothing") | Some range -> range |> tups |> shouldEqual ((7, 12), (7, 15)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match expr``() = let source = """ let add n1 n2 = n1 + n2 @@ -947,13 +944,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 9 21) match res with - | None -> failwith "Expected 'add' but got nothing" + | None -> Assert.Fail("Expected 'add' but got nothing") | Some range -> range |> tups |> shouldEqual ((9, 18), (9, 21)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside lambda - match case``() = let source = """ let add n1 n2 = n1 + n2 @@ -971,13 +968,13 @@ let mapped = let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 11 22) match res with - | None -> failwith "Expected 'add' but got nothing" + | None -> Assert.Fail("Expected 'add' but got nothing") | Some range -> range |> tups |> shouldEqual ((11, 19), (11, 22)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call``() = let source = """ type C() = static member Yeet(x, y, z) = () @@ -986,13 +983,13 @@ C.Yeet(1, 2, sqrt) let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 17) match res with - | None -> failwith "Expected 'sqrt' but got nothing" + | None -> Assert.Fail("Expected 'sqrt' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 13), (3, 17)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - inside method call - parenthesized lambda``() = let source = """ type C() = static member Yeet(x, y, z) = () @@ -1001,13 +998,13 @@ C.Yeet(1, 2, (fun x -> sqrt)) let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 27) match res with - | None -> failwith "Expected 'sqrt' but got nothing" + | None -> Assert.Fail("Expected 'sqrt' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 23), (3, 27)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - generic-typed app``() = let source = """ let f<'x> x = () @@ -1016,13 +1013,13 @@ f let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 6) match res with - | None -> failwith "Expected 'f' but got nothing" + | None -> Assert.Fail("Expected 'f' but got nothing") | Some range -> range |> tups |> shouldEqual ((3, 0), (3, 1)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a list that is used as an argument - Sequential and ArrayOrListComputed``() = let source = """ let test () = div [] [ @@ -1036,13 +1033,13 @@ let test () = div [] [ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 5 15) match res with - | None -> failwith "Expected 'ofInt' but got nothing" + | None -> Assert.Fail("Expected 'ofInt' but got nothing") | Some range -> range |> tups |> shouldEqual ((5, 8), (5, 13)) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after semicolon - Sequential and ComputationExpr``() = let source = """ let div props children = () @@ -1058,7 +1055,7 @@ let test () = div [] [ // Once this particular case is implemented, the expected result should be the range of `div` Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - yielding in a list that is used as an argument, after newline and semicolon - Sequential and ComputationExpr``() = let source = """ let div props children = () @@ -1075,7 +1072,7 @@ let test () = div [] [ // Once this particular case is implemented, the expected result should be the range of `div` Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryRangeOfFunctionOrMethodBeingApplied - multiple yielding in a sequence that is used as an argument - Sequential and ComputationExpr``() = let source = """ seq { 5; int "6" } |> Seq.sum @@ -1083,7 +1080,7 @@ seq { 5; int "6" } |> Seq.sum let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 2 14) match res with - | None -> failwith "Expected 'int' but got nothing" + | None -> Assert.Fail("Expected 'int' but got nothing") | Some range -> range |> tups @@ -1091,7 +1088,7 @@ seq { 5; int "6" } |> Seq.sum module PipelinesAndArgs = - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - No pipeline, no infix app``() = let source = """ let f x = () @@ -1101,7 +1098,7 @@ f 12 let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 3 0) Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - No pipeline, but infix app``() = let source = """ let square x = x * @@ -1110,7 +1107,7 @@ let square x = x * let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 2 18) Assert.True(res.IsNone, sprintf "Got a result, did not expect one: %A" res) - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Single pipeline``() = let source = """ [1..10] |> List.map @@ -1122,9 +1119,9 @@ let square x = x * (ident.idText, numArgs) |> shouldEqual ("op_PipeRight", 1) | None -> - failwith "No pipeline found" + Assert.Fail("No pipeline found") - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Double pipeline``() = let source = """ ([1..10], 1) ||> List.fold @@ -1136,9 +1133,9 @@ let square x = x * (ident.idText, numArgs) |> shouldEqual ("op_PipeRight2", 2) | None -> - failwith "No pipeline found" + Assert.Fail("No pipeline found") - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - Triple pipeline``() = let source = """ ([1..10], [1..10], 3) |||> List.fold2 @@ -1150,9 +1147,9 @@ let square x = x * (ident.idText, numArgs) |> shouldEqual ("op_PipeRight3", 3) | None -> - failwith "No pipeline found" + Assert.Fail("No pipeline found") - [] + [] let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - none when inside lambda``() = let source = """ let add n1 n2 = n1 + n2 @@ -1165,9 +1162,9 @@ let mapped = """ let parseFileResults, _ = getParseAndCheckResults source let res = parseFileResults.TryIdentOfPipelineContainingPosAndNumArgsApplied (mkPos 6 22) - Assert.True(res.IsNone, "Inside a lambda but counted the pipeline outside of that lambda.") + Assert.IsTrue(res.IsNone, "Inside a lambda but counted the pipeline outside of that lambda.") -[] +[] let ``TryRangeOfExprInYieldOrReturn - not contained``() = let source = """ let f x = @@ -1177,7 +1174,7 @@ let f x = let res = parseFileResults.TryRangeOfExprInYieldOrReturn (mkPos 3 4) Assert.True(res.IsNone, "Expected not to find a range.") -[] +[] let ``TryRangeOfExprInYieldOrReturn - contained``() = let source = """ let f x = @@ -1191,9 +1188,9 @@ let f x = |> tups |> shouldEqual ((3, 11), (3, 12)) | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - not correct operator``() = let source = """ let x = y |> y + 1 @@ -1202,7 +1199,7 @@ let x = y |> y + 1 let res = parseFileResults.TryRangeOfParenEnclosingOpEqualsGreaterUsage (mkPos 2 8) Assert.True(res.IsNone, "Expected not to find any ranges.") -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - error arg pos``() = let source = """ let x = y => y + 1 @@ -1215,9 +1212,9 @@ let x = y => y + 1 |> List.map tups |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - error expr pos``() = let source = """ let x = y => y + 1 @@ -1230,9 +1227,9 @@ let x = y => y + 1 |> List.map tups |> shouldEqual [((2, 8), (2, 18)); ((2, 8), (2, 9)); ((2, 13), (2, 18))] | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = let source = """ [1..10] |> List.map (x => x + 1) @@ -1245,9 +1242,9 @@ let ``TryRangeOfParenEnclosingOpEqualsGreaterUsage - parenthesized lambda``() = |> List.map tups |> shouldEqual [((2, 21), (2, 31)); ((2, 21), (2, 22)); ((2, 26), (2, 31))] | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - simple``() = let source = """ let x = nameof x @@ -1260,9 +1257,9 @@ let x = nameof x |> tups |> shouldEqual ((2, 4), (2, 5)) | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - inside match``() = let source = """ let mySum xs acc = @@ -1279,9 +1276,9 @@ let mySum xs acc = |> tups |> shouldEqual ((2, 4), (2, 9)) | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - nested binding``() = let source = """ let f x = @@ -1298,9 +1295,9 @@ let f x = |> tups |> shouldEqual ((4, 8), (4, 9)) | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") -[] +[] let ``TryRangeOfNameOfNearestOuterBindingContainingPos - nested and after other statements``() = let source = """ let f x = @@ -1319,231 +1316,231 @@ let f x = |> tups |> shouldEqual ((6, 8), (6, 9)) | None -> - failwith "Expected to get a range back, but got none." + Assert.Fail("Expected to get a range back, but got none.") module TypeAnnotations = - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - no annotation``() = let source = """ let f x = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 6), "Expected no annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 6), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - single arg annotation``() = let source = """ let f (x: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - first arg annotated``() = let source = """ let f (x: int) y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - second arg annotated``() = let source = """ let f x (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 9), "Expected annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 9), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - function - all args annotated``() = let source = """ let f (x: int) (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 16), "Expected annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 16), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - lambda function - all args annotated``() = let source = """ let f = fun (x: int) (y: string) -> () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected a annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 22), "Expected a annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected a annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 22), "Expected a annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - arg no annotations``() = let source = """ type C(x) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - first arg unannotated``() = let source = """ type C(x, y: string) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 10), "Expected annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected no annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 10), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - second arg unannotated``() = let source = """ type C(x: int, y) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - constuctor - both args annotated``() = let source = """ type C(x: int, y: int) = class end """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 7), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 15), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - args no unannotions``() = let source = """ type C() = member _.M(x, y) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected no annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - first arg annotated``() = let source = """ type C() = member _.M(x: int, y) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected no annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - second arg annotated``() = let source = """ type C() = member _.M(x, y: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - both args annotated``() = let source = """ type C() = member _.M(x: int, y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 23), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - args no unannotions``() = let source = """ type C() = member _.M x y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 17), "Expected no annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 17), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - first arg annotated``() = let source = """ type C() = member _.M (x: int) y = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 24), "Expected no annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 24), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - second arg annotated``() = let source = """ type C() = member _.M x (y: int) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected no annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected no annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 18), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method currying - both args annotated``() = let source = """ type C() = member _.M (x: int) (y: string) = () """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 25), "Expected annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 16), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 25), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - method - only return type annotated``() = let source = """ type C() = member _.M(x): string = "hello" + x """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 3 15), "Expected no annotation for argument 'x'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - no annotations``() = let source = """ let (x, y) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for value 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected no annotation for value 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for value 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected no annotation for value 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - first value annotated``() = let source = """ let (x: int, y) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected no annotation for argument 'y'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 13), "Expected no annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - tuple - second value annotated``() = let source = """ let (x, y: string) = (12, "hello") """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for argument 'x'") - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected annotation for argument 'y'") + Assert.IsFalse(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected no annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 8), "Expected annotation for argument 'y'") - [] + [] let ``IsTypeAnnotationGivenAtPosition - binding - second value annotated``() = let source = """ let x: int = 12 """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") + Assert.IsTrue(parseFileResults.IsTypeAnnotationGivenAtPosition (mkPos 2 5), "Expected annotation for argument 'x'") module LambdaRecognition = - [] + [] let ``IsBindingALambdaAtPosition - recognize a lambda``() = let source = """ let f = fun x y -> x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - recognize a nested lambda``() = let source = """ let f = @@ -1552,9 +1549,9 @@ let f = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - recognize a "partial" lambda``() = let source = """ let f x = @@ -1562,12 +1559,12 @@ let f x = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.True(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") + Assert.IsTrue(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "Expected 'f' to be a lambda expression") - [] + [] let ``IsBindingALambdaAtPosition - not a lambda``() = let source = """ let f x y = x + y """ let parseFileResults, _ = getParseAndCheckResults source - Assert.False(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "'f' is not a lambda expression'") + Assert.IsFalse(parseFileResults.IsBindingALambdaAtPosition (mkPos 2 4), "'f' is not a lambda expression'")