Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
e10b8d04
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e10b8d04
编写于
5月 18, 2015
作者:
P
Patrick McDonald
提交者:
latkin
5月 18, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
truncate should not throw ArgumentException when count is negative
fixes #453 closes #454
上级
2044977c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
12 addition
and
9 deletion
+12
-9
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
.../FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
+2
-1
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
...s/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
+2
-1
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
...ts/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
+5
-0
src/fsharp/FSharp.Core/array.fs
src/fsharp/FSharp.Core/array.fs
+1
-2
src/fsharp/FSharp.Core/array.fsi
src/fsharp/FSharp.Core/array.fsi
+0
-1
src/fsharp/FSharp.Core/list.fsi
src/fsharp/FSharp.Core/list.fsi
+0
-1
src/fsharp/FSharp.Core/local.fs
src/fsharp/FSharp.Core/local.fs
+2
-3
未找到文件。
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
浏览文件 @
e10b8d04
...
...
@@ -939,7 +939,8 @@ type ArrayModule2() =
CheckThrowsArgumentNullException
(
fun
()
->
Array
.
truncate
1
null
|>
ignore
)
// negative count
CheckThrowsArgumentException
(
fun
()
->
Array
.
truncate
-
1
[|
1
..
5
|]
|>
ignore
)
Assert
.
AreEqual
([|
|],
Array
.
truncate
-
1
[|
1
..
5
|])
Assert
.
AreEqual
([|
|],
Array
.
truncate
System
.
Int32
.
MinValue
[|
1
..
5
|])
()
...
...
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
浏览文件 @
e10b8d04
...
...
@@ -815,7 +815,8 @@ type ListModule02() =
Assert
.
AreEqual
([],
List
.
truncate
1
[]
)
// negative count
CheckThrowsArgumentException
(
fun
()
->
List
.
truncate
-
1
[
1
..
5
]
|>
ignore
)
Assert
.
AreEqual
([],
List
.
truncate
-
1
[
1
..
5
])
Assert
.
AreEqual
([],
List
.
truncate
System
.
Int32
.
MinValue
[
1
..
5
])
()
...
...
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
浏览文件 @
e10b8d04
...
...
@@ -1533,6 +1533,11 @@ type SeqModule2() =
// null Seq
CheckThrowsArgumentNullException
(
fun
()
->
Seq
.
truncate
1
null
|>
ignore
)
// negative count
VerifySeqsEqual
Seq
.
empty
<|
Seq
.
truncate
-
1
(
seq
[
1
;
2
;
4
;
5
;
7
])
VerifySeqsEqual
Seq
.
empty
<|
Seq
.
truncate
System
.
Int32
.
MinValue
(
seq
[
1
;
2
;
4
;
5
;
7
])
()
[<
Test
>]
...
...
src/fsharp/FSharp.Core/array.fs
浏览文件 @
e10b8d04
...
...
@@ -1001,8 +1001,7 @@ namespace Microsoft.FSharp.Collections
[<
CompiledName
(
"Truncate"
)>]
let
truncate
count
(
array
:
'
T
[]
)
=
checkNonNull
"array"
array
if
count
<
0
then
invalidArg
"count"
(
SR
.
GetString
(
SR
.
inputMustBeNonNegative
))
if
count
=
0
then
empty
if
count
<=
0
then
empty
else
let
len
=
array
.
Length
let
count'
=
Operators
.
min
count
len
...
...
src/fsharp/FSharp.Core/array.fsi
浏览文件 @
e10b8d04
...
...
@@ -981,7 +981,6 @@ namespace Microsoft.FSharp.Collections
/// <param name="array">The input array.</param>
/// <returns>The result array.</returns>
/// <exception cref="System.ArgumentNullException">Thrown when the input array is null.</exception>
/// <exception cref="System.ArgumentException">Thrown when the count is negative.</exception>
[<
CompiledName
(
"Truncate"
)>]
val
truncate
:
count
:
int
->
array
:
'
T
[]
->
'
T
[]
...
...
src/fsharp/FSharp.Core/list.fsi
浏览文件 @
e10b8d04
...
...
@@ -778,7 +778,6 @@ namespace Microsoft.FSharp.Collections
/// <param name="count">The maximum number of items to return.</param>
/// <param name="array">The input list.</param>
/// <returns>The result list.</returns>
/// <exception cref="System.ArgumentException">Thrown when the count is negative.</exception>
[<
CompiledName
(
"Truncate"
)>]
val
truncate
:
count
:
int
->
list
:
'
T
list
->
'
T
list
...
...
src/fsharp/FSharp.Core/local.fs
浏览文件 @
e10b8d04
...
...
@@ -441,17 +441,16 @@ module internal List =
truncateToFreshConsTail
cons2
(
count
-
1
)
t
let
truncate
count
list
=
if
count
<
0
then
invalidArg
"count"
(
SR
.
GetString
(
SR
.
inputMustBeNonNegative
))
match
list
with
|
[]
->
list
|
_
::
([]
as
nil
)
->
if
count
>
0
then
list
else
nil
|
h
::
t
->
if
count
=
0
then
[]
if
count
<
=
0
then
[]
else
let
cons
=
freshConsNoTail
h
truncateToFreshConsTail
cons
(
count
-
1
)
t
cons
let
rec
unfoldToFreshConsTail
cons
f
s
=
match
f
s
with
|
None
->
setFreshConsTail
cons
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录