forked from kriskowal/q
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspread.js
37 lines (32 loc) · 926 Bytes
/
spread.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
var Q = require("../q");
exports['test spread'] = function (ASSERT, done) {
Q.resolve([1,2,3])
.spread(function (a, b, c) {
ASSERT.equal(a, 1, 'spread 1');
ASSERT.equal(b, 2, 'spread 2');
ASSERT.equal(c, 3, 'spread 3');
ASSERT.equal(arguments.length, 3, 'spread arguments length');
})
.fail(function (reason) {
ASSERT.ok(false, reason);
})
.fin(done)
};
exports['test spread all'] = function (ASSERT, done) {
Q.resolve([1,2,3].map(Q.resolve))
.all()
.spread(function (a, b, c) {
ASSERT.equal(a, 1, 'spread 1');
ASSERT.equal(b, 2, 'spread 2');
ASSERT.equal(c, 3, 'spread 3');
ASSERT.equal(arguments.length, 3, 'spread arguments length');
})
.fail(function (reason) {
ASSERT.ok(false, reason);
})
.fin(done)
};
if (module == require.main) {
require('test').run(exports);
}