Skip to content

Allow arbitrary comparison function in expect_prop() #51

@gorcha

Description

@gorcha

Had a thought about the expect_prop() API - it would be nice to make a slight change to make the cmp argument take an arbitrary function that takes the proportion meeting the check condition and indicates whether this proportion passes some test or not. This makes it more flexible and I think reads pretty nicely.

For e.g., with a little helper function, you can do nice things like this:

expect_prop(a1, chk_blank, is_gte(0.8))

Where is_gte() is a function generator:

is_gte <- function(prop) {
  function(x) x >= prop
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions