Skip to content

Commit f391d30

Browse files
committed
tests
1 parent d18cfe7 commit f391d30

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module ErrorMessages.FSharpDiagnosticTests
2+
3+
open FSharp.Compiler.CodeAnalysis
4+
open FSharp.Compiler.Diagnostics
5+
open FSharp.Test.Assert
6+
open FSharp.Test.Compiler
7+
open Xunit
8+
9+
let checkDiagnostics diagnostics (checkResults: FSharpCheckFileResults) =
10+
checkResults.Diagnostics
11+
|> Array.map (fun e ->
12+
{| Number = e.ErrorNumber
13+
Severity = e.Severity
14+
DefaultSeverity = e.DefaultSeverity |})
15+
|> shouldEqual diagnostics
16+
17+
[<Fact>]
18+
let ``FSharpDiagnostic: warning default severity`` () =
19+
FSharp "
20+
module Test
21+
5
22+
"
23+
|> typecheckResults
24+
|> checkDiagnostics [|
25+
{| Number = 20
26+
Severity = FSharpDiagnosticSeverity.Warning
27+
DefaultSeverity = FSharpDiagnosticSeverity.Warning |}
28+
|]
29+
30+
[<Fact>]
31+
let ``FSharpDiagnostic: warning as error default severity`` () =
32+
FSharp "
33+
module M
34+
5
35+
"
36+
|> withOptions [ "--warnaserror+" ]
37+
|> typecheckResults
38+
|> checkDiagnostics [|
39+
{| Number = 20
40+
Severity = FSharpDiagnosticSeverity.Error
41+
DefaultSeverity = FSharpDiagnosticSeverity.Warning |}
42+
|]
43+
44+
[<Fact>]
45+
let ``FSharpDiagnostic: error default severity`` () =
46+
FSharp "
47+
module M
48+
x
49+
"
50+
|> typecheckResults
51+
|> checkDiagnostics [|
52+
{| Number = 39
53+
Severity = FSharpDiagnosticSeverity.Error
54+
DefaultSeverity = FSharpDiagnosticSeverity.Error |}
55+
|]

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
<Compile Include="ErrorMessages\AbbreviationTests.fs" />
232232
<Compile Include="ErrorMessages\NamespaceTests.fs" />
233233
<Compile Include="ErrorMessages\NameIsBoundMultipleTimesTests.fs" />
234+
<Compile Include="ErrorMessages\FSharpDiagnosticTests.fs" />
234235
<Compile Include="Language\IndexerSetterParamArray.fs" />
235236
<Compile Include="Language\MultiDimensionalArrayTests.fs" />
236237
<Compile Include="Language\RegressionTests.fs" />

0 commit comments

Comments
 (0)