Skip to content

expect_equal() failed to capture argument: tol  #17

@chuvanan

Description

@chuvanan

I got an error when trying to use expect_equal() even though the equivalent all.equal() gave correct result.

expect_equal(
    my_function(binary_actual, predicted),
    target = 0.4861996,
    tol = 10e-8
)
# FALSE

all.equal(my_function(binary_actual, predicted),
          target = 0.4861996,
          tolerance = 10e-8)
# TRUE

It seems that the argument tol is not used by expect_equal():

expect_equal <- function(current, target, tol = sqrt(.Machine$double.eps), ...){

  check <- all.equal(current, target,...)
  [truncated]
}

I think the correct way should be:

expect_equal <- function(current, target, tol = sqrt(.Machine$double.eps), ...){

  check <- all.equal(current, target, tolerance = tol, ...)
  [truncated]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions