Skip to content

pkg/matcher: isEmpty should fail for null or non-collections. #21562

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


As there is no isNotEmpty matcher, you are forced to use isNot(isEmpty). However, expect(null, isNot(isEmpty)) passes because isEmpty returns false for non-collections or null. So, likewise, any other non-collection object would also wrongly pass such an expect call.

My suggested solution would be for isEmpty to throw an exception for "wrong" types.

Alternatively, an isNotEmpty matcher could be added.

Thanks,
 Andreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions