diff --git a/closure/goog/result/combine_test.html b/closure/goog/result/combine_test.html index 51d62757..b5ad6a72 100644 --- a/closure/goog/result/combine_test.html +++ b/closure/goog/result/combine_test.html @@ -55,6 +55,16 @@ combinedResult = successCombinedResult = null; } +function testSynchronousCombine() { + resolveAllGivenResultsToSuccess(); + + newCombinedResult = goog.result.combine(result1, result2, result3, result4); + + goog.result.wait(newCombinedResult, resultCallback); + + assertSuccessCall(newCombinedResult, resultCallback); +} + function testCombineWhenAllResultsSuccess() { goog.result.wait(combinedResult, resultCallback); diff --git a/closure/goog/result/resultutil.js b/closure/goog/result/resultutil.js index b68b6d91..10c48320 100644 --- a/closure/goog/result/resultutil.js +++ b/closure/goog/result/resultutil.js @@ -303,7 +303,8 @@ goog.result.combine = function(var_args) { }; var checkResults = function() { - if (goog.array.every(results, isResolved)) { + if (combinedResult.getState() == goog.result.Result.State.PENDING && + goog.array.every(results, isResolved)) { combinedResult.setValue(results); } };