Skip to content

Commit

Permalink
Extracting obsolete List and Seq functions into separate test module
Browse files Browse the repository at this point in the history
  • Loading branch information
forki authored and latkin committed Jan 30, 2015
1 parent db6d3b7 commit 9f7ab69
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 46 deletions.
2 changes: 2 additions & 0 deletions src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\HashIdentityModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListModule2.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ObsoleteListFunctions.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\MapModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\MapType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SetModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SetType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SeqModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SeqModule2.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ObsoleteSeqFunctions.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\StringModule.fs" />
<Compile Include="FSharp.Core\PrimTypes.fs" />
<Compile Include="FSharp.Core\DiscrimantedUnionType.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Various tests for the:
// Microsoft.FSharp.Collections.List module

#nowarn "44" // This construct is deprecated. please use List.item
namespace FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Collections

open System
Expand Down Expand Up @@ -318,21 +317,6 @@ type ListModule02() =
CheckThrowsArgumentException ( fun() -> List.minBy funcEpt List.empty)

()

[<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)

()

[<Test>]
member this.Item() =
Expand Down
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)

()
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)

()
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 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
Expand Down Expand Up @@ -896,35 +895,6 @@ type SeqModule2() =

()


[<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)

()

[<Test>]
member this.Item() =
// integer Seq
Expand Down

0 comments on commit 9f7ab69

Please sign in to comment.