@@ -395,6 +395,10 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
395395 catf(" Test %s did not produce correct output:\n " , numStr )
396396 catf(" Expected: <<%s>>\n " , encodeString(output )) # \n printed as '\\n' so the two lines of output can be compared vertically
397397 catf(" Observed: <<%s>>\n " , encodeString(out ))
398+ if (anyNonAscii(output ) || anyNonAscii((out ))) {
399+ catf(" Expected (raw): <<%s>>\n " , paste(charToRaw(output ), collapse = " " ))
400+ catf(" Observed (raw): <<%s>>\n " , paste(charToRaw(out ), collapse = " " ))
401+ }
398402 fail = TRUE
399403 # nocov end
400404 }
@@ -403,6 +407,10 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
403407 catf(" Test %s produced output but should not have:\n " , numStr )
404408 catf(" Expected absent (case insensitive): <<%s>>\n " , encodeString(notOutput ))
405409 catf(" Observed: <<%s>>\n " , encodeString(out ))
410+ if (anyNonAscii(notOutput ) || anyNonAscii((out ))) {
411+ catf(" Expected absent (raw): <<%s>>\n " , paste(charToRaw(notOutput ), collapse = " " ))
412+ catf(" Observed (raw): <<%s>>\n " , paste(charToRaw(out ), collapse = " " ))
413+ }
406414 fail = TRUE
407415 # nocov end
408416 }
@@ -448,6 +456,10 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
448456 # head.matrix doesn't restrict columns
449457 if (length(d <- dim(x ))) do.call(`[` , c(list (x , drop = FALSE ), lapply(pmin(d , 6L ), seq_len )))
450458 else print(head(x ))
459+ if (typeof(x ) == ' character' && anyNonAscii(x )) {
460+ cat(" Non-ASCII string detected, raw representation:\n " )
461+ print(lapply(head(x ), charToRaw ))
462+ }
451463 }
452464 }
453465 failPrint(x , deparse(xsub ))
@@ -466,3 +478,4 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
466478 invisible (! fail )
467479}
468480
481+ anyNonAscii = function (x ) anyNA(iconv(x , to = " ASCII" )) # nocov
0 commit comments