From 382714004f0cbfa18f25135a38f70c9c1c0860ad Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 4 Oct 2022 15:38:40 +0200 Subject: [PATCH] More DU obsolete attribute tests (#13996) --- .../ObsoleteAttributeCheckingTests.fs | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs index 29ea07183..4c87a14d9 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs @@ -205,7 +205,77 @@ C.Update() |> shouldFail |> withDiagnostics [ (Error 101, Line 9, Col 1, Line 9, Col 9, "This construct is deprecated. Use B instead") - ] + ] + + [] + let ``Obsolete attribute error is taken into account when used on a struct du and invocation`` () = + Fsx """ +open System +[] +[] +type Color = + | Red + | Green + +let c = Color.Red + """ + |> ignoreWarnings + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 101, Line 9, Col 9, Line 9, Col 14, "This construct is deprecated. Use B instead") + ] + + [] + let ``Obsolete attribute error is taken into account when used on a du and invocation`` () = + Fsx """ +open System +[] +type Color = + | Red + | Green + +let c = Color.Red + """ + |> ignoreWarnings + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 101, Line 8, Col 9, Line 8, Col 14, "This construct is deprecated. Use B instead") + ] + + [] + let ``Obsolete attribute error is taken into account when used on a du field and invocation`` () = + Fsx """ +open System +type Color = + | [] Red + | Green + +let c = Color.Red + """ + |> ignoreWarnings + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 101, Line 7, Col 9, Line 7, Col 18, "This construct is deprecated. Use B instead") + ] + + [] + let ``Obsolete attribute warning is taken into account when used on a du field and invocation`` () = + Fsx """ +open System +type Color = + | [] Red + | Green + +let c = Color.Red + """ + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 44, Line 7, Col 9, Line 7, Col 18, "This construct is deprecated. Use B instead") + ] [] let ``Obsolete attribute error is taken into account when used on an enum and invocation`` () = -- GitLab