Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
4d862aad
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4d862aad
编写于
1月 11, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 11, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7180 fix taskpool xts bugs
Merge pull request !7180 from cwx1148594/master
上级
95c81a4e
39b80d2a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
433 addition
and
191 deletion
+433
-191
commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
...s/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
+433
-191
未找到文件。
commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
浏览文件 @
4d862aad
...
...
@@ -16,9 +16,19 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
taskpool
from
'
@ohos.taskpool
'
import
worker
from
"
@ohos.worker
"
export
default
function
TaskPoolTest
()
{
describe
(
'
ActsAbilityTest
'
,
function
(
done
)
{
describe
(
'
ActsAbilityTest
'
,
function
()
{
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
function
promiseCase
()
{
let
p
=
new
Promise
(
function
(
resolve
,
reject
)
{
setTimeout
(
function
()
{
resolve
()
},
100
)
}).
then
(
undefined
,
(
error
)
=>
{
})
return
p
}
it
(
'
TaskPoolTestClass001
'
,
0
,
async
function
(
done
)
{
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
...
...
@@ -311,10 +321,17 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result
;
var
isTerminate
=
false
;
var
task
=
new
taskpool
.
Task
(
Sum
,
10
,
20
)
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
30
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
30
);
done
();
})
...
...
@@ -326,9 +343,16 @@ describe('ActsAbilityTest', function (done) {
return
false
;
}
var
task
=
new
taskpool
.
Task
(
Add
,
true
,
true
)
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
true
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
true
);
done
();
})
...
...
@@ -337,9 +361,16 @@ describe('ActsAbilityTest', function (done) {
return
value1
+
value2
;
}
var
task
=
new
taskpool
.
Task
(
StrCat
,
"
abc
"
,
"
def
"
)
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
"
abcdef
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
"
abcdef
"
);
done
();
})
...
...
@@ -351,9 +382,16 @@ describe('ActsAbilityTest', function (done) {
return
value1
+
StrCat
(
value2
,
"
hello
"
);
}
var
task
=
new
taskpool
.
Task
(
Sum
,
"
abc
"
,
"
def
"
);
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
"
abcdefhello
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
"
abcdefhello
"
);
done
();
})
...
...
@@ -365,10 +403,17 @@ describe('ActsAbilityTest', function (done) {
return
value
;
}
var
task
=
new
taskpool
.
Task
(
Sum
,
[
1
,
2
],
[
3
,
4
]);
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
[
0
]).
assertEqual
(
4
)
;
expect
(
ret
[
1
]).
assertEqual
(
6
)
;
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
[
0
]).
assertEqual
(
4
);
expect
(
result
[
1
]).
assertEqual
(
6
);
done
();
})
...
...
@@ -380,9 +425,16 @@ describe('ActsAbilityTest', function (done) {
return
value
;
}
var
task
=
new
taskpool
.
Task
(
Sum
,
{
"
a
"
:
1
,
"
b
"
:
2
},
{
"
a
"
:
3
,
"
b
"
:
4
});
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
JSON
.
stringify
(
ret
)).
assertEqual
(
"
{
\"
a
\"
:4,
\"
b
\"
:6}
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
JSON
.
stringify
(
result
)).
assertEqual
(
"
{
\"
a
\"
:4,
\"
b
\"
:6}
"
);
done
();
})
...
...
@@ -391,9 +443,16 @@ describe('ActsAbilityTest', function (done) {
return
value1
+
value2
;
}
var
task
=
new
taskpool
.
Task
(
Sum
,
10
);
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
NaN
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
.
toString
()).
assertEqual
(
"
NaN
"
);
done
();
})
...
...
@@ -402,9 +461,16 @@ describe('ActsAbilityTest', function (done) {
return
value1
+
value2
;
}
var
task
=
new
taskpool
.
Task
(
Sum
,
10
,
20
,
30
);
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
task
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
30
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
30
);
done
();
})
...
...
@@ -412,15 +478,27 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result1
;
var
result2
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
var
task1
=
new
taskpool
.
Task
(
Sum
,
10
,
20
);
taskpool
.
execute
(
task1
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
var
task2
=
new
taskpool
.
Task
(
Sum
,
30
,
40
);
taskpool
.
execute
(
task2
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
70
);
result2
=
ret2
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
70
);
done
();
})
...
...
@@ -428,15 +506,26 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result1
;
var
result2
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
var
task1
=
new
taskpool
.
Task
(
Sum
,
10
,
20
)
taskpool
.
execute
(
task1
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
var
task2
=
new
taskpool
.
Task
(
Sum
,
10
,
20
)
taskpool
.
execute
(
task2
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
30
);
result2
=
ret2
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
30
);
done
();
})
...
...
@@ -444,13 +533,25 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result1
;
var
result2
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
var
task
=
new
taskpool
.
Task
(
Sum
,
10
,
20
)
taskpool
.
execute
(
task
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
task
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
30
);
result2
=
ret2
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
30
);
done
();
})
...
...
@@ -462,22 +563,43 @@ describe('ActsAbilityTest', function (done) {
return
value1
*
value2
;
}
var
result1
;
var
result2
;
var
result3
;
var
result4
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
var
isTerminate3
=
false
;
var
isTerminate4
=
false
;
var
task1
=
new
taskpool
.
Task
(
Sum
,
10
,
20
)
taskpool
.
execute
(
task1
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
var
task2
=
new
taskpool
.
Task
(
Multi
,
10
,
20
)
taskpool
.
execute
(
task2
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
200
);
result2
=
ret2
;
isTerminate2
=
true
;
})
var
task3
=
new
taskpool
.
Task
(
Sum
,
10
,
30
)
taskpool
.
execute
(
task3
).
then
((
ret3
)
=>
{
expect
(
ret3
).
assertEqual
(
40
);
result3
=
ret3
;
isTerminate3
=
true
;
})
var
task4
=
new
taskpool
.
Task
(
Multi
,
20
,
20
)
taskpool
.
execute
(
task4
).
then
((
ret4
)
=>
{
expect
(
ret4
).
assertEqual
(
400
);
result4
=
ret4
;
isTerminate4
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
||
!
isTerminate3
||
!
isTerminate4
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
200
);
expect
(
result3
).
assertEqual
(
40
);
expect
(
result4
).
assertEqual
(
400
);
done
();
})
...
...
@@ -485,9 +607,16 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
30
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
30
);
done
();
})
...
...
@@ -498,9 +627,16 @@ describe('ActsAbilityTest', function (done) {
else
return
false
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Add
,
true
,
false
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
false
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
false
);
done
();
})
...
...
@@ -508,9 +644,16 @@ describe('ActsAbilityTest', function (done) {
function
StrCat
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
StrCat
,
"
abc
"
,
"
def
"
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
"
abcdef
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
"
abcdef
"
);
done
();
})
...
...
@@ -521,9 +664,16 @@ describe('ActsAbilityTest', function (done) {
}
return
value1
+
StrCat
(
value2
,
"
hello
"
);
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
"
abc
"
,
"
def
"
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
"
abcdefhello
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
"
abcdefhello
"
);
done
();
})
...
...
@@ -534,10 +684,17 @@ describe('ActsAbilityTest', function (done) {
value
[
1
]
=
arg1
[
1
]
+
arg2
[
1
];
return
value
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
[
1
,
2
],
[
3
,
4
]).
then
((
ret
)
=>
{
expect
(
ret
[
0
]).
assertEqual
(
4
)
;
expect
(
ret
[
1
]).
assertEqual
(
6
)
;
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
[
0
]).
assertEqual
(
4
);
expect
(
result
[
1
]).
assertEqual
(
6
);
done
();
})
...
...
@@ -548,9 +705,16 @@ describe('ActsAbilityTest', function (done) {
value
.
b
=
arg1
.
b
+
arg2
.
b
;
return
value
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
{
"
a
"
:
1
,
"
b
"
:
2
},
{
"
a
"
:
3
,
"
b
"
:
4
}).
then
((
ret
)
=>
{
expect
(
JSON
.
stringify
(
ret
)).
assertEqual
(
"
{
\"
a
\"
:4,
\"
b
\"
:6}
"
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
JSON
.
stringify
(
result
)).
assertEqual
(
"
{
\"
a
\"
:4,
\"
b
\"
:6}
"
);
done
();
})
...
...
@@ -558,9 +722,16 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
10
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
NaN
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
.
toString
()).
assertEqual
(
"
NaN
"
);
done
();
})
...
...
@@ -568,9 +739,16 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result
;
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
,
30
).
then
((
ret
)
=>
{
expect
(
ret
).
assertEqual
(
30
);
result
=
ret
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
30
);
done
();
})
...
...
@@ -578,12 +756,24 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result1
;
var
result2
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Sum
,
30
,
40
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
70
);
result2
=
ret2
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
70
);
done
();
})
...
...
@@ -591,12 +781,24 @@ describe('ActsAbilityTest', function (done) {
function
Sum
(
value1
,
value2
)
{
return
value1
+
value2
;
}
var
result1
;
var
result2
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
30
);
result2
=
ret2
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
30
);
done
();
})
...
...
@@ -608,18 +810,38 @@ describe('ActsAbilityTest', function (done) {
return
value1
*
value2
;
}
var
result1
;
var
result2
;
var
result3
;
var
result4
;
var
isTerminate1
=
false
;
var
isTerminate2
=
false
;
var
isTerminate3
=
false
;
var
isTerminate4
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
expect
(
ret1
).
assertEqual
(
30
);
result1
=
ret1
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Multi
,
10
,
20
).
then
((
ret2
)
=>
{
expect
(
ret2
).
assertEqual
(
200
);
result2
=
ret2
;
isTerminate2
=
true
;
})
taskpool
.
execute
(
Sum
,
10
,
30
).
then
((
ret3
)
=>
{
expect
(
ret3
).
assertEqual
(
40
);
result3
=
ret3
;
isTerminate3
=
true
;
})
taskpool
.
execute
(
Multi
,
20
,
20
).
then
((
ret4
)
=>
{
expect
(
ret4
).
assertEqual
(
400
);
result4
=
ret4
;
isTerminate4
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
||
!
isTerminate3
||
!
isTerminate4
)
{
await
promiseCase
()
}
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
200
);
expect
(
result3
).
assertEqual
(
40
);
expect
(
result4
).
assertEqual
(
400
);
done
();
})
...
...
@@ -643,7 +865,7 @@ describe('ActsAbilityTest', function (done) {
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass049
'
,
0
,
async
function
(
done
)
{
it
(
'
TaskPoolTestClass049
'
,
0
,
async
function
(
done
)
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
...
...
@@ -655,18 +877,18 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
""
);
expect
(
e
.
toString
()).
assertEqual
(
""
);
}
done
();
})
...
...
@@ -691,18 +913,18 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
""
);
expect
(
e
.
toString
()).
assertEqual
(
""
);
}
done
();
})
...
...
@@ -727,23 +949,24 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task1
);
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not cancel the running task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task
"
);
}
done
();
})
...
...
@@ -768,23 +991,24 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task1
);
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not cancel the running task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task
"
);
}
done
();
})
...
...
@@ -802,23 +1026,24 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task1
);
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -836,29 +1061,30 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -876,17 +1102,18 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -904,17 +1131,18 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -939,24 +1167,25 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -981,24 +1210,25 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task1
=
new
taskpool
.
Task
(
additionDelay
,
100
);
var
task2
=
new
taskpool
.
Task
(
additionDelay
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -1016,28 +1246,34 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
taskpool
.
cancel
(
task6
);
taskpool
.
cancel
(
task5
);
taskpool
.
cancel
(
task4
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task2
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
100
)
{
continue
;
}
taskpool
.
cancel
(
task6
);
taskpool
.
cancel
(
task5
);
taskpool
.
cancel
(
task4
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task2
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
@@ -1055,28 +1291,34 @@ describe('ActsAbilityTest', function (done) {
return
arg
+
1
;
}
try
{
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
taskpool
.
cancel
(
task6
);
taskpool
.
cancel
(
task5
);
taskpool
.
cancel
(
task4
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task2
);
var
task1
=
new
taskpool
.
Task
(
addition
,
100
);
var
task2
=
new
taskpool
.
Task
(
addition
,
200
);
var
task3
=
new
taskpool
.
Task
(
addition
,
300
);
var
task4
=
new
taskpool
.
Task
(
addition
,
400
);
var
task5
=
new
taskpool
.
Task
(
addition
,
500
);
var
task6
=
new
taskpool
.
Task
(
addition
,
600
);
var
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
var
result4
=
taskpool
.
execute
(
task4
);
var
result5
=
taskpool
.
execute
(
task5
);
var
result6
=
taskpool
.
execute
(
task6
);
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
100
)
{
continue
;
}
taskpool
.
cancel
(
task6
);
taskpool
.
cancel
(
task5
);
taskpool
.
cancel
(
task4
);
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task2
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task
"
);
}
done
();
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录