Skip to content

testing output using patterns disabled when parentheses present #3422

@jangorecki

Description

@jangorecki

At least the last test call in below example should pass. Ideally second to last also.
If possible would be great to have that for 1.12.2 as it blocks some other PR that should goes for 1.12.2.

#test = data.table:::test 
#cc(F)
dummy = function(..., use.parentheses=FALSE) {
  part_of_msg = "fun"
  if (use.parentheses) part_of_msg = paste0("(", part_of_msg, ")") 
  cat(sprintf("starting dummy %s\n", part_of_msg))
  t = system.time(Sys.sleep(0.001))[["elapsed"]]
  cat(sprintf("dummy took %.3fs\n", t))
  list(...)
}
dummy(1)
#starting dummy fun
#dummy took 0.001s
#[[1]]
#[1] 1
#
dummy(1, use.parentheses=TRUE)
#starting dummy (fun)
#dummy took 0.001s
#[[1]]
#[1] 1

isTRUE(test(1, dummy(1), output=c("starting dummy fun", "dummy took.*s")))
#[1] TRUE
test(1, dummy(1, use.parentheses=TRUE), output=c("starting dummy (fun)", "dummy took.*s"))
#Test 1 didn't produce correct output:
#Expected: <<starting dummy (fun)\ndummy took.*s>>
#Observed: <<starting dummy (fun)\ndummy took 0.001s\n[[1]]\n[1] 1\n>>
test(1, {dummy(1, use.parentheses=TRUE); NULL}, output=c("starting dummy (fun)", "dummy took.*s"))
#Test 1 didn't produce correct output:
#Expected: <<starting dummy (fun)\ndummy took.*s>>
#Observed: <<starting dummy (fun)\ndummy took 0.001s>>

overcomplicated attempt to solve that was made in https://github.com/Rdatatable/data.table/pull/3394/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions