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

Assert: Allow fat arrow functions in throws expected handler #1492

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

smcclure15
Copy link
Member

fixes #1389
added positive and negative unittests

@Krinkle
Copy link
Member

Krinkle commented Nov 5, 2020

It took me a while to figure out why this works. In particular, I was trying to find how absence of this condition leads to TypeError: 'prototype' property of x is not an object.

But I see now that the issue is coming from the native code behind the instanceof operator. I... wasn't expecting that!

arr = () => {};
function Foo() {}

x = new Foo();
x instanceof arr;
//> TypeError: 'prototype' property of arr is not an object

@Krinkle Krinkle self-assigned this Nov 5, 2020
Copy link
Member

@Krinkle Krinkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll get review this once more tomorrow and then land it.

Could you add an inline comment about the instanceof caveat for future eyes?

@smcclure15
Copy link
Member Author

Agreed, this also took me a bit.
Kudos to @ohze for supplying the solution in their issue.
This was indeed a "Good first issue" - glad to help!

add inline comments around instanceof behavior
@Krinkle Krinkle merged commit 10728df into qunitjs:master Nov 5, 2020
@smcclure15 smcclure15 deleted the throws-fat-arrow branch November 6, 2020 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

assert.throws fails when expected is an arrow function: 'prototype' property of expected is not an object
2 participants