-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracting obsolete List and Seq functions into separate test module
- Loading branch information
Showing
5 changed files
with
67 additions
and
46 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
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
25 changes: 25 additions & 0 deletions
25
...p/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteListFunctions.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,25 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
#nowarn "44" // This construct is deprecated. please use List.item | ||
namespace FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Collections | ||
|
||
open System | ||
open FSharp.Core.Unittests.LibraryTestFx | ||
open NUnit.Framework | ||
|
||
[<TestFixture>] | ||
type ObsoleteListFunctions() = | ||
[<Test>] | ||
member this.Nth() = | ||
// integer List | ||
let resultInt = List.nth [3;7;9;4;8;1;1;2] 3 | ||
Assert.AreEqual(4, resultInt) | ||
|
||
// string List | ||
let resultStr = List.nth ["a";"b";"c";"d"] 3 | ||
Assert.AreEqual("d", resultStr) | ||
|
||
// empty List | ||
CheckThrowsArgumentException ( fun() -> List.nth List.empty 1) | ||
|
||
() |
40 changes: 40 additions & 0 deletions
40
...rp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.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,40 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
#nowarn "44" // This construct is deprecated. please use Seq.item | ||
namespace FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Collections | ||
|
||
open System | ||
open NUnit.Framework | ||
|
||
open FSharp.Core.Unittests.LibraryTestFx | ||
|
||
[<TestFixture>] | ||
type ObsoleteSeqFunctions() = | ||
|
||
[<Test>] | ||
member this.Nth() = | ||
|
||
// Negative index | ||
for i = -1 downto -10 do | ||
CheckThrowsArgumentException (fun () -> Seq.nth i { 10 .. 20 } |> ignore) | ||
|
||
// Out of range | ||
for i = 11 to 20 do | ||
CheckThrowsArgumentException (fun () -> Seq.nth i { 10 .. 20 } |> ignore) | ||
|
||
// integer Seq | ||
let resultInt = Seq.nth 3 { 10..20 } | ||
Assert.AreEqual(13, resultInt) | ||
|
||
// string Seq | ||
let resultStr = Seq.nth 3 (seq ["Lists"; "Are"; "nthString" ; "List" ]) | ||
Assert.AreEqual("List",resultStr) | ||
|
||
// empty Seq | ||
CheckThrowsArgumentException(fun () -> Seq.nth 0 (Seq.empty : seq<decimal>) |> ignore) | ||
|
||
// null Seq | ||
let nullSeq:seq<'a> = null | ||
CheckThrowsArgumentNullException (fun () ->Seq.nth 3 nullSeq |> ignore) | ||
|
||
() |
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