Skip to content

Commit

Permalink
Add "The input must be positive." error message and use it in windowed
Browse files Browse the repository at this point in the history
Fix #266
  • Loading branch information
PatrickMcDonald committed Feb 23, 2015
1 parent 4267370 commit c6bbef5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/fsharp/FSharp.Core/FSCore.resx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<data name="inputMustBeNonNegative" xml:space="preserve">
<value>The input must be non-negative.</value>
</data>
<data name="inputMustBePositive" xml:space="preserve">
<value>The input must be positive.</value>
</data>
<data name="inputSequenceEmpty" xml:space="preserve">
<value>The input sequence was empty.</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSharp.Core/SR.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module internal SR =
let pickElementNotFound = "pickElementNotFound"
let notEnoughElements = "notEnoughElements"
let inputMustBeNonNegative = "inputMustBeNonNegative"
let inputMustBePositive = "inputMustBePositive"
let enumerationPastIntMaxValue = "enumerationPastIntMaxValue"
let inputSequenceEmpty = "inputSequenceEmpty"
let inputSequenceTooLong = "inputSequenceTooLong"
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ namespace Microsoft.FSharp.Collections
[<CompiledName("Windowed")>]
let windowed windowSize (array:'T[]) =
checkNonNull "array" array
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBeNonNegative))
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBePositive))
let len = array.Length
if windowSize > len then
[| |]
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/local.fs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ module internal List =
windowedToFreshConsTail cons2 windowSize i t arr

let windowed windowSize list =
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBeNonNegative))
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBePositive))
match list with
| [] -> []
| _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/seq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ namespace Microsoft.FSharp.Collections
[<CompiledName("Windowed")>]
let windowed windowSize (source: seq<_>) =
checkNonNull "source" source
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBeNonNegative))
if windowSize <= 0 then invalidArg "windowSize" (SR.GetString(SR.inputMustBePositive))
seq {
let arr = Array.zeroCreateUnchecked windowSize
let r = ref (windowSize - 1)
Expand Down

0 comments on commit c6bbef5

Please sign in to comment.