Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kriskowal/q
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed May 16, 2012
2 parents 37cced8 + 02241ea commit c0991dc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions lib/jasmine-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jasmine.Block.prototype.execute = function (onComplete) {
}
} catch (error) {
spec.fail(error);
onComplete();
}
};

19 changes: 9 additions & 10 deletions q-spec.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html>
<html>
<head>
<title>Jasmine Spec Runner</title>

<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-promise.js"></script>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png" />
<link rel="stylesheet" href="lib/jasmine-1.2.0/jasmine.css" />
<script src="lib/jasmine-1.2.0/jasmine.js"></script>
<script src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<script src="lib/jasmine-promise.js"></script>

<!-- include source files here... -->
<script type="text/javascript" src="q.js"></script>
<script src="q.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="q-spec.js"></script>
<script src="q-spec.js"></script>

<script type="text/javascript">
<script>
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
Expand Down
24 changes: 12 additions & 12 deletions q-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe("promises for functions", function () {
return bound()
.then(function (_result) {
expect(_result).toBe(result);
})
});
});

it("returns a rejected promise from a thrown error", function () {
Expand All @@ -298,7 +298,7 @@ describe("promises for functions", function () {
expect("flying pigs").toBe("swillin' pigs");
}, function (_exception) {
expect(_exception).toBe(exception);
})
});
});

it("passes arguments through", function () {
Expand Down Expand Up @@ -436,7 +436,7 @@ describe("propagation", function () {
.then()
.then(function (ten) {
expect(ten).toBe(10);
})
});
});

it("propagate through then with modifying callback", function () {
Expand All @@ -446,19 +446,19 @@ describe("propagation", function () {
})
.then(function (twen) {
expect(twen).toBe(20);
})
});
});

it("errback recovers from exception", function () {
var error = new Error("Bah!")
var error = new Error("Bah!");
return Q.reject(error)
.then(null, function (_error) {
expect(_error).toBe(error);
return 10;
})
.then(function (value) {
expect(value).toBe(10);
})
});
});

it("rejection propagates through then with no errback", function () {
Expand Down Expand Up @@ -528,7 +528,7 @@ describe("allResolved", function () {
return Q.allResolved([1, Q.resolve(2), Q.reject(3)])
.then(null, function () {
expect("flying pigs").toBe("flightless pigs");
})
});
});

it("the state and quantity of promises to be correct", function () {
Expand All @@ -550,7 +550,7 @@ describe("allResolved", function () {

expect(promises[0].valueOf()).toEqual(1);
expect(promises[1].valueOf()).toEqual(2);
})
});
});

it("is resolved after every constituent promise is resolved", function () {
Expand All @@ -567,13 +567,13 @@ describe("allResolved", function () {
.then(function () {
toResolve.resolve();
resolved = true;
})
});

return Q.allResolved(promises)
.then(function (promises) {
expect(resolved).toBe(true);
expect(rejected).toBe(true);
})
});
});

});
Expand Down Expand Up @@ -648,7 +648,7 @@ describe("node support", function () {
return Q.napply(subject.foo, subject, [])
.then(function (result) {
expect(result).toBe(true);
})
});
});

it("rejects with callback error", function () {
Expand Down Expand Up @@ -684,7 +684,7 @@ describe("node support", function () {
return Q.ncall(subject.foo, subject)
.then(function (result) {
expect(result).toBe(true);
})
});
});

it("rejects with callback error", function () {
Expand Down
3 changes: 2 additions & 1 deletion q.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ if (typeof process !== "undefined") {
nextTick = process.nextTick;
} else if (typeof msSetImmediate === "function") {
// IE 10 only, at the moment
nextTick = msSetImmediate;
// And yes, ``bind``ing to ``window`` is necessary O_o.
nextTick = msSetImmediate.bind(window);
} else if (typeof setImmediate === "function") {
// https://github.com/NobleJS/setImmediate
nextTick = setImmediate;
Expand Down

0 comments on commit c0991dc

Please sign in to comment.