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

contain() is always true for empty ref with only and not once #323

Closed
samliebow opened this issue Aug 9, 2019 · 1 comment · Fixed by #324
Closed

contain() is always true for empty ref with only and not once #323

samliebow opened this issue Aug 9, 2019 · 1 comment · Fixed by #324
Assignees
Labels
bug
Milestone

Comments

@samliebow
Copy link
Contributor

@samliebow samliebow commented Aug 9, 2019

Empty refs (i.e. '', [], or {}) don't have anything in the ref to not be in the values, so misses is false, so in the following block:

 if (options.only) {
        if (misses || !options.once) {
            return !misses;
        }
    }

If only is true and once isn't, contain will always return true.

This bug was introduced in #276. That's Hoek 6.0.2, and I found it via its effects on Code (expect(ref).to.only.include(value)) after version 5.2.2.

@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Aug 12, 2019

Thanks. Nice catch.

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.