From 9f7ab69a2ff5170498be1c51933b361c7c1baf6e Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 29 Jan 2015 14:57:06 +0100 Subject: [PATCH] Extracting obsolete List and Seq functions into separate test module --- .../FSharp.Core.Unittests.fsproj | 2 + .../ListModule2.fs | 16 -------- .../ObsoleteListFunctions.fs | 25 ++++++++++++ .../ObsoleteSeqFunctions.fs | 40 +++++++++++++++++++ .../SeqModule2.fs | 30 -------------- 5 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteListFunctions.fs create mode 100644 src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj index 214d3c7db08..622d010760e 100644 --- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj @@ -78,6 +78,7 @@ + @@ -85,6 +86,7 @@ + diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs index b3eefb6aabe..148e73ec45d 100644 --- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs @@ -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 @@ -318,21 +317,6 @@ type ListModule02() = CheckThrowsArgumentException ( fun() -> List.minBy funcEpt List.empty) () - - [] - 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) - - () [] member this.Item() = diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteListFunctions.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteListFunctions.fs new file mode 100644 index 00000000000..877eb2af96e --- /dev/null +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteListFunctions.fs @@ -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 + +[] +type ObsoleteListFunctions() = + [] + 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) + + () \ No newline at end of file diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs new file mode 100644 index 00000000000..0667148599a --- /dev/null +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs @@ -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 + +[] +type ObsoleteSeqFunctions() = + + [] + 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) |> ignore) + + // null Seq + let nullSeq:seq<'a> = null + CheckThrowsArgumentNullException (fun () ->Seq.nth 3 nullSeq |> ignore) + + () \ No newline at end of file diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs index 95c9ecc35ec..1693f926be4 100644 --- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs @@ -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 @@ -896,35 +895,6 @@ type SeqModule2() = () - - [] - 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) |> ignore) - - // null Seq - let nullSeq:seq<'a> = null - CheckThrowsArgumentNullException (fun () ->Seq.nth 3 nullSeq |> ignore) - - () - [] member this.Item() = // integer Seq