Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
ef0949c
Copy sources from Versions.props to NuGet.config (#7191)
Jul 11, 2019
0c9ccae
Only check distinct errors (#7140)
forki Jul 11, 2019
598db3e
Use 1-based column numbers in tests (#7141)
forki Jul 11, 2019
fe0426a
Merge pull request #7197 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 11, 2019
bf1055c
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 11, 2019
13596c4
Merge pull request #7201 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 12, 2019
da432e1
Better record and value formatting in tools (#7021)
cartermp Jul 12, 2019
660a545
fix portable PDBs for anon records (#7099)
dsyme Jul 12, 2019
9dc9d0e
fix portable PDBs for anon records (#7099)
dsyme Jul 12, 2019
60c915a
Moving ElseBranchHasWrongTypeTests over to NUnit (#7104)
forki Jul 12, 2019
869c2bb
Port tests for missing else branch to NUnit (#7209)
forki Jul 12, 2019
c80a0cb
Merge pull request #7208 from KevinRansom/cherrypickfix
KevinRansom Jul 12, 2019
2fabdaa
Merge pull request #7213 from dotnet/merges/master-to-release/dev16.3
brettfo Jul 12, 2019
59bfc83
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 12, 2019
8ab272a
Update dependencies from https://github.com/dotnet/arcade build 20190…
Jul 13, 2019
1ad5657
Merge pull request #7222 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 13, 2019
b7d5efd
Merge branch 'release/dev16.3' into merges/release/fsharp47-to-releas…
KevinRansom Jul 13, 2019
7780cab
Fix Supplementary Character / Surrogate Pair info (no code changes) (…
srutzky Jul 13, 2019
30cce45
Merge pull request #7228 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 14, 2019
0abf39c
Merge pull request #7223 from dotnet/merges/release/fsharp47-to-relea…
KevinRansom Jul 14, 2019
f9a8e2a
Update IlxGen.fs (#7227)
TIHan Jul 14, 2019
c79a8ab
Merge pull request #7225 from dotnet/darc-master-1d1b7b40-d7f9-4b9d-9…
KevinRansom Jul 14, 2019
ec8a424
Check for exit code in compiler tests (#7211)
forki Jul 14, 2019
c4dba1f
Moving AccessOfTypeAbbreviationTests over to NUnit (#7226)
sergey-tihon Jul 14, 2019
f720c73
Merge pull request #7230 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 14, 2019
75cef56
Moving ConstructorTests over to NUnit (#7236)
sergey-tihon Jul 15, 2019
c7cd220
[master] Update dependencies from dotnet/arcade (#7233)
dotnet-maestro[bot] Jul 15, 2019
0f24b3e
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 16, 2019
863ec25
Moving UpcastDowncastTests over to NUnit (#7229)
sergey-tihon Jul 16, 2019
c8bac72
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 17, 2019
6980587
Move ErrorMessages/NameResolution Tests to NUnit (#7237)
kMutagene Jul 17, 2019
4cf7b5b
Moving WarnExpressionTests over to NUnit (#7232)
sergey-tihon Jul 17, 2019
2f270f2
Merge pull request #7241 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 17, 2019
650805b
move some error and warning tests to NUnit (#7244)
smcl Jul 17, 2019
375fd7c
Update dependencies from https://github.com/dotnet/arcade build 20190…
Jul 18, 2019
8d74566
Merge pull request #7253 from dotnet/darc-master-648345c2-b59c-4cd2-9…
KevinRansom Jul 19, 2019
c423de9
Move UnitGenericAbstractType To Nunit (#7257)
falfaddaghi Jul 19, 2019
4151eb2
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 19, 2019
bdb2b79
Moving TypeMismatchTests over to NUnit (#7250)
sergey-tihon Jul 19, 2019
b0e5926
publish pdbs in FSharp.Core.nupkg (#7255)
brettfo Jul 19, 2019
3e7b66d
Enable hash algorithm selection (#7252)
KevinRansom Jul 20, 2019
c70ead8
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 20, 2019
ff7b8ff
Improve netcore reference selection (#7263)
KevinRansom Jul 22, 2019
d53a38c
Moving Libraries Control tests to NUnit (#7234)
thinkbeforecoding Jul 22, 2019
5efa8a7
Member constraints and PrimitiveConstraints (#7210)
forki Jul 22, 2019
a7c68c3
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 23, 2019
a67156b
Merge branch 'master' into merges/release/dev16.2-to-master
brettfo Jul 24, 2019
0bd851b
Merge pull request #7272 from dotnet/merges/release/dev16.2-to-master
Jul 25, 2019
37970b4
fixes issue #6832 (#7259)
KevinRansom Jul 25, 2019
d979174
Color nameof as intrinsic (#7273)
cartermp Jul 25, 2019
8e843ae
[master] Update dependencies from dotnet/arcade (#7269)
dotnet-maestro[bot] Jul 26, 2019
b3811d2
Merge pull request #7279 from dotnet/merges/release/fsharp47-to-relea…
Jul 26, 2019
ce483c0
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 26, 2019
969a9c4
Fix test assert (#7283)
KevinRansom Jul 26, 2019
2304ea4
merge
KevinRansom Jul 26, 2019
c03755f
disablewarningtests
KevinRansom Jul 27, 2019
d488458
Merge pull request #7266 from dotnet/merges/master-to-release/dev16.3
Jul 27, 2019
cc60ed6
code cleanup prior to optional interop improvements (#7276)
dsyme Jul 27, 2019
e72ded1
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 27, 2019
bdb229c
Moving ClassesTests over to NUnit (#7264)
sergey-tihon Jul 27, 2019
8370ef6
Move Basic Constants to NUnit (#7262)
falfaddaghi Jul 27, 2019
3ce8eb1
Moved Don't Suggest Tests over to NUnit (#7288)
sergey-tihon Jul 29, 2019
868b76a
[master] Update dependencies from dotnet/arcade (#7287)
dotnet-maestro[bot] Jul 29, 2019
9c1a0d1
Fix langversion with multiple projects (#7293)
KevinRansom Jul 30, 2019
8edf449
Merge remote-tracking branch 'upstream/master' into merges/master-to-…
brettfo Jul 30, 2019
54f13f0
Merge pull request #7292 from dotnet/merges/master-to-release/dev16.3
Jul 30, 2019
897afd3
Merge pull request #7301 from KevinRansom/release/fsharp47
brettfo Jul 30, 2019
a80b135
Merge Dev16.3, resolve conflicts.
KevinRansom Jul 30, 2019
282cd3d
Resolve merge issues, and take care of Test Framework incompatabilities
KevinRansom Jul 31, 2019
bd1becc
Tweak tests
KevinRansom Jul 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move some error and warning tests to NUnit (dotnet#7244)
* move some error and warning tests to NUnit

* CompilerAssert.ParseWithErrors now uses ParseFile instead of ParseAndCheckFileInProject

* merge conflicts
  • Loading branch information
smcl authored and cartermp committed Jul 17, 2019
commit 650805b36840bd9ded0d4472a31bc756a42e8243
19 changes: 19 additions & 0 deletions tests/fsharp/Compiler/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,22 @@ module CompilerAssert =
Assert.AreEqual(expectedErrorMessage, errorMessage)
)

let ParseWithErrors (source: string) expectedParseErrors =
let parseResults = checker.ParseFile("test.fs", SourceText.ofString source, FSharpParsingOptions.Default) |> Async.RunSynchronously

Assert.True(parseResults.ParseHadErrors)

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

Assert.AreEqual(Array.length expectedParseErrors, errors.Length, sprintf "Type check errors: %A" parseResults.Errors)

Array.zip errors expectedParseErrors
|> Array.iter (fun (info, expectedError) ->
let (expectedServerity: FSharpErrorSeverity, expectedErrorNumber: int, expectedErrorRange: int * int * int * int, expectedErrorMsg: string) = expectedError
Assert.AreEqual(expectedServerity, info.Severity)
Assert.AreEqual(expectedErrorNumber, info.ErrorNumber, "expectedErrorNumber")
Assert.AreEqual(expectedErrorRange, (info.StartLineAlternate, info.StartColumn + 1, info.EndLineAlternate, info.EndColumn + 1), "expectedErrorRange")
Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg")
)
23 changes: 23 additions & 0 deletions tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.UnitTests

open NUnit.Framework
open FSharp.Compiler.SourceCodeServices

[<TestFixture>]
module ``Errors assigning to mutable objects`` =

[<Test>]
let ``Assign to immutable error``() =
CompilerAssert.TypeCheckSingleError
"""
let x = 10
x <- 20

exit 0
"""
FSharpErrorSeverity.Error
27
(3, 1, 3, 8)
"This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'."
108 changes: 108 additions & 0 deletions tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.UnitTests

open NUnit.Framework
open FSharp.Compiler.SourceCodeServices

[<TestFixture>]
module ``Warnings assigning to mutable and immutable objects`` =

[<Test>]
let ``Unused compare with immutable when assignment might be intended``() =
CompilerAssert.TypeCheckSingleError
"""
let x = 10
let y = "hello"

let changeX() =
x = 20
y = "test"

exit 0
"""
FSharpErrorSeverity.Warning
20
(6, 5, 6, 11)
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'."

[<Test>]
let ``Unused compare with mutable when assignment might be intended``() =
CompilerAssert.TypeCheckSingleError
"""
let mutable x = 10
let y = "hello"

let changeX() =
x = 20
y = "test"

exit 0
"""
FSharpErrorSeverity.Warning
20
(6, 5, 6, 11)
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'."

[<Test>]
let ``Unused comparison of property in dotnet object when assignment might be intended``() =
CompilerAssert.TypeCheckSingleError
"""
open System

let z = new System.Timers.Timer()
let y = "hello"

let changeProperty() =
z.Enabled = true
y = "test"

exit 0
"""
FSharpErrorSeverity.Warning
20
(8, 5, 8, 21)
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'."

[<Test>]
let ``Unused comparison of property when assignment might be intended ``() =
CompilerAssert.TypeCheckSingleError
"""
type MyClass(property1 : int) =
member val Property1 = property1
member val Property2 = "" with get, set

let x = MyClass(1)
let y = "hello"

let changeProperty() =
x.Property2 = "20"
y = "test"

exit 0
"""
FSharpErrorSeverity.Warning
20
(10, 5, 10, 23)
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'."

[<Test>]
let ``Don't warn if assignment to property without setter ``() =
CompilerAssert.TypeCheckSingleError
"""
type MyClass(property1 : int) =
member val Property2 = "" with get

let x = MyClass(1)
let y = "hello"

let changeProperty() =
x.Property2 = "22"
y = "test"

exit 0
"""
FSharpErrorSeverity.Warning
20
(9, 5, 9, 23)
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'."
2 changes: 2 additions & 0 deletions tests/fsharp/FSharpSuite.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
<Compile Include="Compiler\ErrorMessages\MissingElseBranch.fs" />
<Compile Include="Compiler\ErrorMessages\NameResolutionTests.fs" />
<Compile Include="Compiler\ErrorMessages\UpcastDowncastTests.fs" />
<Compile Include="Compiler\ErrorMessages\AssignmentErrorTests.fs" />
<Compile Include="Compiler\ErrorMessages\WarnExpressionTests.fs" />
<Compile Include="Compiler\SourceTextTests.fs" />
<Compile Include="Compiler\Language\AnonRecordTests.fs" />
<Compile Include="Compiler\Language\SpanOptimizationTests.fs" />
<Compile Include="Compiler\Language\SpanTests.fs" />
<Compile Include="Compiler\Language\StringConcatOptimizationTests.fs" />
<Compile Include="Compiler\Stress\LargeExprTests.fs" />
<Compile Include="Compiler\Warnings\AssignmentWarningTests.fs" />
<Content Include="packages.config" />
<None Include="app.config" />
<None Include="update.base.line.with.actuals.fsx" />
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst

This file was deleted.

7 changes: 0 additions & 7 deletions tests/fsharpqa/Source/Warnings/AssignmentOnImmutable.fs

This file was deleted.

1 change: 0 additions & 1 deletion tests/fsharpqa/Source/Warnings/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
SOURCE=MatchingMethodWithSameNameIsNotAbstract.fs # MatchingMethodWithSameNameIsNotAbstract.fs
SOURCE=NoMatchingAbstractMethodWithSameName.fs # NoMatchingAbstractMethodWithSameName.fs
SOURCE=MissingExpressionAfterLet.fs # MissingExpressionAfterLet.fs
SOURCE=AssignmentOnImmutable.fs # AssignmentOnImmutable.fs
SOURCE=SuggestFieldsInCtor.fs # SuggestFieldsInCtor.fs
SOURCE=FieldSuggestion.fs # FieldSuggestion.fs
SOURCE=SuggestToUseIndexer.fs # SuggestToUseIndexer.fs
Expand Down
1 change: 0 additions & 1 deletion tests/fsharpqa/Source/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ Misc01 Libraries\Core\Operators
Misc01 Libraries\Core\Reflection
Misc01 Libraries\Core\Unchecked
Misc01 Warnings
Misc01 ErrorMessages\NameResolution
Misc01 ErrorMessages\UnitGenericAbstractType
Misc01 ErrorMessages\ConfusingTypeName

Expand Down