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 |
|
16 | Sync(function(){
|
17 | return 'some value';
|
18 | }, function(err, value){
|
19 | assert.equal(value, 'some value');
|
20 | })
|
21 |
|
22 |
|
23 | Sync(function(){
|
24 | throw 'something went wrong';
|
25 | }, function(err){
|
26 | assert.equal(err, 'something went wrong');
|
27 | })
|
28 |
|
29 |
|
30 | assert.throws(function(){
|
31 | Sync(function(){
|
32 | throw 'something went wrong';
|
33 | })
|
34 | }, 'something went wrong');
|
35 |
|
36 |
|
37 | assert.throws(function(){
|
38 | Sync(function(){
|
39 |
|
40 | }, function(){
|
41 | throw 'something went wrong';
|
42 | })
|
43 | }, 'something went wrong');
|
44 |
|
45 |
|
46 | Sync(function(fiber){
|
47 | assert.ok(fiber instanceof Fiber);
|
48 | })
|
49 |
|
50 |
|
51 | assert.doesNotThrow(function(){
|
52 | Sync(function(){
|
53 | return 'test';
|
54 | })
|
55 | })
|
56 |
|
57 |
|
58 | Sync.Fiber(function(){
|
59 | return 'some value';
|
60 | }, function(err, value){
|
61 | assert.equal(value, 'some value');
|
62 | })
|
63 | }
|
64 | catch (e) {
|
65 | console.error(e.stack);
|
66 | }
|
67 |
|
68 | if (callback) {
|
69 | callback(e);
|
70 | }
|
71 | }
|
72 |
|
73 | if (!module.parent) {
|
74 | runTest(function(){
|
75 | console.log('%s done', __filename);
|
76 | });
|
77 | }
|