未验证 提交 02f45609 编写于 作者: O openharmony_ci 提交者: Gitee

!9043 modify and add taskpool xts

Merge pull request !9043 from buzhuyu/master
...@@ -29,17 +29,89 @@ describe('ActsAbilityTest', function () { ...@@ -29,17 +29,89 @@ describe('ActsAbilityTest', function () {
return p return p
} }
it('TaskPoolTestClass001', 0, async function (done) { /**
* @tc.number : TaskPoolTestClass001
* @tc.name : Async Function use taskpool and worker
* @tc.desc : Test Simultaneous use taskpool and worker
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass001', 0, async function (done) {
function testTaskPool() {
function addition(arg) {
"use concurrent"
return arg + 1;
}
function additionDelay(arg) {
"use concurrent"
let start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
}
return arg + 1;
}
try {
let task1 = new taskpool.Task(additionDelay, 100);
let task2 = new taskpool.Task(additionDelay, 200);
let task3 = new taskpool.Task(addition, 300);
taskpool.execute(task1)
taskpool.execute(task2)
taskpool.execute(task3)
let start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
for (let i = 1; i <= 10; i++) {
taskpool.cancel(task1);
}
}
catch (e) {
console.info("taskpoolXTS061 catch error: " + e);
}
}
function promiseCase() {
let p = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(0)
}, 100)
}).then(undefined, (error) => {
})
return p
}
let ss = new worker.ThreadWorker("entry/ets/workers/worker.js")
let res = 0
let flag = false
ss.onexit = function () {
flag = true
res++
}
testTaskPool();
for (let i = 0; i < 10; i++) {
ss.terminate();
}
while (!flag) {
await promiseCase()
}
expect(res).assertEqual(1)
done();
})
it('TaskPoolTestClass002', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result = await taskpool.execute(Sum, 10, 20); let result = await taskpool.execute(Sum, 10, 20);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass002', 0, async function (done) { it('TaskPoolTestClass003', 0, async function (done) {
function Add(value1, value2) { function Add(value1, value2) {
"use concurrent" "use concurrent"
if (value1 & value2) if (value1 & value2)
...@@ -47,33 +119,33 @@ describe('ActsAbilityTest', function () { ...@@ -47,33 +119,33 @@ describe('ActsAbilityTest', function () {
else else
return false; return false;
} }
var result = await taskpool.execute(Add, true, true); let result = await taskpool.execute(Add, true, true);
expect(result).assertEqual(true); expect(result).assertEqual(true);
done(); done();
}) })
it('TaskPoolTestClass003', 0, async function (done) { it('TaskPoolTestClass004', 0, async function (done) {
function StrCat(value1, value2) { function StrCat(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result = await taskpool.execute(StrCat, "abc", "def"); let result = await taskpool.execute(StrCat, "abc", "def");
expect(result).assertEqual("abcdef"); expect(result).assertEqual("abcdef");
done(); done();
}) })
it('TaskPoolTestClass004', 0, async function (done) { it('TaskPoolTestClass005', 0, async function (done) {
function StrCat(value1, value2) { function StrCat(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result = await taskpool.execute(StrCat, "abc", "def"); let result = await taskpool.execute(StrCat, "abc", "def");
result = await taskpool.execute(StrCat, "abc", "def"); result = await taskpool.execute(StrCat, "abc", "def");
expect(result).assertEqual("abcdef"); expect(result).assertEqual("abcdef");
done(); done();
}) })
it('TaskPoolTestClass005', 0, async function (done) { it('TaskPoolTestClass006', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
function StrCat(value1, value2) { function StrCat(value1, value2) {
...@@ -81,12 +153,12 @@ describe('ActsAbilityTest', function () { ...@@ -81,12 +153,12 @@ describe('ActsAbilityTest', function () {
} }
return value1+StrCat(value2,"hello"); return value1+StrCat(value2,"hello");
} }
var result = await taskpool.execute(Sum, "abc", "def"); let result = await taskpool.execute(Sum, "abc", "def");
expect(result).assertEqual("abcdefhello"); expect(result).assertEqual("abcdefhello");
done(); done();
}) })
it('TaskPoolTestClass006', 0, async function (done) { it('TaskPoolTestClass007', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = []; let value = [];
...@@ -94,13 +166,13 @@ describe('ActsAbilityTest', function () { ...@@ -94,13 +166,13 @@ describe('ActsAbilityTest', function () {
value[1] = arg1[1] + arg2[1]; value[1] = arg1[1] + arg2[1];
return value; return value;
} }
var result = await taskpool.execute(Sum, [1,2], [3,4]); let result = await taskpool.execute(Sum, [1,2], [3,4]);
expect(result[0]).assertEqual(4); expect(result[0]).assertEqual(4);
expect(result[1]).assertEqual(6); expect(result[1]).assertEqual(6);
done(); done();
}) })
it('TaskPoolTestClass007', 0, async function (done) { it('TaskPoolTestClass008', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = arg1; let value = arg1;
...@@ -108,56 +180,56 @@ describe('ActsAbilityTest', function () { ...@@ -108,56 +180,56 @@ describe('ActsAbilityTest', function () {
value.b = arg1.b + arg2.b; value.b = arg1.b + arg2.b;
return value; return value;
} }
var result = await taskpool.execute(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4}); let result = await taskpool.execute(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4});
expect(JSON.stringify(result)).assertEqual("{\"a\":4,\"b\":6}"); expect(JSON.stringify(result)).assertEqual("{\"a\":4,\"b\":6}");
done(); done();
}) })
it('TaskPoolTestClass008', 0, async function (done) { it('TaskPoolTestClass009', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result = await taskpool.execute(Sum, 10); let result = await taskpool.execute(Sum, 10);
expect(result.toString()).assertEqual("NaN"); expect(result.toString()).assertEqual("NaN");
done(); done();
}) })
it('TaskPoolTestClass009', 0, async function (done) { it('TaskPoolTestClass010', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result = await taskpool.execute(Sum, 10, 20, 30); let result = await taskpool.execute(Sum, 10, 20, 30);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass010', 0, async function (done) { it('TaskPoolTestClass011', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1 = await taskpool.execute(Sum, 10, 20); let result1 = await taskpool.execute(Sum, 10, 20);
var result2 = await taskpool.execute(Sum, 30, 40); let result2 = await taskpool.execute(Sum, 30, 40);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(70); expect(result2).assertEqual(70);
done(); done();
}) })
it('TaskPoolTestClass011', 0, async function (done) { it('TaskPoolTestClass012', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1 = await taskpool.execute(Sum, 10, 20); let result1 = await taskpool.execute(Sum, 10, 20);
var result2 = await taskpool.execute(Sum, 10, 20); let result2 = await taskpool.execute(Sum, 10, 20);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(30); expect(result2).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass012', 0, async function (done) { it('TaskPoolTestClass013', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
...@@ -166,10 +238,10 @@ describe('ActsAbilityTest', function () { ...@@ -166,10 +238,10 @@ describe('ActsAbilityTest', function () {
"use concurrent" "use concurrent"
return value1 * value2; return value1 * value2;
} }
var result1 = await taskpool.execute(Sum, 10, 20); let result1 = await taskpool.execute(Sum, 10, 20);
var result2 = await taskpool.execute(Multi, 10, 20); let result2 = await taskpool.execute(Multi, 10, 20);
var result3 = await taskpool.execute(Sum, 10, 30); let result3 = await taskpool.execute(Sum, 10, 30);
var result4 = await taskpool.execute(Multi, 20, 20); let result4 = await taskpool.execute(Multi, 20, 20);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(200); expect(result2).assertEqual(200);
expect(result3).assertEqual(40); expect(result3).assertEqual(40);
...@@ -177,18 +249,18 @@ describe('ActsAbilityTest', function () { ...@@ -177,18 +249,18 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass013', 0, async function (done) { it('TaskPoolTestClass014', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10, 20); let task = new taskpool.Task(Sum, 10, 20);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass014', 0, async function (done) { it('TaskPoolTestClass015', 0, async function (done) {
function Add(value1, value2) { function Add(value1, value2) {
"use concurrent" "use concurrent"
if (value1 & value2) if (value1 & value2)
...@@ -196,24 +268,24 @@ describe('ActsAbilityTest', function () { ...@@ -196,24 +268,24 @@ describe('ActsAbilityTest', function () {
else else
return false; return false;
} }
var task = new taskpool.Task(Add, true, true); let task = new taskpool.Task(Add, true, true);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual(true); expect(result).assertEqual(true);
done(); done();
}) })
it('TaskPoolTestClass015', 0, async function (done) { it('TaskPoolTestClass016', 0, async function (done) {
function StrCat(value1, value2) { function StrCat(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(StrCat, "abc", "def"); let task = new taskpool.Task(StrCat, "abc", "def");
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual("abcdef"); expect(result).assertEqual("abcdef");
done(); done();
}) })
it('TaskPoolTestClass016', 0, async function (done) { it('TaskPoolTestClass017', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
function StrCat(value1, value2) { function StrCat(value1, value2) {
...@@ -221,13 +293,13 @@ describe('ActsAbilityTest', function () { ...@@ -221,13 +293,13 @@ describe('ActsAbilityTest', function () {
} }
return value1+StrCat(value2,"hello"); return value1+StrCat(value2,"hello");
} }
var task = new taskpool.Task(Sum, "abc", "def"); let task = new taskpool.Task(Sum, "abc", "def");
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual("abcdefhello"); expect(result).assertEqual("abcdefhello");
done(); done();
}) })
it('TaskPoolTestClass017', 0, async function (done) { it('TaskPoolTestClass018', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = []; let value = [];
...@@ -235,14 +307,14 @@ describe('ActsAbilityTest', function () { ...@@ -235,14 +307,14 @@ describe('ActsAbilityTest', function () {
value[1] = arg1[1] + arg2[1]; value[1] = arg1[1] + arg2[1];
return value; return value;
} }
var task = new taskpool.Task(Sum, [1,2], [3,4]); let task = new taskpool.Task(Sum, [1,2], [3,4]);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result[0]).assertEqual(4); expect(result[0]).assertEqual(4);
expect(result[1]).assertEqual(6); expect(result[1]).assertEqual(6);
done(); done();
}) })
it('TaskPoolTestClass018', 0, async function (done) { it('TaskPoolTestClass019', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = arg1; let value = arg1;
...@@ -250,76 +322,76 @@ describe('ActsAbilityTest', function () { ...@@ -250,76 +322,76 @@ describe('ActsAbilityTest', function () {
value.b = arg1.b + arg2.b; value.b = arg1.b + arg2.b;
return value; return value;
} }
var task = new taskpool.Task(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4}); let task = new taskpool.Task(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4});
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(JSON.stringify(result)).assertEqual("{\"a\":4,\"b\":6}"); expect(JSON.stringify(result)).assertEqual("{\"a\":4,\"b\":6}");
done(); done();
}) })
it('TaskPoolTestClass019', 0, async function (done) { it('TaskPoolTestClass020', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10); let task = new taskpool.Task(Sum, 10);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result.toString()).assertEqual("NaN"); expect(result.toString()).assertEqual("NaN");
done(); done();
}) })
it('TaskPoolTestClass020', 0, async function (done) { it('TaskPoolTestClass021', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10, 20, 30); let task = new taskpool.Task(Sum, 10, 20, 30);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass021', 0, async function (done) { it('TaskPoolTestClass022', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10, 20); let task = new taskpool.Task(Sum, 10, 20);
var result1 = await taskpool.execute(task); let result1 = await taskpool.execute(task);
var result2 = await taskpool.execute(task); let result2 = await taskpool.execute(task);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(30); expect(result2).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass022', 0, async function (done) { it('TaskPoolTestClass023', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task1 = new taskpool.Task(Sum, 10, 20); let task1 = new taskpool.Task(Sum, 10, 20);
var task2 = new taskpool.Task(Sum, 30, 40); let task2 = new taskpool.Task(Sum, 30, 40);
var result1 = await taskpool.execute(task1); let result1 = await taskpool.execute(task1);
var result2 = await taskpool.execute(task2); let result2 = await taskpool.execute(task2);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(70); expect(result2).assertEqual(70);
done(); done();
}) })
it('TaskPoolTestClass023', 0, async function (done) { it('TaskPoolTestClass024', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task1 = new taskpool.Task(Sum, 10, 20); let task1 = new taskpool.Task(Sum, 10, 20);
var task2 = new taskpool.Task(Sum, 10, 20); let task2 = new taskpool.Task(Sum, 10, 20);
var result1 = await taskpool.execute(task1); let result1 = await taskpool.execute(task1);
var result2 = await taskpool.execute(task2); let result2 = await taskpool.execute(task2);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(30); expect(result2).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass024', 0, async function (done) { it('TaskPoolTestClass025', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
...@@ -328,14 +400,14 @@ describe('ActsAbilityTest', function () { ...@@ -328,14 +400,14 @@ describe('ActsAbilityTest', function () {
"use concurrent" "use concurrent"
return value1 * value2; return value1 * value2;
} }
var task1 = new taskpool.Task(Sum, 10, 20); let task1 = new taskpool.Task(Sum, 10, 20);
var result1 = await taskpool.execute(task1); let result1 = await taskpool.execute(task1);
var task2 = new taskpool.Task(Multi, 10, 20); let task2 = new taskpool.Task(Multi, 10, 20);
var result2 = await taskpool.execute(task2); let result2 = await taskpool.execute(task2);
var task3 = new taskpool.Task(Sum, 10, 30); let task3 = new taskpool.Task(Sum, 10, 30);
var result3 = await taskpool.execute(task3); let result3 = await taskpool.execute(task3);
var task4 = new taskpool.Task(Multi, 20, 20); let task4 = new taskpool.Task(Multi, 20, 20);
var result4 = await taskpool.execute(task4); let result4 = await taskpool.execute(task4);
expect(result1).assertEqual(30); expect(result1).assertEqual(30);
expect(result2).assertEqual(200); expect(result2).assertEqual(200);
expect(result3).assertEqual(40); expect(result3).assertEqual(40);
...@@ -343,14 +415,14 @@ describe('ActsAbilityTest', function () { ...@@ -343,14 +415,14 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass025', 0, async function (done) { it('TaskPoolTestClass026', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
var task = new taskpool.Task(Sum, 10, 20) let task = new taskpool.Task(Sum, 10, 20)
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -362,7 +434,7 @@ describe('ActsAbilityTest', function () { ...@@ -362,7 +434,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass026', 0, async function (done) { it('TaskPoolTestClass027', 0, async function (done) {
function Add(value1, value2) { function Add(value1, value2) {
"use concurrent" "use concurrent"
if (value1 & value2) if (value1 & value2)
...@@ -370,9 +442,9 @@ describe('ActsAbilityTest', function () { ...@@ -370,9 +442,9 @@ describe('ActsAbilityTest', function () {
else else
return false; return false;
} }
var task = new taskpool.Task(Add, true, true) let task = new taskpool.Task(Add, true, true)
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -384,14 +456,14 @@ describe('ActsAbilityTest', function () { ...@@ -384,14 +456,14 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass027', 0, async function (done) { it('TaskPoolTestClass028', 0, async function (done) {
function StrCat(value1, value2) { function StrCat(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(StrCat, "abc", "def") let task = new taskpool.Task(StrCat, "abc", "def")
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -403,7 +475,7 @@ describe('ActsAbilityTest', function () { ...@@ -403,7 +475,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass028', 0, async function (done) { it('TaskPoolTestClass029', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
function StrCat(value1, value2) { function StrCat(value1, value2) {
...@@ -411,9 +483,9 @@ describe('ActsAbilityTest', function () { ...@@ -411,9 +483,9 @@ describe('ActsAbilityTest', function () {
} }
return value1+StrCat(value2,"hello"); return value1+StrCat(value2,"hello");
} }
var task = new taskpool.Task(Sum, "abc", "def"); let task = new taskpool.Task(Sum, "abc", "def");
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -425,7 +497,7 @@ describe('ActsAbilityTest', function () { ...@@ -425,7 +497,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass029', 0, async function (done) { it('TaskPoolTestClass030', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = []; let value = [];
...@@ -433,9 +505,9 @@ describe('ActsAbilityTest', function () { ...@@ -433,9 +505,9 @@ describe('ActsAbilityTest', function () {
value[1] = arg1[1] + arg2[1]; value[1] = arg1[1] + arg2[1];
return value; return value;
} }
var task = new taskpool.Task(Sum, [1,2], [3,4]); let task = new taskpool.Task(Sum, [1,2], [3,4]);
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -448,7 +520,7 @@ describe('ActsAbilityTest', function () { ...@@ -448,7 +520,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass030', 0, async function (done) { it('TaskPoolTestClass031', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = arg1; let value = arg1;
...@@ -456,9 +528,9 @@ describe('ActsAbilityTest', function () { ...@@ -456,9 +528,9 @@ describe('ActsAbilityTest', function () {
value.b = arg1.b + arg2.b; value.b = arg1.b + arg2.b;
return value; return value;
} }
var task = new taskpool.Task(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4}); let task = new taskpool.Task(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4});
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -470,14 +542,14 @@ describe('ActsAbilityTest', function () { ...@@ -470,14 +542,14 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass031', 0, async function (done) { it('TaskPoolTestClass032', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10); let task = new taskpool.Task(Sum, 10);
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -489,14 +561,14 @@ describe('ActsAbilityTest', function () { ...@@ -489,14 +561,14 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass032', 0, async function (done) { it('TaskPoolTestClass033', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var task = new taskpool.Task(Sum, 10, 20, 30); let task = new taskpool.Task(Sum, 10, 20, 30);
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(task).then((ret) => { taskpool.execute(task).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -508,23 +580,23 @@ describe('ActsAbilityTest', function () { ...@@ -508,23 +580,23 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass033', 0, async function (done) { it('TaskPoolTestClass034', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1; let result1;
var result2; let result2;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
var task1 = new taskpool.Task(Sum, 10, 20); let task1 = new taskpool.Task(Sum, 10, 20);
taskpool.execute(task1).then((ret1) => { taskpool.execute(task1).then((ret1) => {
result1 = ret1; result1 = ret1;
isTerminate1 = true; isTerminate1 = true;
}) })
var task2 = new taskpool.Task(Sum, 30, 40); let task2 = new taskpool.Task(Sum, 30, 40);
taskpool.execute(task2).then((ret2) => { taskpool.execute(task2).then((ret2) => {
result2 = ret2; result2 = ret2;
isTerminate2 = true; isTerminate2 = true;
...@@ -537,22 +609,22 @@ describe('ActsAbilityTest', function () { ...@@ -537,22 +609,22 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass034', 0, async function (done) { it('TaskPoolTestClass035', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1; let result1;
var result2; let result2;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
var task1 = new taskpool.Task(Sum, 10, 20) let task1 = new taskpool.Task(Sum, 10, 20)
taskpool.execute(task1).then((ret1) => { taskpool.execute(task1).then((ret1) => {
result1 = ret1; result1 = ret1;
isTerminate1 = true; isTerminate1 = true;
}) })
var task2 = new taskpool.Task(Sum, 10, 20) let task2 = new taskpool.Task(Sum, 10, 20)
taskpool.execute(task2).then((ret2) => { taskpool.execute(task2).then((ret2) => {
result2 = ret2; result2 = ret2;
isTerminate2 = true; isTerminate2 = true;
...@@ -565,17 +637,17 @@ describe('ActsAbilityTest', function () { ...@@ -565,17 +637,17 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass035', 0, async function (done) { it('TaskPoolTestClass036', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1; let result1;
var result2; let result2;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
var task = new taskpool.Task(Sum, 10, 20) let task = new taskpool.Task(Sum, 10, 20)
taskpool.execute(task).then((ret1) => { taskpool.execute(task).then((ret1) => {
result1 = ret1; result1 = ret1;
isTerminate1 = true; isTerminate1 = true;
...@@ -592,7 +664,7 @@ describe('ActsAbilityTest', function () { ...@@ -592,7 +664,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass036', 0, async function (done) { it('TaskPoolTestClass037', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
...@@ -602,31 +674,31 @@ describe('ActsAbilityTest', function () { ...@@ -602,31 +674,31 @@ describe('ActsAbilityTest', function () {
return value1 * value2; return value1 * value2;
} }
var result1; let result1;
var result2; let result2;
var result3; let result3;
var result4; let result4;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
var isTerminate3 = false; let isTerminate3 = false;
var isTerminate4 = false; let isTerminate4 = false;
var task1 = new taskpool.Task(Sum, 10, 20) let task1 = new taskpool.Task(Sum, 10, 20)
taskpool.execute(task1).then((ret1) => { taskpool.execute(task1).then((ret1) => {
result1 = ret1; result1 = ret1;
isTerminate1 = true; isTerminate1 = true;
}) })
var task2 = new taskpool.Task(Multi, 10, 20) let task2 = new taskpool.Task(Multi, 10, 20)
taskpool.execute(task2).then((ret2) => { taskpool.execute(task2).then((ret2) => {
result2 = ret2; result2 = ret2;
isTerminate2 = true; isTerminate2 = true;
}) })
var task3 = new taskpool.Task(Sum, 10, 30) let task3 = new taskpool.Task(Sum, 10, 30)
taskpool.execute(task3).then((ret3) => { taskpool.execute(task3).then((ret3) => {
result3 = ret3; result3 = ret3;
isTerminate3 = true; isTerminate3 = true;
}) })
var task4 = new taskpool.Task(Multi, 20, 20) let task4 = new taskpool.Task(Multi, 20, 20)
taskpool.execute(task4).then((ret4) => { taskpool.execute(task4).then((ret4) => {
result4 = ret4; result4 = ret4;
isTerminate4 = true; isTerminate4 = true;
...@@ -642,13 +714,13 @@ describe('ActsAbilityTest', function () { ...@@ -642,13 +714,13 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass037', 0, async function (done) { it('TaskPoolTestClass038', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, 10, 20).then((ret) => { taskpool.execute(Sum, 10, 20).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -660,7 +732,7 @@ describe('ActsAbilityTest', function () { ...@@ -660,7 +732,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass038', 0, async function (done) { it('TaskPoolTestClass039', 0, async function (done) {
function Add(value1, value2) { function Add(value1, value2) {
"use concurrent" "use concurrent"
if (value1 & value2) if (value1 & value2)
...@@ -668,8 +740,8 @@ describe('ActsAbilityTest', function () { ...@@ -668,8 +740,8 @@ describe('ActsAbilityTest', function () {
else else
return false; return false;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Add, true, false).then((ret) => { taskpool.execute(Add, true, false).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -681,13 +753,13 @@ describe('ActsAbilityTest', function () { ...@@ -681,13 +753,13 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass039', 0, async function (done) { it('TaskPoolTestClass040', 0, async function (done) {
function StrCat(value1, value2) { function StrCat(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(StrCat, "abc", "def").then((ret) => { taskpool.execute(StrCat, "abc", "def").then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -699,7 +771,7 @@ describe('ActsAbilityTest', function () { ...@@ -699,7 +771,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass040', 0, async function (done) { it('TaskPoolTestClass041', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
function StrCat(value1, value2) { function StrCat(value1, value2) {
...@@ -707,8 +779,8 @@ describe('ActsAbilityTest', function () { ...@@ -707,8 +779,8 @@ describe('ActsAbilityTest', function () {
} }
return value1+StrCat(value2,"hello"); return value1+StrCat(value2,"hello");
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, "abc", "def").then((ret) => { taskpool.execute(Sum, "abc", "def").then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -720,7 +792,7 @@ describe('ActsAbilityTest', function () { ...@@ -720,7 +792,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass041', 0, async function (done) { it('TaskPoolTestClass042', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = []; let value = [];
...@@ -728,8 +800,8 @@ describe('ActsAbilityTest', function () { ...@@ -728,8 +800,8 @@ describe('ActsAbilityTest', function () {
value[1] = arg1[1] + arg2[1]; value[1] = arg1[1] + arg2[1];
return value; return value;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, [1,2], [3,4]).then((ret) => { taskpool.execute(Sum, [1,2], [3,4]).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -742,7 +814,7 @@ describe('ActsAbilityTest', function () { ...@@ -742,7 +814,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass042', 0, async function (done) { it('TaskPoolTestClass043', 0, async function (done) {
function Sum(arg1, arg2) { function Sum(arg1, arg2) {
"use concurrent" "use concurrent"
let value = arg1; let value = arg1;
...@@ -750,8 +822,8 @@ describe('ActsAbilityTest', function () { ...@@ -750,8 +822,8 @@ describe('ActsAbilityTest', function () {
value.b = arg1.b + arg2.b; value.b = arg1.b + arg2.b;
return value; return value;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4}).then((ret) => { taskpool.execute(Sum, {"a": 1, "b" : 2}, {"a": 3, "b" : 4}).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -763,13 +835,13 @@ describe('ActsAbilityTest', function () { ...@@ -763,13 +835,13 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass043', 0, async function (done) { it('TaskPoolTestClass044', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, 10).then((ret) => { taskpool.execute(Sum, 10).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -781,13 +853,13 @@ describe('ActsAbilityTest', function () { ...@@ -781,13 +853,13 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass044', 0, async function (done) { it('TaskPoolTestClass045', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result; let result;
var isTerminate = false; let isTerminate = false;
taskpool.execute(Sum, 10, 20, 30).then((ret) => { taskpool.execute(Sum, 10, 20, 30).then((ret) => {
result = ret; result = ret;
isTerminate = true; isTerminate = true;
...@@ -799,15 +871,15 @@ describe('ActsAbilityTest', function () { ...@@ -799,15 +871,15 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass045', 0, async function (done) { it('TaskPoolTestClass046', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1; let result1;
var result2; let result2;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
taskpool.execute(Sum, 10, 20).then((ret1) => { taskpool.execute(Sum, 10, 20).then((ret1) => {
result1 = ret1; result1 = ret1;
...@@ -825,15 +897,15 @@ describe('ActsAbilityTest', function () { ...@@ -825,15 +897,15 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass046', 0, async function (done) { it('TaskPoolTestClass047', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
var result1; let result1;
var result2; let result2;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
taskpool.execute(Sum, 10, 20).then((ret1) => { taskpool.execute(Sum, 10, 20).then((ret1) => {
result1 = ret1; result1 = ret1;
...@@ -851,7 +923,7 @@ describe('ActsAbilityTest', function () { ...@@ -851,7 +923,7 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass047', 0, async function (done) { it('TaskPoolTestClass048', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
...@@ -861,14 +933,14 @@ describe('ActsAbilityTest', function () { ...@@ -861,14 +933,14 @@ describe('ActsAbilityTest', function () {
return value1 * value2; return value1 * value2;
} }
var result1; let result1;
var result2; let result2;
var result3; let result3;
var result4; let result4;
var isTerminate1 = false; let isTerminate1 = false;
var isTerminate2 = false; let isTerminate2 = false;
var isTerminate3 = false; let isTerminate3 = false;
var isTerminate4 = false; let isTerminate4 = false;
taskpool.execute(Sum, 10, 20).then((ret1) => { taskpool.execute(Sum, 10, 20).then((ret1) => {
result1 = ret1; result1 = ret1;
...@@ -896,13 +968,13 @@ describe('ActsAbilityTest', function () { ...@@ -896,13 +968,13 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass048', 0, async function (done) { it('TaskPoolTestClass049', 0, async function (done) {
function Sum(value1, value2) { function Sum(value1, value2) {
"use concurrent" "use concurrent"
return value1 + value2; return value1 + value2;
} }
try { try {
var result = await taskpool.execute(Sum); let result = await taskpool.execute(Sum);
} catch(e) { } catch(e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: first param must be object when argc is one"); expect(e.toString()).assertEqual("BusinessError: taskpool:: first param must be object when argc is one");
} }
...@@ -910,14 +982,14 @@ describe('ActsAbilityTest', function () { ...@@ -910,14 +982,14 @@ describe('ActsAbilityTest', function () {
}) })
/** /**
* @tc.number : TaskPoolTestClass061 * @tc.number : TaskPoolTestClass049
* @tc.name : Async Function about priority task * @tc.name : Async Function about priority task
* @tc.desc : Execute priority tasks * @tc.desc : Execute priority tasks
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass061', 0, async function (done) { it('TaskPoolTestClass050', 0, async function (done) {
function testTime() { function testTime() {
"use concurrent"; "use concurrent";
return Date.now(); return Date.now();
...@@ -963,7 +1035,15 @@ describe('ActsAbilityTest', function () { ...@@ -963,7 +1035,15 @@ describe('ActsAbilityTest', function () {
done(); done();
}) })
it('TaskPoolTestClass062', 0, async function (done) { /**
* @tc.number : TaskPoolTestClass051
* @tc.name : Async function execute task
* @tc.desc : Execute async function
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass051', 0, async function (done) {
async function func(value1, value2) { async function func(value1, value2) {
"use concurrent" "use concurrent"
let result = await new Promise((resolve, reject) => { let result = await new Promise((resolve, reject) => {
...@@ -972,12 +1052,20 @@ describe('ActsAbilityTest', function () { ...@@ -972,12 +1052,20 @@ describe('ActsAbilityTest', function () {
}) })
return result; return result;
} }
var result = await taskpool.execute(func, 10, 20); let result = await taskpool.execute(func, 10, 20);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
it('TaskPoolTestClass063', 0, async function (done) { /**
* @tc.number : TaskPoolTestClass052
* @tc.name : Async function execute task
* @tc.desc : Execute async function task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass052', 0, async function (done) {
async function func(value1, value2) { async function func(value1, value2) {
"use concurrent" "use concurrent"
let result = await new Promise((resolve, reject) => { let result = await new Promise((resolve, reject) => {
...@@ -986,318 +1074,181 @@ describe('ActsAbilityTest', function () { ...@@ -986,318 +1074,181 @@ describe('ActsAbilityTest', function () {
}) })
return result; return result;
} }
var task = new taskpool.Task(func, 10, 20); let task = new taskpool.Task(func, 10, 20);
var result = await taskpool.execute(task); let result = await taskpool.execute(task);
expect(result).assertEqual(30); expect(result).assertEqual(30);
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass049 * @tc.number : TaskPoolTestClass053
* @tc.name : Async Function Cancel task * @tc.name : Async function execute taskGroup
* @tc.desc : Cancel tasks that have not been executed * @tc.desc : Execute async function
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass049', 0, async function (done) { it('TaskPoolTestClass053', 0, async function (done) {
function addition(arg) { function printArgs(args) {
"use concurrent" "use concurrent"
return arg + 1; return args;
}
function additionDelay(arg) {
"use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 200) {
continue;
}
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(additionDelay, 200);
var task4 = new taskpool.Task(additionDelay, 200);
var task5 = new taskpool.Task(additionDelay, 200);
var task6 = new taskpool.Task(additionDelay, 200);
var task7 = new taskpool.Task(additionDelay, 200);
var task8 = new taskpool.Task(additionDelay, 200);
var task9 = new taskpool.Task(additionDelay, 200);
var task10 = new taskpool.Task(additionDelay, 200);
var task11 = new taskpool.Task(addition, 300);
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 result7 = taskpool.execute(task7);
var result8 = taskpool.execute(task8);
var result9 = taskpool.execute(task9);
var result10 = taskpool.execute(task10);
var result11 = taskpool.execute(task11);
var start = new Date().getTime();
while (new Date().getTime() - start < 20) {
continue;
}
taskpool.cancel(task11);
} }
catch (e) {
expect(e.toString()).assertEqual("");
}
done();
})
/** let taskGroup = new taskpool.TaskGroup();
* @tc.number : TaskPoolTestClass050 taskGroup.addTask(printArgs, 10);
* @tc.name : Sync Function Cancel task taskGroup.addTask(printArgs, 20);
* @tc.desc : Cancel tasks that have not been executed taskGroup.addTask(printArgs, 30);
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass050', 0, function (done) {
function addition(arg) {
"use concurrent"
return arg + 1;
}
function additionDelay(arg) {
"use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 200) {
continue;
}
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(additionDelay, 200);
var task4 = new taskpool.Task(additionDelay, 200);
var task5 = new taskpool.Task(additionDelay, 200);
var task6 = new taskpool.Task(additionDelay, 200);
var task7 = new taskpool.Task(additionDelay, 200);
var task8 = new taskpool.Task(additionDelay, 200);
var task9 = new taskpool.Task(additionDelay, 200);
var task10 = new taskpool.Task(additionDelay, 200);
var task11 = new taskpool.Task(addition, 300);
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 result7 = taskpool.execute(task7);
var result8 = taskpool.execute(task8);
var result9 = taskpool.execute(task9);
var result10 = taskpool.execute(task10);
var result11 = taskpool.execute(task11);
var start = new Date().getTime();
while (new Date().getTime() - start < 20) {
continue;
}
taskpool.cancel(task11); taskpool.execute(taskGroup).then((res) => {
} expect(res[0]).assertEqual(10);
catch (e) { expect(res[1]).assertEqual(20);
expect(e.toString()).assertEqual(""); expect(res[2]).assertEqual(30);
} });
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass051 * @tc.number : TaskPoolTestClass054
* @tc.name : Async Function Cancel task * @tc.name : Async function execute taskGroup
* @tc.desc : Cancel the task in progress * @tc.desc : Execute async function
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass051', 0, async function (done) { it('TaskPoolTestClass054', 0, async function (done) {
function addition(arg) { function printArgs(args) {
"use concurrent"
return arg + 1;
}
function additionDelay(arg) {
"use concurrent" "use concurrent"
var start = new Date().getTime(); return args;
while (new Date().getTime() - start < 3000) {
continue;
}
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 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;
}
taskpool.cancel(task1); let taskGroup = new taskpool.TaskGroup();
} let task1 = new taskpool.Task(printArgs, 100);
catch (e) { let task2 = new taskpool.Task(printArgs, 200);
expect(e.toString()).assertEqual( let task3 = new taskpool.Task(printArgs, 300);
"BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task"); taskGroup.addTask(task1);
} taskGroup.addTask(task2);
taskGroup.addTask(task3);
taskpool.execute(taskGroup).then((res) => {
expect(res[0]).assertEqual(10);
expect(res[1]).assertEqual(20);
expect(res[2]).assertEqual(30);
});
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass052 * @tc.number : TaskPoolTestClass055
* @tc.name : Sync Function Cancel task * @tc.name : SetTransferList for task
* @tc.desc : Cancel the task in progress * @tc.desc : Set transfer list for the task
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass052', 0, function (done) { it('TaskPoolTestClass055', 0, async function (done) {
function addition(arg) { let buffer = new ArrayBuffer(8);
"use concurrent" let view = new Uint8Array(buffer);
return arg + 1; let buffer1 = new ArrayBuffer(16);
} let view1 = new Uint8Array(buffer1);
function additionDelay(arg) {
"use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
}
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 result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime(); function testTransfer(arg1, arg2) {
while (new Date().getTime() - start < 1000) { "use concurrent"
continue; return arg1.byteLength + arg2.byteLength;
}
taskpool.cancel(task1);
}
catch (e) {
expect(e.toString()).assertEqual(
"BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task");
} }
let task = new taskpool.Task(testTransfer, view, view1);
task.setTransferList([view.buffer, view1.buffer]);
taskpool.execute(task).then((res)=>{
expect(res).assertEqual(24);
});
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass053 * @tc.number : TaskPoolTestClass056
* @tc.name : Async Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Cancel the executed task * @tc.desc : Cancel tasks that have not been executed
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass053', 0, async function (done) { it('TaskPoolTestClass056', 0, async function (done) {
function addition(arg) { function inspectStatus(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg;
} }
try {
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 start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task1); let task = new taskpool.Task(inspectStatus, 100);
} taskpool.execute(task);
catch (e) { taskpool.cancel(task);
expect(e.toString()).assertEqual( expect(taskpool.Task.isCanceled() == false);
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass054 * @tc.number : TaskPoolTestClass057
* @tc.name : Sync Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Cancel the executed task * @tc.desc : Cancel the task in progress
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass054', 0, function (done) { it('TaskPoolTestClass057', 0, async function (done) {
function addition(arg) { function inspectStatus(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg;
} }
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 start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task3); try {
} let task1 = new taskpool.Task(inspectStatus, 100);
catch (e) { let task2 = new taskpool.Task(inspectStatus, 200);
let task3 = new taskpool.Task(inspectStatus, 300);
let task4 = new taskpool.Task(inspectStatus, 400);
let task5 = new taskpool.Task(inspectStatus, 500);
let task6 = new taskpool.Task(inspectStatus, 600);
let res1 = taskpool.execute(task1);
let res2 = taskpool.execute(task2);
let res3 = taskpool.execute(task3);
let res4 = taskpool.execute(task4);
let res5 = taskpool.execute(task5);
let res6 = taskpool.execute(task6);
taskpool.execute(task1);
taskpool.cancel(task1);
} catch(e) {
expect(e.toString()).assertEqual( expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
} }
expect(taskpool.Task.isCanceled() == false);
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass055 * @tc.number : TaskPoolTestClass058
* @tc.name : Async Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Cancel nonexistent task * @tc.desc : Cancel the executed task
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass055', 0, async function (done) { it('TaskPoolTestClass058', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); let task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); let task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); let task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); let result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); let result2 = taskpool.execute(task2);
let result3 = taskpool.execute(task3);
taskpool.cancel(task3); let start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task1);
} }
catch (e) { catch (e) {
expect(e.toString()).assertEqual( expect(e.toString()).assertEqual(
...@@ -1307,25 +1258,25 @@ describe('ActsAbilityTest', function () { ...@@ -1307,25 +1258,25 @@ describe('ActsAbilityTest', function () {
}) })
/** /**
* @tc.number : TaskPoolTestClass056 * @tc.number : TaskPoolTestClass059
* @tc.name : Sync Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Cancel nonexistent task * @tc.desc : Cancel nonexistent task
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass056', 0, function (done) { it('TaskPoolTestClass059', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); let task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); let task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); let task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); let result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); let result2 = taskpool.execute(task2);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
...@@ -1337,36 +1288,36 @@ describe('ActsAbilityTest', function () { ...@@ -1337,36 +1288,36 @@ describe('ActsAbilityTest', function () {
}) })
/** /**
* @tc.number : TaskPoolTestClass057 * @tc.number : TaskPoolTestClass060
* @tc.name : Async Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Canceling unexecuted tasks multiple times * @tc.desc : Canceling unexecuted tasks multiple times
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass057', 0, async function (done) { it('TaskPoolTestClass060', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg + 1;
} }
function additionDelay(arg) { function additionDelay(arg) {
"use concurrent" "use concurrent"
var start = new Date().getTime(); let start = new Date().getTime();
while (new Date().getTime() - start < 3000) { while (new Date().getTime() - start < 3000) {
continue; continue;
} }
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); let task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); let task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); let task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); let result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); let result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); let result3 = taskpool.execute(task3);
var start = new Date().getTime(); let start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
...@@ -1382,42 +1333,43 @@ describe('ActsAbilityTest', function () { ...@@ -1382,42 +1333,43 @@ describe('ActsAbilityTest', function () {
}) })
/** /**
* @tc.number : TaskPoolTestClass058 * @tc.number : TaskPoolTestClass061
* @tc.name : Sync Function Cancel task * @tc.name : Async Function Cancel task
* @tc.desc : Canceling unexecuted tasks multiple times * @tc.desc : Cancel all tasks in sequence
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass058', 0, function (done) { it('TaskPoolTestClass061', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
return arg + 1; return arg + 1;
} }
function additionDelay(arg) {
"use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
}
return arg + 1;
}
try { try {
var task1 = new taskpool.Task(additionDelay, 100); let task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(additionDelay, 200); let task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); let task3 = new taskpool.Task(addition, 300);
let task4 = new taskpool.Task(addition, 400);
var result1 = taskpool.execute(task1); let task5 = new taskpool.Task(addition, 500);
var result2 = taskpool.execute(task2); let task6 = new taskpool.Task(addition, 600);
var result3 = taskpool.execute(task3);
let result1 = taskpool.execute(task1);
var start = new Date().getTime(); let result2 = taskpool.execute(task2);
while (new Date().getTime() - start < 1000) { let result3 = taskpool.execute(task3);
let result4 = taskpool.execute(task4);
let result5 = taskpool.execute(task5);
let result6 = taskpool.execute(task6);
let start = new Date().getTime();
while (new Date().getTime() - start < 100) {
continue; continue;
} }
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3); taskpool.cancel(task3);
taskpool.cancel(task3); taskpool.cancel(task2);
} }
catch (e) { catch (e) {
expect(e.toString()).assertEqual( expect(e.toString()).assertEqual(
...@@ -1427,168 +1379,145 @@ describe('ActsAbilityTest', function () { ...@@ -1427,168 +1379,145 @@ describe('ActsAbilityTest', function () {
}) })
/** /**
* @tc.number : TaskPoolTestClass059 * @tc.number : TaskPoolTestClass062
* @tc.name : Async Function Cancel task * @tc.name : Async Function Cancel taskGroup
* @tc.desc : Cancel all tasks in sequence * @tc.desc : Cancel the taskGroup in progress
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass059', 0, async function (done) { it('TaskPoolTestClass062', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
return arg + 1; let start = new Date().getTime();
} while (new Date().getTime() - start < 2000) {
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 start = new Date().getTime();
while (new Date().getTime() - start < 100) {
continue; continue;
} }
return arg + 1;
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
}
catch (e) {
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
} }
let i = 10;
let taskGroup1 = new taskpool.TaskGroup();
taskGroup1.addTask(addition, 10);
taskGroup1.addTask(addition, 20);
taskGroup1.addTask(addition, 30);
let taskGroup2 = new taskpool.TaskGroup();
let task1 = new taskpool.Task(addition, 100);
let task2 = new taskpool.Task(addition, 200);
let task3 = new taskpool.Task(addition, 300);
taskGroup2.addTask(task1);
taskGroup2.addTask(task2);
taskGroup2.addTask(task3);
taskpool.execute(taskGroup1).then(() => {
++i;
});
taskpool.execute(taskGroup2);
taskpool.cancel(taskGroup1);
expect(i).assertEqual(10)
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass060 * @tc.number : TaskPoolTestClass063
* @tc.name : Sync Function Cancel task * @tc.name : Async Function Cancel taskGroup
* @tc.desc : Cancel all tasks in sequence * @tc.desc : Cancel the taskGroup that have not been executed
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass060', 0, function (done) { it('TaskPoolTestClass063', 0, async function (done) {
function addition(arg) { function addition(arg) {
"use concurrent" "use concurrent"
let start = new Date().getTime();
while (new Date().getTime() - start < 2000) {
continue;
}
return arg + 1; return arg + 1;
} }
let i = 10;
let taskGroup1 = new taskpool.TaskGroup();
taskGroup1.addTask(addition, 10);
taskGroup1.addTask(addition, 20);
taskGroup1.addTask(addition, 30);
let taskGroup2 = new taskpool.TaskGroup();
let task1 = new taskpool.Task(addition, 100);
let task2 = new taskpool.Task(addition, 200);
let task3 = new taskpool.Task(addition, 300);
taskGroup2.addTask(task1);
taskGroup2.addTask(task2);
taskGroup2.addTask(task3);
taskpool.execute(taskGroup1);
taskpool.execute(taskGroup2).then(() => {
++i;
});
taskpool.cancel(taskGroup2);
expect(i).assertEqual(10)
done();
})
/**
* @tc.number : TaskPoolTestClass064
* @tc.name : Async Function Cancel taskGroup
* @tc.desc : Cancel the non-existent taskGroup
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass064', 0, async function (done) {
try { try {
var task1 = new taskpool.Task(addition, 100); let taskGroup = new taskpool.TaskGroup();
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(taskGroup);
taskpool.cancel(task5); } catch (e) {
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
}
catch (e) {
expect(e.toString()).assertEqual( expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); "BusinessError: The task group does not exist when it is canceled, taskpool:: can not find the taskGroup");
} }
done(); done();
}) })
/** /**
* @tc.number : TaskPoolTestClass061 * @tc.number : TaskPoolTestClass065
* @tc.name : Sync Function Cancel task * @tc.name : Async Function Cancel taskGroup
* @tc.desc : Test Simultaneous use taskpool and worker * @tc.desc : Cancel the executed taskGroup
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass061', 0, async function (done) { it('TaskPoolTestClass065', 0, async function (done) {
function testTaskPool() { function printArgs(args) {
function addition(arg) { "use concurrent"
"use concurrent" return args;
return arg + 1; }
}
function additionDelay(arg) {
"use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
}
return arg + 1;
}
try { let taskGroup1 = new taskpool.TaskGroup();
var task1 = new taskpool.Task(additionDelay, 100); taskGroup1.addTask(printArgs, 10);
var task2 = new taskpool.Task(additionDelay, 200); taskGroup1.addTask(printArgs, 20);
var task3 = new taskpool.Task(addition, 300); taskGroup1.addTask(printArgs, 30);
taskpool.execute(task1) let taskGroup2 = new taskpool.TaskGroup();
taskpool.execute(task2) let task1 = new taskpool.Task(printArgs, 100);
taskpool.execute(task3) let task2 = new taskpool.Task(printArgs, 200);
let task3 = new taskpool.Task(printArgs, 300);
var start = new Date().getTime(); taskGroup2.addTask(task1);
while (new Date().getTime() - start < 1000) { taskGroup2.addTask(task2);
continue; taskGroup2.addTask(task3);
}
for (let i = 1; i <= 10; i++) {
taskpool.cancel(task1);
}
}
catch (e) {
console.info("taskpoolXTS061 catch error: " + e);
}
}
function promiseCase() {
let p = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(0)
}, 100)
}).then(undefined, (error) => {
})
return p
}
let ss = new worker.ThreadWorker("entry/ets/workers/worker.js") taskpool.execute(taskGroup1);
let res = 0 taskpool.execute(taskGroup2);
let flag = false
ss.onexit = function () { setTimeout(()=>{
flag = true try {
res++ taskpool.cancel(taskGroup1);
} } catch (e) {
testTaskPool(); expect(e.toString()).assertEqual(
for (let i = 0; i < 10; i++) { "BusinessError: The task group does not exist when it is canceled, taskpool:: can not find the taskGroup");
ss.terminate(); }
} }, 3000);
while (!flag) {
await promiseCase()
}
expect(res).assertEqual(1)
done(); done();
}) })
}) })
} }
\ No newline at end of file
...@@ -2146,7 +2146,7 @@ describe('threadWorkerTest', function () { ...@@ -2146,7 +2146,7 @@ describe('threadWorkerTest', function () {
let ss = new worker.ThreadWorker("entry/ets/workers/newworker_016.js"); let ss = new worker.ThreadWorker("entry/ets/workers/newworker_016.js");
let array = [] let array = []
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
array[i] = CreateArray(i, 62); array[i] = CreateArray(i, 65);
} }
let res = 0; let res = 0;
...@@ -2172,7 +2172,7 @@ describe('threadWorkerTest', function () { ...@@ -2172,7 +2172,7 @@ describe('threadWorkerTest', function () {
while (!isTerminate) { while (!isTerminate) {
await promiseCase(); await promiseCase();
} }
expect(res).assertEqual(620) expect(res).assertEqual(650)
done(); done();
}) })
......
...@@ -1446,7 +1446,7 @@ describe('WorkerTest', function () { ...@@ -1446,7 +1446,7 @@ describe('WorkerTest', function () {
let ss = new worker.Worker("entry/ets/workers/worker_016.js"); let ss = new worker.Worker("entry/ets/workers/worker_016.js");
let array = [] let array = []
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
array[i] = CreateArray(i, 62); array[i] = CreateArray(i, 65);
} }
let res = 0; let res = 0;
...@@ -1472,7 +1472,7 @@ describe('WorkerTest', function () { ...@@ -1472,7 +1472,7 @@ describe('WorkerTest', function () {
while (!isTerminate) { while (!isTerminate) {
await promiseCase(); await promiseCase();
} }
expect(res).assertEqual(620) expect(res).assertEqual(650)
done(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册