Comments (12)
Another test to make sure is included: https://gist.github.com/domenic/43d3228e141ea225ea6e
from native-promise-only.
This just bit me that I don't have these ES6 API surface tests, which led to a regression bug #11 in Promise.all(..)
and Promise.race(..)
. :(
from native-promise-only.
@getify have these tests been pulled out yet?
from native-promise-only.
@stefanpenner i believe @smikes is still working on that.
from native-promise-only.
Yes, these exist -- at least partial coverage -- as a separate npm module promises-es6-tests
from native-promise-only.
https://www.npmjs.org/package/promises-es6-tests
from native-promise-only.
I'm not clear on how this project native-promise-only can adhere to the structure of that test suite yet, given this assertion:
When a polyfill or other Javascript implementation of Promises is being tested, these functions should modify the passed-in globalScope object, not the global object.
That sorta violates the spirit of how polyfills work. They intentionally test the real global, by name, and aren't usually set up to accept another "global" to test against.
I suppose the best an adapter for this lib could do is the very hacky:
- Test if there is already a
global.Promise
object. If so, save a ref to it, but then delete it. - Load NPO
- Pull the NPO provided version of
global.Promise
off theglobal
so that theglobal
is clean again. - Restore the saved ref, if any, from (1) of the original
Promise
back toglobal
. - Add the NPO provided
Promise
to this fakeglobal
in the adapter.
That's a pretty awkward integration path, but I don't see any other way at the moment.
from native-promise-only.
That's exactly what the adapter does. It's kludgy but the goal was to make poly fills, shims, and native implementations testable in browser or console scopes, for example if there is already a native Promise implementation on global.Promise.
Note that the existence of global.Promise is not a problem ; it's just ignored by the test suite.
On Thu, Aug 14, 2014 at 11:57 AM, Kyle Simpson [email protected]
wrote:
I'm not clear on how this project native-promise-only can adhere to the structure of that test suite yet, given this assertion:
When a polyfill or other Javascript implementation of Promises is being tested, these functions should modify the passed-in globalScope object, not the global object.
That sorta violates the spirit of how polyfills work. They intentionally test the real global, by name, and aren't usually set up to accept another "global" to test against.
I suppose the best an adapter for this lib could do is the very hacky:
- Test if there is already a
global.Promise
object. If so, save a ref to it, but then delete it.- Load NPO
- Pull the NPO provided version of
global.Promise
off theglobal
so that theglobal
is clean again.- Restore the saved ref from (1) if any.
- Add the NPO provided
Promise
to this fakeglobal
in the adapter.That's a pretty awkward integration path, but I don't see any other way at the moment.
Reply to this email directly or view it on GitHub:
#6 (comment)
from native-promise-only.
Note that the existence of global.Promise is not a problem ; it's just ignored by the test suite.
It's not a problem for the test suite. But it's a problem for the polyfill, which ignores doing its job if the global.Promise
is there. So that's what I meant about the awkwardness of creating forced tests around something whose design goal is to be ignorable in newer environments. IOW, it's unfortunate to have to force a newer environment to pretend Promise
isn't there just so the polyfill will even load itself.
In fact, I think it actually is an interesting philosophical question... should a polyfill be tested in a newer environment that has the thing and doesn't need the polyfill? One on hand, I'd say enthusiastically YES!!!, but OTOH I'd say, reluctantly, "perhaps not?" I don't have a good conclusion yet.
from native-promise-only.
Personally I'd most prefer a poly fill that
- Tests for correct functionality and replaces global. Promise if not correct
- Always returns its own implementation, for testing and in order to try parallel implementations.
Since both node 0.11 and chrome ship the version of v8 with incorrect promises, what the polyfill does in that context is an open question.
[edited to correct email formatting, fix typo, and remove quoted text]
from native-promise-only.
Though that might not fit some people's definition of a "polyfill" vs a "shim" vs whatever. I am not really clear on the terminology there.
BTW when I said "what the polyfill does is an open question" I mean what it should do is an open question. What it actually does is well-defined. It leaves the buggy implementation of promises in place, by design.
from native-promise-only.
+1
from native-promise-only.
Related Issues (20)
- browsers support information HOT 7
- Cross-Browser Support & Tests HOT 3
- Support IE8 HOT 5
- What is correct execution sequence when attach multiple handlers to the same promise. HOT 8
- Better native support detection? HOT 3
- Create tag for v0.7.6-a HOT 1
- Android 4.0 issue HOT 17
- AMD? HOT 19
- handling uncaught exceptions HOT 5
- Promise.resolve(1) throws on Android 4.0 HOT 1
- `resolve(..)` should call a thenable's `then(..)` async, not sync. HOT 5
- Unhandled rejection detection HOT 9
- Suggestion: make Promise.prototype aliases of `then` and `catch` HOT 5
- Error when running through babel compiler HOT 5
- Module with unminified code should be exported by default
- on nodejs, exceptions are not shown. HOT 4
- Microtasks? HOT 1
- Ponyfill support? HOT 1
- Missing tag for version 0.7.8-a used by jQuery HOT 7
- Promise finally not supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from native-promise-only.