-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving UpcastDowncastTests over to NUnit (#7229)
* Moving UpcastDowncastTests over to NUnit * missing new line
- Loading branch information
1 parent
0f24b3e
commit 863ec25
Showing
6 changed files
with
52 additions
and
30 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// 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 ``Upcast and Downcast`` = | ||
|
||
[<Test>] | ||
let ``Downcast Instead Of Upcast``() = | ||
CompilerAssert.TypeCheckSingleError | ||
""" | ||
open System.Collections.Generic | ||
let orig = Dictionary<obj,obj>() :> IDictionary<obj,obj> | ||
let c = orig :> Dictionary<obj,obj> | ||
""" | ||
FSharpErrorSeverity.Error | ||
193 | ||
(5, 9, 5, 36) | ||
"Type constraint mismatch. The type \n 'IDictionary<obj,obj>' \nis not compatible with type\n 'Dictionary<obj,obj>' \n" | ||
|
||
[<Test>] | ||
let ``Upcast Instead Of Downcast``() = | ||
CompilerAssert.TypeCheckWithErrors | ||
""" | ||
open System.Collections.Generic | ||
let orig = Dictionary<obj,obj>() | ||
let c = orig :?> IDictionary<obj,obj> | ||
""" | ||
[| | ||
FSharpErrorSeverity.Warning, 67, (5, 9, 5, 38), "This type test or downcast will always hold" | ||
FSharpErrorSeverity.Error, 3198, (5, 9, 5, 38), "The conversion from Dictionary<obj,obj> to IDictionary<obj,obj> is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator." | ||
|] | ||
|
||
[<Test>] | ||
let ``Upcast Function Instead Of Downcast``() = | ||
CompilerAssert.TypeCheckWithErrors | ||
""" | ||
open System.Collections.Generic | ||
let orig = Dictionary<obj,obj>() | ||
let c : IDictionary<obj,obj> = downcast orig | ||
""" | ||
[| | ||
FSharpErrorSeverity.Warning, 67, (5, 32, 5, 45), "This type test or downcast will always hold" | ||
FSharpErrorSeverity.Error, 3198, (5, 32, 5, 45), "The conversion from Dictionary<obj,obj> to IDictionary<obj,obj> is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'." | ||
|] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
tests/fsharpqa/Source/Warnings/UpcastFunctionInsteadOfDowncast.fs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters