-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving ElseBranchHasWrongTypeTests over to NUnit
- Loading branch information
Showing
6 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
tests/fsharp/Compiler/ErrorMessages/ElseBranchHasWrongTypeTests.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,36 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Compiler.UnitTests | ||
|
||
open NUnit.Framework | ||
|
||
[<TestFixture>] | ||
module ElseBranchHasWrongTypeTests = | ||
|
||
[<Test>] | ||
let ``Else branch is int while if branch is string``() = | ||
CompilerAssert.TypeCheckSingleError | ||
""" | ||
let test = 100 | ||
let y = | ||
if test > 10 then "test" | ||
else 123 | ||
""" | ||
1 | ||
(5, 9, 5, 12) | ||
"All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." | ||
|
||
|
||
[<Test>] | ||
let ``Else branch is a function that returns int while if branch is string``() = | ||
CompilerAssert.TypeCheckSingleError | ||
""" | ||
let test = 100 | ||
let f x = test | ||
let y = | ||
if test > 10 then "test" | ||
else f 10 | ||
""" | ||
1 | ||
(6, 9, 6, 13) | ||
"All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." |
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.
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