Skip to content

Commit

Permalink
Merge pull request web-platform-tests#115 from g-ortuno/sequential-pr…
Browse files Browse the repository at this point in the history
…omise-tests

Turn promise tests into sequential promise tests.
  • Loading branch information
jgraham committed Jun 30, 2015
2 parents 10feb1a + cf0b67d commit 0790087
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Binary file modified docs/api.md
Binary file not shown.
34 changes: 21 additions & 13 deletions testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,27 @@ policies and contribution forms [3].

function promise_test(func, name, properties) {
var test = async_test(name, properties);
Promise.resolve(test.step(func, test, test))
.then(
function() {
test.done();
})
.catch(test.step_func(
function(value) {
if (value instanceof AssertionError) {
throw value;
}
assert(false, "promise_test", null,
"Unhandled rejection with value: ${value}", {value:value});
}));
// If there is no promise tests queue make one.
test.step(function() {
if (!tests.promise_tests) {
tests.promise_tests = Promise.resolve();
}
});
tests.promise_tests = tests.promise_tests.then(function() {
return Promise.resolve(test.step(func, test, test))
.then(
function() {
test.done();
})
.catch(test.step_func(
function(value) {
if (value instanceof AssertionError) {
throw value;
}
assert(false, "promise_test", null,
"Unhandled rejection with value: ${value}", {value:value});
}));
});
}

function promise_rejects(test, expected, promise) {
Expand Down

0 comments on commit 0790087

Please sign in to comment.