-
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.
Move fsharpqa/Libraries/Core/Collections test cases to NUnit (#9292)
* Moved some test cased to NUnit * Moved List.head and List.tail test cases to NUnit * Split tests into multiple files * Moved IEnumerable test cases to NUnit * Removed migrated test cases * Fixed positions in List tests
- Loading branch information
1 parent
f422dc3
commit 4df8f8e
Showing
11 changed files
with
151 additions
and
101 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
tests/fsharp/Compiler/Libraries/Core/Collections/CollectionTests.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,28 @@ | ||
// 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 ``Array2D Tests`` = | ||
|
||
[<Test>] | ||
let ``Iter should not throw on non-zero based 2D arrays``() = | ||
// Regression for FSHARP1.0: 5919 | ||
// bug in array2D functions would cause iter to blow up | ||
|
||
let a = Array2D.createBased 1 5 10 10 0.0 | ||
let testDelegate = TestDelegate (fun _ -> a |> Array2D.iter (printf "%f")) | ||
|
||
Assert.DoesNotThrow testDelegate | ||
|
||
[<Test>] | ||
let ``Iteri should not throw on non-zero based 2D arrays``() = | ||
// Regression for FSHARP1.0: 5919 | ||
// bug in array2D functions would cause iteri to blow up | ||
|
||
let a = Array2D.createBased 1 5 10 10 0.0 | ||
let testDelegate = TestDelegate (fun _ -> a |> Array2D.iteri (fun _ _ x -> printf "%f" x)) | ||
|
||
Assert.DoesNotThrow testDelegate |
43 changes: 43 additions & 0 deletions
43
tests/fsharp/Compiler/Libraries/Core/Collections/IEnumerableTests.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,43 @@ | ||
// 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 ``IEnumerable Tests`` = | ||
|
||
// Regression test for FSHARP1.0:4726 | ||
// Makes sure that the .Dispose() method, if available, in invoked on IEnumerable | ||
|
||
let mutable dispose_called_in_E = 0 // we expect this to be incremented 3 times | ||
let mutable dispose_called_in_C = 0 // we expect this to be incremented once (=this is what the bug was about, i.e. .Dispose() was never invoked) | ||
|
||
type E(_c:int) = class | ||
interface System.IDisposable with | ||
member __.Dispose () = dispose_called_in_E <- dispose_called_in_E + 1 | ||
end | ||
|
||
type C() = class | ||
let mutable i = 0 | ||
interface System.Collections.IEnumerator with | ||
member __.Current with get () = new E(i) :> obj | ||
member __.MoveNext () = | ||
i <- i+1 | ||
i<4 | ||
member __.Reset () = i <- 0 | ||
interface System.Collections.IEnumerable with | ||
member x.GetEnumerator () = x :> System.Collections.IEnumerator | ||
|
||
interface System.IDisposable with | ||
member __.Dispose () = dispose_called_in_C <- dispose_called_in_C + 1 | ||
end | ||
end | ||
|
||
[<Test>] | ||
let ``Dispose``() = | ||
let _ = Seq.cast (new C()) |> Seq.map (fun x -> use o = x; | ||
o) |> Seq.length | ||
|
||
Assert.areEqual 3 dispose_called_in_E | ||
Assert.areEqual 1 dispose_called_in_C |
59 changes: 59 additions & 0 deletions
59
tests/fsharp/Compiler/Libraries/Core/Collections/ListTests.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,59 @@ | ||
// 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 ``List Tests`` = | ||
|
||
[<Test>] | ||
let ``List hd should not exist``() = | ||
// Regression test for FSharp1.0:5641 | ||
// Title: List.hd/tl --> List.head/tail | ||
|
||
CompilerAssert.TypeCheckSingleError | ||
""" | ||
List.hd [1] |> ignore | ||
""" | ||
FSharpErrorSeverity.Error | ||
39 | ||
(2, 6, 2, 8) | ||
"The value, constructor, namespace or type 'hd' is not defined." | ||
|
||
|
||
|
||
[<Test>] | ||
let ``List tl should not exist``() = | ||
// Regression test for FSharp1.0:5641 | ||
// Title: List.hd/tl --> List.head/tail | ||
|
||
CompilerAssert.TypeCheckSingleError | ||
""" | ||
List.tl [1] |> ignore | ||
""" | ||
FSharpErrorSeverity.Error | ||
39 | ||
(2, 6, 2, 8) | ||
"The value, constructor, namespace or type 'tl' is not defined." | ||
|
||
[<Test>] | ||
let ``List head of empty list``() = | ||
let testDelegate = TestDelegate (fun _ -> (List.head [] |> ignore)) | ||
|
||
Assert.Throws<System.ArgumentException> testDelegate |> ignore | ||
|
||
[<Test>] | ||
let ``List tail of empty list``() = | ||
let testDelegate = TestDelegate (fun _ -> (List.tail [] |> ignore)) | ||
|
||
Assert.Throws<System.ArgumentException> testDelegate |> ignore | ||
|
||
[<Test>] | ||
let ``List head and tail``() = | ||
Assert.areEqual 1 (List.head [1 .. 10]) | ||
Assert.areEqual "a" (List.head ["a"]) | ||
Assert.areEqual [2 .. 10] (List.tail [1 .. 10]) | ||
Assert.areEqual [] (List.tail [1]) | ||
Assert.areEqual (List.head (List.tail ['a'; 'a'])) (List.head ['a'; 'a']) |
17 changes: 17 additions & 0 deletions
17
tests/fsharp/Compiler/Libraries/Core/Collections/MapTests.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,17 @@ | ||
// 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 ``Map Tests`` = | ||
|
||
[<Test>] | ||
let ``Equality should be implemented on map``() = | ||
// Dev11:19569 - this used to throw an ArgumentException saying Object didn't implement IComparable | ||
|
||
let m = Map.ofArray [| 1, obj() |] | ||
let testDelegate = TestDelegate (fun _ -> (m = m) |> ignore) | ||
|
||
Assert.DoesNotThrow testDelegate |
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
10 changes: 0 additions & 10 deletions
10
tests/fsharpqa/Source/Libraries/Core/Collections/Array2DIter01.fs
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
tests/fsharpqa/Source/Libraries/Core/Collections/Array2DIter02.fs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/fsharpqa/Source/Libraries/Core/Collections/EqualityOnMap01.fs
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
tests/fsharpqa/Source/Libraries/Core/Collections/Seq_Cast_Dispose01.fs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
tests/fsharpqa/Source/Libraries/Core/Collections/list_head_tail01.fs
This file was deleted.
Oops, something went wrong.