Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't blow up when imitating a thing with generators on it #274

Merged
merged 4 commits into from
Jun 30, 2017

Conversation

searls
Copy link
Member

@searls searls commented Jun 30, 2017

td.js does not yet support generator functions and we don't have a concept of faking / imitating them since their stubbing needs are quite different from standard functions. However, as of the 3.2 release, anything users imitate that contain native generators will explode. This should fix that.

  • don't fake the generator with a test double to start with
  • bail out when trying to change the constructor; either in chainPrototype (very deep) or in isPrimitiveLike (preventing the recurse step).

The latter approach is cleaner and less likely to taint generators, but would prevent imitation of any user-defined properties on it. The former is more surgical in that it's possible we mess up something on the generators' prototype like next()

Fixes #273, #271

searls added 3 commits June 28, 2017 10:17
testdouble.js does not yet support faking generators, full stop. Just
return the actual function and fake any properties tacked onto them
instead.
@searls
Copy link
Member Author

searls commented Jun 30, 2017

My feeling is I should probably go with the isPrimitiveLike patch and rename it to something more intent-revealing like isUnsupportedType()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generator support
1 participant