promises-aplus/promises-tests — pull request #20 by nobuoka (2013-02-13 19:46:51+00:00)
Title: Test returnedPromise fulfilled/rejected with a promise

Hello.

I develop a Promises/A+ library [Ten.Promise](https://github.com/nobuoka/Ten.Promise), which aims to have interface-level compatibility with [WinJS.Promise](http://msdn.microsoft.com/en-us/library/windows/apps/br211867.aspx).

Now, my library Ten.Promise is different from WinJS.Promise in treatment of a returnedPromise fulfilled/rejected with a promise.

````JavaScript
var sentinel = {};
var sentinelPromise = Promise.wrap(sentinel);

// `p` is a fulfilled promise
var p = Promise.wrap(100);

// a pseudo promise which pass a promise to callback functions
var pseudoPromObj = {
then: function (s) {
s(sentinelPromise);
}
};

var p2 = p.then(function () {
return pseudoPromObj;
});
p2.then(function (val) {
// Here is difference:
// `val` is `sentinel` in case of using WinJS.Promise,
// while `val` is `sentinelPromise` in case of using Ten.Promise
});
````

I think Ten.Promise is compliant to the Promises/A+ specification. However, either implementation passes the current promises-tests, so I added tests about this behavior to promises-tests.

Thanks.