Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-4 Task. TapeGhad #72

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
53def7b
async task
IlyaMokin Apr 3, 2016
702d9b5
async task description
IlyaMokin Apr 3, 2016
c47a9b6
async task, tests fixes
IlyaMokin Apr 3, 2016
5faf64b
Merge branch 'async_task'
IlyaMokin Sep 12, 2017
6ea5858
added a comment for async task
IlyaMokin Sep 12, 2017
dbb7799
new timeSpanToString test
Sep 14, 2017
b1392c0
additional getFactorial test
IlyaMokin Sep 16, 2017
c015aae
depthTraversalTree test, timeout increase
IlyaMokin Sep 16, 2017
40d6ba4
async additional test
IlyaMokin Sep 21, 2017
df9bce0
additional test for domino task
VadimSemenuk Sep 22, 2017
b2cef11
Merge pull request #17 from VadimSemenuk/master
IlyaMokin Sep 24, 2017
9c82b05
Merge branch 'parseDataFromRfc2822' into aisedu_master
IlyaMokin Sep 24, 2017
96f0d13
additional test to retry task
VadimSemenuk Sep 26, 2017
323599e
fix
VadimSemenuk Sep 26, 2017
db62c06
fix
VadimSemenuk Sep 26, 2017
c3b9e84
Merge pull request #22 from VadimSemenuk/retryTestFix
IlyaMokin Sep 26, 2017
b574239
retry test fix
VadimSemenuk Sep 26, 2017
43cf153
fix
VadimSemenuk Sep 26, 2017
a7aa45d
Merge pull request #23 from VadimSemenuk/retryTestFix
IlyaMokin Sep 27, 2017
fdc6982
Merge remote-tracking branch 'init/master'
IlyaMokin Jun 29, 2020
827e2c9
travis
IlyaMokin Jun 29, 2020
9e6cd26
Update the links
TapeGhad Jun 30, 2020
79a2f5a
task1-4
TapeGhad Jul 3, 2020
0381434
task_1_4
TapeGhad Jul 3, 2020
ecb2d04
task_1_4
TapeGhad Jul 3, 2020
5c58e89
task_1_4
TapeGhad Jul 3, 2020
ad88a75
task_1_4
TapeGhad Jul 10, 2020
97e0327
task_1_4
TapeGhad Jul 10, 2020
9b0af16
task_1_4
TapeGhad Jul 10, 2020
8c38905
task_1_4
TapeGhad Jul 10, 2020
e46fe00
task_1_4
TapeGhad Jul 10, 2020
33553bd
task_1_4
TapeGhad Jul 11, 2020
38e8782
task_1_4
TapeGhad Jul 11, 2020
047ddc8
task_1_4
TapeGhad Jul 11, 2020
a614d6a
task_1_4
TapeGhad Jul 15, 2020
7bfdbdd
okay
TapeGhad Jul 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
async task
IlyaMokin committed Apr 3, 2016
commit 53def7ba24db6563b44d85418e98dbaec020d0f5
2 changes: 1 addition & 1 deletion extensions/it-optional.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ function testOptional(title, fn) {

it(title, function() {
try {
fn.call(this);
return fn.call(this);
} catch (err) {
if (err.message=="Not implemented") {
this.test.skip();
16 changes: 15 additions & 1 deletion task/07-yield-tasks.js
Original file line number Diff line number Diff line change
@@ -129,11 +129,25 @@ function* mergeSortedSequences(source1, source2) {
throw new Error('Not implemented');
}

/**
* Resolve Promises and take values step by step.
*
* @params {Iterable.<Promise>} generator
* @return {Promise} Promise with value returned via return
*
* @example
* async((function*() { var a = yield Promise.resolve(6); return a; }) => 6
*/
function async(generator) {
throw new Error('Not implemented');
}


module.exports = {
get99BottlesOfBeer: get99BottlesOfBeer,
getFibonacciSequence: getFibonacciSequence,
depthTraversalTree: depthTraversalTree,
breadthTraversalTree: breadthTraversalTree,
mergeSortedSequences: mergeSortedSequences
mergeSortedSequences: mergeSortedSequences,
async : async
};
39 changes: 39 additions & 0 deletions test/07-yield-tests.js
Original file line number Diff line number Diff line change
@@ -446,4 +446,43 @@ describe('07-yield-tasks', function() {
assert.equal(count, ITEMS_COUNT);

});

it.optional('async should resolve Promises and take values step by step', () => {
return new Promise((resolve, reject)=> {
tasks.async(function*() {
let a = yield new Promise((resolve)=> setTimeout(()=>resolve(5), 100)),
b = yield Promise.resolve(6);
assert.equal(a, 5, '');
assert.equal(b, 6, '');

return yield new Promise((resolve)=> resolve(a + b));
}).then(value=> {
try {
assert.equal(value, 11, '');
resolve()
} catch (err) {
reject(err);
}
}, (err)=> {
reject(err);
});
});
});

it.optional('async should handle exception during generator work', () => {
return new Promise((resolve, reject)=> {
tasks.async(function*() {
yield new Promise(()=> {throw new Error("test error");});
}).then(()=> {
reject();
}, (err)=> {
try {
assert.equal(err.message, 'test error', '');
resolve()
} catch (err) {
reject(err);
}
});
});
});
});