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

test: Assert that `has(…)` throws on `null` or `undefined` #12

Merged
merged 1 commit into from Oct 7, 2019

Conversation

@ExE-Boss
Copy link
Contributor

commented Oct 7, 2019

Currently, calling has(null, "foo") or has(undefined, "foo") throws a TypeError:

TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)

Should I change this so that calling has(…) on null and undefined return false instead?


closes #13

@ljharb

This comment has been minimized.

Copy link
Collaborator

commented Oct 7, 2019

No, it’s supposed to throw on null and undefined.

@ljharb ljharb closed this Oct 7, 2019
@ExE-Boss

This comment has been minimized.

Copy link
Contributor Author

commented Oct 7, 2019

Why have you closed this?

This just adds tests that it indeed throws on those invocations.

@ExE-Boss ExE-Boss changed the title test: `has(…)` throws on `null` or `undefined` test: Assert that `has(…)` throws on `null` or `undefined` Oct 7, 2019
@ljharb

This comment has been minimized.

Copy link
Collaborator

commented Oct 7, 2019

You’re right, i misunderstood :-)

@ljharb ljharb reopened this Oct 7, 2019
@ljharb
ljharb approved these changes Oct 7, 2019
@ljharb ljharb merged commit 8146666 into tarruda:master Oct 7, 2019
@ExE-Boss ExE-Boss deleted the EB-Forks:test/throws-on-null branch Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.