R Under development (unstable) (2026-02-18 r89435 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## small shim to implement testthat expect_* functions > ## without the need for all the insane crud of testthat > > library(iotools) > > expect_equal <- function(expr, result) stopifnot(all.equal(expr, result)) > expect_error <- function(expr, error) stopifnot(tryCatch({ x <- expr; FALSE }, error=function(e) length(grep(error, as.character(e))) > 0L)) > expect_warning <- function(expr, warn) stopifnot(tryCatch({ x <- expr; FALSE }, warning=function(e) length(grep(warn, as.character(e))) > 0L)) > > .on.exit <- list() > > on_exit <- function(fn) .on.exit <<- c(.on.exit, list(fn)) > > for (fn in Sys.glob("tests/*.R")) { + cat("\n\n=== Testing", fn, "===\n") + source(fn, echo=TRUE) + } === Testing tests/test-dstrsplit.R === > n = 100 > test_df = data.frame(col1 = sample(state.abb, n, TRUE), + col2 = sample(1:10, n, TRUE), col3 = runif(n), col4 = complex(n, + runif(n), .... [TRUNCATED] > colClasses = sapply(test_df, class) > out = as.output(test_df) > expect_equal(class(out), "raw") > expect_equal(dstrsplit(out, col_types = colClasses), + test_df) > rownames(test_df) = basename(sapply(1:n, function(v) tempfile())) > out = as.output(test_df) > expect_equal(class(out), "raw") > dout = dstrsplit(out, col_types = colClasses, nsep = "\t") > expect_equal(dout$rowindex, rownames(test_df)) > rownames(dout) = dout$rowindex > dout = dout[, -1] > expect_equal(dout, test_df) > rownames(test_df) = NULL > out = as.output(test_df[1, ]) > expect_equal(class(out), "raw") > expect_equal(dstrsplit(out, col_types = colClasses), + test_df[1, ]) > out = as.output(test_df[, 1, drop = FALSE]) > expect_equal(class(out), "raw") > expect_equal(dstrsplit(out, col_types = colClasses[1]), + test_df[, 1, drop = FALSE]) > test_df_empty = data.frame(test_df[NULL, ]) > out = as.output(test_df_empty) > expect_equal(class(out), "raw") > expect_equal(length(out), 0) > expect_equal(dstrsplit(out, col_types = colClasses), + test_df_empty) > this_test_df = test_df > this_test_df[, ncol(this_test_df)] = paste0(this_test_df[, + ncol(this_test_df)], "\r") > out = as.output(this_test_df) > expect_equal(dstrsplit(out, col_types = colClasses), + test_df) > this_test_df = test_df > this_test_df[, 1] = paste0("'", this_test_df[, 1], + "'") > out = as.output(this_test_df) > expect_equal(dstrsplit(out, col_types = colClasses, + quote = "'\""), test_df) > this_test_df = test_df > this_test_df[, 1] = paste0("'", this_test_df[, 1]) > out = as.output(this_test_df) > expect_error(dstrsplit(out, col_types = colClasses, + quote = "'\""), "End of line within quoted string.") === Testing tests/test-mstrsplit.R === > p = 10 > n = 100 > test_matrix = matrix(sample(1:10, p * n, TRUE), ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "integer"), test_matrix) > test_matrix = matrix(runif(p * n), ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "numeric"), test_matrix) > test_matrix = matrix(sample(state.abb, p * n, TRUE), + ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "character"), test_matrix) > test_matrix = matrix(charToRaw(paste(sample(letters, + n * p, TRUE), collapse = "")), ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "raw"), test_matrix) > test_matrix = matrix(complex(n * p, runif(n * p), + runif(n * p)), ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "complex"), test_matrix) > test_matrix = matrix(runif(n * p) > 0.5, ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "logical"), test_matrix) > test_matrix = matrix(runif(p * n), ncol = p) > out = as.output(test_matrix, sep = ",") > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "numeric", sep = ","), + test_matrix) > test_matrix = matrix(runif(p * n), ncol = p) > rownames(test_matrix) = sample(letters, n, TRUE) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "numeric", nsep = "\t"), + test_matrix) > test_matrix = matrix(runif(p * 1), ncol = p) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "numeric"), test_matrix) > test_matrix = matrix(runif(1 * n), ncol = 1) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(mstrsplit(out, type = "numeric"), test_matrix) > test_matrix = matrix(0, ncol = 0, nrow = 0) > out = as.output(test_matrix) > expect_equal(class(out), "raw") > expect_equal(length(out), 0) > expect_equal(mstrsplit(out, type = "integer"), test_matrix) > test_matrix = matrix(sample(state.abb, p * n, TRUE), + ncol = p) > test_matrix2 = test_matrix > test_matrix2[, ncol(test_matrix2)] = paste0(test_matrix2[, + ncol(test_matrix2)], "\r") > out = as.output(test_matrix2) > expect_equal(mstrsplit(out, type = "character"), test_matrix) > test_matrix = matrix(sample(state.abb, p * n, TRUE), + ncol = p) > test_matrix2 = test_matrix > test_matrix2[, 1] = paste0("'", test_matrix2[, 1], + "'") > out = as.output(test_matrix2) > expect_equal(mstrsplit(out, type = "character", quote = "'\""), + test_matrix) > test_matrix = matrix(sample(state.abb, p * n, TRUE), + ncol = p) > test_matrix2 = test_matrix > test_matrix2[, 1] = paste0("'", test_matrix2[, 1]) > out = as.output(test_matrix2) > expect_error(mstrsplit(out, type = "character", quote = "'\""), + "End of line within quote string on line 1; cannot determine num columns!") > test_matrix = matrix(sample(state.abb, p * n, TRUE), + ncol = p) > test_matrix2 = test_matrix > test_matrix2[-1, 1] = paste0("'", test_matrix2[-1, + 1]) > out = as.output(test_matrix2) > expect_warning(mstrsplit(out, type = "character", + quote = "'\""), "End of line within quoted string!") > > ## Long-running tests that we don't want to run on CRAN > if (nchar(Sys.getenv("NOT_CRAN"))) for (fn in Sys.glob("non-cran/*.R")) { + cat("\n\n=== Testing", fn, "===\n") + source(fn, echo=TRUE) + } > > for (.FUN in .on.exit) .FUN() > > proc.time() user system elapsed 0.28 0.06 0.32