1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var Sync = require('..'),
|
7 | assert = require('assert');
|
8 |
|
9 | var runTest = module.exports = function(callback)
|
10 | {
|
11 | var e;
|
12 |
|
13 | try {
|
14 |
|
15 | Sync(function(){
|
16 | var start = new Date;
|
17 | Sync.sleep(101);
|
18 |
|
19 | assert.ok(new Date - start >= 100);
|
20 | })
|
21 |
|
22 |
|
23 | assert.throws(function(){
|
24 | Sync.sleep(1000);
|
25 | }, 'should throw exception when callend not inside of fiber')
|
26 | }
|
27 | catch (e) {
|
28 | console.error(e.stack);
|
29 | }
|
30 |
|
31 | if (callback) {
|
32 | callback(e);
|
33 | }
|
34 | }
|
35 |
|
36 | if (!module.parent) {
|
37 | runTest(function(){
|
38 | console.log('%s done', __filename);
|
39 | });
|
40 | }
|