Skip to content

Commit 487da90

Browse files
committed
Also skip notOutput= tests in foreign mode
The length(output) || length(notOutput) branch makes length(output) at least 1. Later, 'y' value check is skipped if length(output) is nonzero. Instead of skipping this branch altogether in foreign mode, make sure that it's taken so that the 'y' value check is later skipped when foreign mode is on.
1 parent 5e6c540 commit 487da90

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

R/test.data.table.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,12 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
475475
writeLines(out)
476476
# nocov end
477477
}
478-
if (!fail && !length(error) && (length(output) || length(notOutput)) && !foreign) {
478+
if (!fail && !length(error) && (length(output) || length(notOutput))) {
479479
if (out[length(out)] == "NULL") out = out[-length(out)]
480480
out = paste(out, collapse="\n")
481481
output = paste(output, collapse="\n") # so that output= can be either a \n separated string, or a vector of strings.
482-
if (length(output) && !string_match(output, out)) {
482+
# it also happens to turn off the 'y' checking branch below
483+
if (length(output) && !string_match(output, out) && !foreign) {
483484
# nocov start
484485
catf("Test %s did not produce correct output:\n", numStr)
485486
catf("Expected: <<%s>>\n", encodeString(output)) # \n printed as '\\n' so the two lines of output can be compared vertically
@@ -491,7 +492,7 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
491492
fail = TRUE
492493
# nocov end
493494
}
494-
if (length(notOutput) && string_match(notOutput, out, ignore.case=TRUE)) {
495+
if (length(notOutput) && string_match(notOutput, out, ignore.case=TRUE) && !foreign) {
495496
# nocov start
496497
catf("Test %s produced output but should not have:\n", numStr)
497498
catf("Expected absent (case insensitive): <<%s>>\n", encodeString(notOutput))

0 commit comments

Comments
 (0)