Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1dbb457e
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1dbb457e
编写于
10月 07, 2013
作者:
H
henryjen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8025968: Integrate test improvements made in lambda repo
Reviewed-by: psandoz
上级
a7fd2002
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
88 deletion
+86
-88
test/java/util/stream/bootlib/java/util/stream/OpTestCase.java
...java/util/stream/bootlib/java/util/stream/OpTestCase.java
+82
-87
test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
...est/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
+3
-0
test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java
...st/org/openjdk/tests/java/util/stream/TabulatorsTest.java
+1
-1
未找到文件。
test/java/util/stream/bootlib/java/util/stream/OpTestCase.java
浏览文件 @
1dbb457e
...
...
@@ -30,7 +30,6 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.EnumMap
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -41,7 +40,6 @@ import java.util.function.BiConsumer;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
...
...
@@ -397,14 +395,68 @@ public abstract class OpTestCase extends LoggingTestCase {
// Exercise terminal operations
static
enum
TerminalTestScenario
{
SINGLE_SEQUENTIAL
,
SINGLE_SEQUENTIAL_SHORT_CIRCUIT
,
SINGLE_PARALLEL
,
ALL_SEQUENTIAL
,
ALL_SEQUENTIAL_SHORT_CIRCUIT
,
ALL_PARALLEL
,
ALL_PARALLEL_SEQUENTIAL
,
interface
BaseTerminalTestScenario
<
U
,
R
,
S_OUT
extends
BaseStream
<
U
,
S_OUT
>>
{
boolean
requiresSingleStageSource
();
boolean
requiresParallelSource
();
default
R
run
(
Function
<
S_OUT
,
R
>
terminalF
,
S_OUT
source
,
StreamShape
shape
)
{
return
terminalF
.
apply
(
source
);
}
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
static
enum
TerminalTestScenario
implements
BaseTerminalTestScenario
{
SINGLE_SEQUENTIAL
(
true
,
false
),
SINGLE_SEQUENTIAL_SHORT_CIRCUIT
(
true
,
false
)
{
@Override
public
Object
run
(
Function
terminalF
,
BaseStream
source
,
StreamShape
shape
)
{
source
=
(
BaseStream
)
chain
(
source
,
new
ShortCircuitOp
(
shape
));
return
terminalF
.
apply
(
source
);
}
},
SINGLE_PARALLEL
(
true
,
true
),
ALL_SEQUENTIAL
(
false
,
false
),
ALL_SEQUENTIAL_SHORT_CIRCUIT
(
false
,
false
)
{
@Override
public
Object
run
(
Function
terminalF
,
BaseStream
source
,
StreamShape
shape
)
{
source
=
(
BaseStream
)
chain
(
source
,
new
ShortCircuitOp
(
shape
));
return
terminalF
.
apply
(
source
);
}
},
ALL_PARALLEL
(
false
,
true
),
ALL_PARALLEL_SEQUENTIAL
(
false
,
false
)
{
@Override
public
Object
run
(
Function
terminalF
,
BaseStream
source
,
StreamShape
shape
)
{
return
terminalF
.
apply
(
source
.
sequential
());
}
},
;
private
final
boolean
requiresSingleStageSource
;
private
final
boolean
isParallel
;
TerminalTestScenario
(
boolean
requiresSingleStageSource
,
boolean
isParallel
)
{
this
.
requiresSingleStageSource
=
requiresSingleStageSource
;
this
.
isParallel
=
isParallel
;
}
@Override
public
boolean
requiresSingleStageSource
()
{
return
requiresSingleStageSource
;
}
@Override
public
boolean
requiresParallelSource
()
{
return
isParallel
;
}
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
...
...
@@ -415,8 +467,6 @@ public abstract class OpTestCase extends LoggingTestCase {
R
refResult
;
Set
<
TerminalTestScenario
>
testSet
=
EnumSet
.
allOf
(
TerminalTestScenario
.
class
);
ResultAsserter
<
R
>
resultAsserter
=
(
act
,
exp
,
ord
,
par
)
->
LambdaTestHelpers
.
assertContentsEqual
(
act
,
exp
);
private
ExerciseDataTerminalBuilder
(
TestData
<
T
,
S_IN
>
data
,
Function
<
S_IN
,
S_OUT
>
streamF
,
Function
<
S_OUT
,
R
>
terminalF
)
{
...
...
@@ -442,27 +492,6 @@ public abstract class OpTestCase extends LoggingTestCase {
return
this
;
}
public
ExerciseDataTerminalBuilder
<
T
,
U
,
R
,
S_IN
,
S_OUT
>
without
(
TerminalTestScenario
...
tests
)
{
return
without
(
Arrays
.
asList
(
tests
));
}
public
ExerciseDataTerminalBuilder
<
T
,
U
,
R
,
S_IN
,
S_OUT
>
without
(
Collection
<
TerminalTestScenario
>
tests
)
{
testSet
.
removeAll
(
tests
);
if
(
testSet
.
isEmpty
())
{
throw
new
IllegalStateException
(
"Terminal test scenario set is empty"
);
}
return
this
;
}
public
ExerciseDataTerminalBuilder
<
T
,
U
,
R
,
S_IN
,
S_OUT
>
with
(
TerminalTestScenario
...
tests
)
{
return
with
(
Arrays
.
asList
(
tests
));
}
public
ExerciseDataTerminalBuilder
<
T
,
U
,
R
,
S_IN
,
S_OUT
>
with
(
Collection
<
TerminalTestScenario
>
tests
)
{
testSet
.
addAll
(
tests
);
return
this
;
}
// Build method
public
R
exercise
()
{
...
...
@@ -471,70 +500,36 @@ public abstract class OpTestCase extends LoggingTestCase {
boolean
isOrdered
=
StreamOpFlag
.
ORDERED
.
isKnown
(
ap
.
getStreamFlags
());
StreamShape
shape
=
ap
.
getOutputShape
();
EnumSet
<
TerminalTestScenario
>
tests
=
EnumSet
.
allOf
(
TerminalTestScenario
.
class
);
// Sequentially collect the output that will be input to the terminal op
Node
<
U
>
node
=
ap
.
evaluateToArrayNode
(
size
->
(
U
[])
new
Object
[
size
]);
if
(
refResult
==
null
)
{
// Sequentially collect the output that will be input to the terminal op
refResult
=
terminalF
.
apply
((
S_OUT
)
createPipeline
(
shape
,
node
.
spliterator
(),
StreamOpFlag
.
IS_ORDERED
|
StreamOpFlag
.
IS_SIZED
,
false
));
}
else
if
(
testSet
.
contains
(
TerminalTestScenario
.
SINGLE_SEQUENTIAL
))
{
S_OUT
source
=
(
S_OUT
)
createPipeline
(
shape
,
node
.
spliterator
(),
StreamOpFlag
.
IS_ORDERED
|
StreamOpFlag
.
IS_SIZED
,
false
);
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
false
),
()
->
String
.
format
(
"Single sequential: %s != %s"
,
refResult
,
result
));
}
if
(
testSet
.
contains
(
TerminalTestScenario
.
SINGLE_SEQUENTIAL_SHORT_CIRCUIT
))
{
// Induce the reference result
S_OUT
source
=
(
S_OUT
)
createPipeline
(
shape
,
node
.
spliterator
(),
StreamOpFlag
.
IS_ORDERED
|
StreamOpFlag
.
IS_SIZED
,
false
);
// Force short-circuit
source
=
(
S_OUT
)
chain
(
source
,
new
ShortCircuitOp
<
U
>(
shape
));
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
false
),
()
->
String
.
format
(
"Single sequential pull: %s != %s"
,
refResult
,
result
));
}
if
(
testSet
.
contains
(
TerminalTestScenario
.
SINGLE_PARALLEL
))
{
S_OUT
source
=
(
S_OUT
)
createPipeline
(
shape
,
node
.
spliterator
(),
StreamOpFlag
.
IS_ORDERED
|
StreamOpFlag
.
IS_SIZED
,
true
);
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
true
),
()
->
String
.
format
(
"Single parallel: %s != %s"
,
refResult
,
result
));
refResult
=
(
R
)
TerminalTestScenario
.
SINGLE_SEQUENTIAL
.
run
(
terminalF
,
source
,
shape
);
tests
.
remove
(
TerminalTestScenario
.
SINGLE_SEQUENTIAL
);
}
if
(
testSet
.
contains
(
TerminalTestScenario
.
ALL_SEQUENTIAL
))
{
// This may forEach or tryAdvance depending on the terminal op implementation
S_OUT
source
=
streamF
.
apply
(
data
.
stream
());
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
false
),
()
->
String
.
format
(
"All sequential: %s != %s"
,
refResult
,
result
));
}
if
(
testSet
.
contains
(
TerminalTestScenario
.
ALL_SEQUENTIAL_SHORT_CIRCUIT
))
{
S_OUT
source
=
streamF
.
apply
(
data
.
stream
());
// Force short-circuit
source
=
(
S_OUT
)
chain
(
source
,
new
ShortCircuitOp
<
U
>(
shape
));
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
false
),
()
->
String
.
format
(
"All sequential pull: %s != %s"
,
refResult
,
result
));
}
for
(
BaseTerminalTestScenario
test
:
tests
)
{
S_OUT
source
;
if
(
test
.
requiresSingleStageSource
())
{
source
=
(
S_OUT
)
createPipeline
(
shape
,
node
.
spliterator
(),
StreamOpFlag
.
IS_ORDERED
|
StreamOpFlag
.
IS_SIZED
,
test
.
requiresParallelSource
());
}
else
{
source
=
streamF
.
apply
(
test
.
requiresParallelSource
()
?
data
.
parallelStream
()
:
data
.
stream
());
}
if
(
testSet
.
contains
(
TerminalTestScenario
.
ALL_PARALLEL
))
{
S_OUT
source
=
streamF
.
apply
(
data
.
parallelStream
());
R
result
=
terminalF
.
apply
(
source
);
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
true
),
()
->
String
.
format
(
"All parallel: %s != %s"
,
refResult
,
result
));
}
R
result
=
(
R
)
test
.
run
(
terminalF
,
source
,
shape
);
if
(
testSet
.
contains
(
TerminalTestScenario
.
ALL_PARALLEL_SEQUENTIAL
))
{
S_OUT
source
=
streamF
.
apply
(
data
.
parallelStream
());
R
result
=
terminalF
.
apply
(
source
.
sequential
());
LambdaTestHelpers
.
launderAssertion
(()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
false
),
()
->
String
.
format
(
"All parallel then sequential: %s != %s"
,
refResult
,
result
));
LambdaTestHelpers
.
launderAssertion
(
()
->
resultAsserter
.
assertResult
(
result
,
refResult
,
isOrdered
,
test
.
requiresParallelSource
()),
()
->
String
.
format
(
"%s: %s != %s"
,
test
,
refResult
,
result
));
}
return
refResult
;
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
浏览文件 @
1dbb457e
...
...
@@ -64,6 +64,9 @@ public class ExplodeOpTest extends OpTestCase {
result
=
exerciseOps
(
data
,
s
->
s
.
flatMap
(
mfNull
));
assertEquals
(
0
,
result
.
size
());
result
=
exerciseOps
(
data
,
s
->
s
.
flatMap
(
e
->
Stream
.
empty
()));
assertEquals
(
0
,
result
.
size
());
exerciseOps
(
data
,
s
->
s
.
flatMap
(
mfLt
));
exerciseOps
(
data
,
s
->
s
.
flatMap
(
integerRangeMapper
));
exerciseOps
(
data
,
s
->
s
.
flatMap
((
Integer
e
)
->
IntStream
.
range
(
0
,
e
).
boxed
().
limit
(
10
)));
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java
浏览文件 @
1dbb457e
...
...
@@ -609,7 +609,7 @@ public class TabulatorsTest extends OpTestCase {
@Test
(
dataProvider
=
"StreamTestData<Integer>"
,
dataProviderClass
=
StreamTestDataProvider
.
class
)
public
void
testComposeFinisher
(
String
name
,
TestData
.
OfRef
<
Integer
>
data
)
throws
ReflectiveOperationException
{
List
<
Integer
>
asList
=
exerciseTerminalOps
(
data
,
s
->
s
.
collect
(
toList
()));
List
<
Integer
>
asImmutableList
=
exerciseTerminalOps
(
data
,
s
->
s
.
collect
(
collectingAndThen
(
toList
(),
Collections:
:
<
Integer
>
unmodifiableList
)));
List
<
Integer
>
asImmutableList
=
exerciseTerminalOps
(
data
,
s
->
s
.
collect
(
collectingAndThen
(
toList
(),
Collections:
:
unmodifiableList
)));
assertEquals
(
asList
,
asImmutableList
);
try
{
asImmutableList
.
add
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录