Skip to content

Commit 1536571

Browse files
other.Rraw
1 parent 3060a5d commit 1536571

File tree

1 file changed

+107
-102
lines changed

1 file changed

+107
-102
lines changed

inst/tests/other.Rraw

Lines changed: 107 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,12 @@ if (loaded[["xts"]]) { # was 1465 in tests.Rraw, #5516
507507

508508
# 890 -- key argument for as.data.table.xts
509509
x = xts(1:10, as.Date(1:10, origin = "1970-01-01"))
510-
old = options(datatable.verbose=FALSE)
511-
test(18.18, capture.output(as.data.table(x, key="index")),
510+
test(18.18, options=c(datatable.verbose=FALSE),
511+
capture.output(as.data.table(x, key="index")),
512512
c(" index V1", " 1: 1970-01-02 1", " 2: 1970-01-03 2",
513513
" 3: 1970-01-04 3", " 4: 1970-01-05 4", " 5: 1970-01-06 5",
514514
" 6: 1970-01-07 6", " 7: 1970-01-08 7", " 8: 1970-01-09 8",
515515
" 9: 1970-01-10 9", "10: 1970-01-11 10"))
516-
options(old)
517516

518517
# as.data.table.xts(foo) had incorrect integer index with a column name called 'x', #4897
519518
M = xts::as.xts(matrix(1, dimnames=list("2021-05-23", "x"))) # xts:: just to be extra robust; shouldn't be needed with rm(as.xts) above
@@ -528,23 +527,24 @@ if (loaded[["xts"]]) { # was 1465 in tests.Rraw, #5516
528527
# was 2108 in tests.Rraw, #5516
529528
# first and last should no longer load xts namespace, #3857, below commented test for interactive validation when xts present but not loaded or attached
530529
# stopifnot("xts"%in%installed.packages(), !isNamespaceLoaded("xts")); library(data.table); x=as.POSIXct("2019-01-01"); last(x); stopifnot(!isNamespaceLoaded("xts"))
531-
x = as.POSIXct("2019-09-09")+0:1
532-
old = options(datatable.verbose=TRUE)
533-
test(19.01, last(x), x[length(x)], output="!is.xts(x)")
534-
test(19.02, first(x), x[1L], output="!is.xts(x)")
535-
if (loaded[["xts"]]) {
536-
xt = xts(1:2, x)
537-
test(19.03, last(xt, 2L), xt, output="using xts::last: is.xts(x)")
538-
test(19.04, first(xt, 2L), xt, output="using xts::first: is.xts(x)")
539-
xt = xts(matrix(1:4, 2L, 2L), x)
540-
test(19.05, last(xt, 2L), xt, output="using xts::last: is.xts(x)")
541-
test(19.06, first(xt, 2L), xt, output="using xts::first: is.xts(x)")
542-
}
543-
# first on empty df now match head(df, n=1L), #3858
544-
df = data.frame(a=integer(), b=integer())
545-
test(19.11, first(df), df, output="!is.xts(x)")
546-
test(19.12, last(df), df, output="!is.xts(x)")
547-
options(datatable.verbose=FALSE) # so the as.data.table() doesn't pollute output
530+
local({
531+
x = as.POSIXct("2019-09-09")+0:1
532+
old = options(datatable.verbose=TRUE); on.exit(options(old))
533+
test(19.01, last(x), x[length(x)], output="!is.xts(x)")
534+
test(19.02, first(x), x[1L], output="!is.xts(x)")
535+
if (loaded[["xts"]]) {
536+
xt = xts(1:2, x)
537+
test(19.03, last(xt, 2L), xt, output="using xts::last: is.xts(x)")
538+
test(19.04, first(xt, 2L), xt, output="using xts::first: is.xts(x)")
539+
xt = xts(matrix(1:4, 2L, 2L), x)
540+
test(19.05, last(xt, 2L), xt, output="using xts::last: is.xts(x)")
541+
test(19.06, first(xt, 2L), xt, output="using xts::first: is.xts(x)")
542+
}
543+
# first on empty df now match head(df, n=1L), #3858
544+
df = data.frame(a=integer(), b=integer())
545+
test(19.11, first(df), df, output="!is.xts(x)")
546+
test(19.12, last(df), df, output="!is.xts(x)")
547+
})
548548
# xts last-first dispatch fix #4053
549549
x = 1:3
550550
y = as.POSIXct(x, origin="1970-01-01")
@@ -560,75 +560,76 @@ xt = structure(
560560
index = structure(c(1167782400, 1167868800, 1167955200), tzone = "UTC", tclass = "Date"),
561561
.Dim = c(3L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
562562
)
563-
options(datatable.verbose=TRUE)
564-
if (loaded[["xts"]]) {
565-
test(19.21, last(x, n=2L), 2:3, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
566-
test(19.22, last(y, n=2L), y[2:3], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
567-
test(19.23, last(x, n=1L), 3L, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
568-
test(19.24, last(y, n=1L), y[3L], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
569-
xt_last = structure(
570-
c(141.330002, 141.399994, 140.380005, 140.539993, 76645300, 108.360008),
571-
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
572-
index = structure(1167955200, tzone = "UTC", tclass = "Date"),
573-
.Dim = c(1L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
574-
)
575-
xt_last2 = structure(
576-
c(141.229996, 141.330002, 142.050003, 141.399994, 140.610001, 140.380005,
577-
141.669998, 140.539993, 69620600, 76645300, 109.231255, 108.360008),
578-
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
579-
index = structure(c(1167868800, 1167955200), tzone = "UTC", tclass = "Date"),
580-
.Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
581-
)
582-
test(19.25, last(xt), xt_last, output="using xts::last: is.xts(x)")
583-
test(19.26, last(xt, n=2L), xt_last2, output="using xts::last: is.xts(x)")
584-
test(19.31, first(x, n=2L), 1:2, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
585-
test(19.32, first(y, n=2L), y[1:2], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
586-
test(19.33, first(x, n=1L), 1L, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
587-
test(19.34, first(y, n=1L), y[1L], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
588-
xt_first = structure(
589-
c(142.25, 142.860001, 140.570007, 141.369995, 94807600, 108.999954),
590-
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
591-
index = structure(1167782400, tzone = "UTC", tclass = "Date"),
592-
.Dim = c(1L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
593-
)
594-
xt_first2 = structure(
595-
c(142.25, 141.229996, 142.860001, 142.050003, 140.570007, 140.610001, 141.369995, 141.669998, 94807600, 69620600, 108.999954, 109.231255),
596-
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
597-
index = structure(c(1167782400, 1167868800), tzone = "UTC", tclass = "Date"),
598-
.Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
599-
)
600-
test(19.35, first(xt), xt_first, output="using xts::first: is.xts(x)")
601-
test(19.36, first(xt, n=2L), xt_first2, output="using xts::first: is.xts(x)")
602-
} else {
603-
test(19.21, last(x, n=2L), 2:3, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
604-
test(19.22, last(y, n=2L), y[2:3], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
605-
test(19.23, last(x, n=1L), 3L, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
606-
test(19.24, last(y, n=1L), y[3L], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
607-
test(19.25, last(xt), error="you should have 'xts' installed already")
608-
test(19.26, last(xt, n=2L), error="you should have 'xts' installed already")
609-
test(19.31, first(x, n=2L), 1:2, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
610-
test(19.32, first(y, n=2L), y[1:2], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
611-
test(19.33, first(x, n=1L), 1L, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
612-
test(19.34, first(y, n=1L), y[1L], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
613-
test(19.35, first(xt), error="you should have 'xts' installed already")
614-
test(19.36, first(xt, n=2L), error="you should have 'xts' installed already")
615-
}
616-
test(19.41, last(x), 3L, output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
617-
test(19.42, last(y), y[3L], output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
618-
test(19.51, first(x), 1L, output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
619-
test(19.52, first(y), y[1L], output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
620-
test(19.61, last(df), structure(list(a=2L, b=2L), row.names=2L, class="data.frame"), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
621-
test(19.62, last(dt), data.table(a=2L, b=2L), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
622-
test(19.71, first(df), structure(list(a=1L, b=3L), row.names=1L, class="data.frame"), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
623-
test(19.72, first(dt), data.table(a=1L, b=3L), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
624-
# matrix/array utils::tail behavior is likely to change in future R, Michael is more in the topic
625-
test(19.81, last(mx), structure(c(3L, 6L, 9L), .Dim = c(1L, 3L), .Dimnames = list("[3,]", NULL)), output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
626-
expected = if (base::getRversion() < "3.7.0") 27L else structure(c(3L, 6L, 9L, 12L, 15L, 18L, 21L, 24L, 27L), .Dim = c(1L, 3L, 3L), .Dimnames = list("[3,]", NULL, NULL)) #4127
627-
test(19.82, last(ar), expected, output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
628-
test(19.91, first(mx), structure(c(1L, 4L, 7L), .Dim = c(1L, 3L)), output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
629-
expected = if (base::getRversion() < "3.7.0") 1L else structure(c(1L, 4L, 7L, 10L, 13L, 16L, 19L, 22L, 25L), .Dim = c(1L, 3L, 3L)) #4127
630-
test(19.92, first(ar), expected, output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
631-
options(old)
563+
local({
564+
old = options(datatable.verbose=TRUE); on.exit(options(old))
565+
if (loaded[["xts"]]) {
566+
test(19.21, last(x, n=2L), 2:3, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
567+
test(19.22, last(y, n=2L), y[2:3], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
568+
test(19.23, last(x, n=1L), 3L, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
569+
test(19.24, last(y, n=1L), y[3L], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
570+
xt_last = structure(
571+
c(141.330002, 141.399994, 140.380005, 140.539993, 76645300, 108.360008),
572+
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
573+
index = structure(1167955200, tzone = "UTC", tclass = "Date"),
574+
.Dim = c(1L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
575+
)
576+
xt_last2 = structure(
577+
c(141.229996, 141.330002, 142.050003, 141.399994, 140.610001, 140.380005,
578+
141.669998, 140.539993, 69620600, 76645300, 109.231255, 108.360008),
579+
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
580+
index = structure(c(1167868800, 1167955200), tzone = "UTC", tclass = "Date"),
581+
.Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
582+
)
583+
test(19.25, last(xt), xt_last, output="using xts::last: is.xts(x)")
584+
test(19.26, last(xt, n=2L), xt_last2, output="using xts::last: is.xts(x)")
585+
test(19.31, first(x, n=2L), 1:2, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
586+
test(19.32, first(y, n=2L), y[1:2], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
587+
test(19.33, first(x, n=1L), 1L, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
588+
test(19.34, first(y, n=1L), y[1L], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()")
589+
xt_first = structure(
590+
c(142.25, 142.860001, 140.570007, 141.369995, 94807600, 108.999954),
591+
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
592+
index = structure(1167782400, tzone = "UTC", tclass = "Date"),
593+
.Dim = c(1L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
594+
)
595+
xt_first2 = structure(
596+
c(142.25, 141.229996, 142.860001, 142.050003, 140.570007, 140.610001, 141.369995, 141.669998, 94807600, 69620600, 108.999954, 109.231255),
597+
class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC",
598+
index = structure(c(1167782400, 1167868800), tzone = "UTC", tclass = "Date"),
599+
.Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted"))
600+
)
601+
test(19.35, first(xt), xt_first, output="using xts::first: is.xts(x)")
602+
test(19.36, first(xt, n=2L), xt_first2, output="using xts::first: is.xts(x)")
603+
} else {
604+
test(19.21, last(x, n=2L), 2:3, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
605+
test(19.22, last(y, n=2L), y[2:3], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
606+
test(19.23, last(x, n=1L), 3L, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
607+
test(19.24, last(y, n=1L), y[3L], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
608+
test(19.25, last(xt), error="you should have 'xts' installed already")
609+
test(19.26, last(xt, n=2L), error="you should have 'xts' installed already")
610+
test(19.31, first(x, n=2L), 1:2, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
611+
test(19.32, first(y, n=2L), y[1:2], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
612+
test(19.33, first(x, n=1L), 1L, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
613+
test(19.34, first(y, n=1L), y[1L], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()")
614+
test(19.35, first(xt), error="you should have 'xts' installed already")
615+
test(19.36, first(xt, n=2L), error="you should have 'xts' installed already")
616+
}
617+
test(19.41, last(x), 3L, output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
618+
test(19.42, last(y), y[3L], output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
619+
test(19.51, first(x), 1L, output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
620+
test(19.52, first(y), y[1L], output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))")
621+
test(19.61, last(df), structure(list(a=2L, b=2L), row.names=2L, class="data.frame"), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
622+
test(19.62, last(dt), data.table(a=2L, b=2L), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
623+
test(19.71, first(df), structure(list(a=1L, b=3L), row.names=1L, class="data.frame"), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
624+
test(19.72, first(dt), data.table(a=1L, b=3L), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)")
625+
# matrix/array utils::tail behavior is likely to change in future R, Michael is more in the topic
626+
test(19.81, last(mx), structure(c(3L, 6L, 9L), .Dim = c(1L, 3L), .Dimnames = list("[3,]", NULL)), output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
627+
expected = if (base::getRversion() < "3.7.0") 27L else structure(c(3L, 6L, 9L, 12L, 15L, 18L, 21L, 24L, 27L), .Dim = c(1L, 3L, 3L), .Dimnames = list("[3,]", NULL, NULL)) #4127
628+
test(19.82, last(ar), expected, output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
629+
test(19.91, first(mx), structure(c(1L, 4L, 7L), .Dim = c(1L, 3L)), output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
630+
expected = if (base::getRversion() < "3.7.0") 1L else structure(c(1L, 4L, 7L, 10L, 13L, 16L, 19L, 22L, 25L), .Dim = c(1L, 3L, 3L)) #4127
631+
test(19.92, first(ar), expected, output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)")
632+
})
632633

633634
if (loaded[["xts"]]) { # was 2133 in tests.Rraw, #5516
634635
# keep.rownames in as.data.table.xts() supports a string, #4232
@@ -681,11 +682,12 @@ if (loaded[["nanotime"]]) {
681682
# was 2080.01-05 in tests.Rraw, #5516
682683
n = nanotime(1:4)
683684
n[2L] = NA
684-
opt = options(datatable.verbose=TRUE)
685-
test(24.1, between(n, nanotime(2), nanotime(10)), c(FALSE, NA, TRUE, TRUE), output="between parallel processing of integer64")
686-
test(24.2, between(n, nanotime(3), nanotime(10), incbounds=FALSE), c(FALSE, NA, FALSE, TRUE), output="between parallel processing of integer64")
687-
test(24.3, between(n, nanotime(3), nanotime(NA), incbounds=FALSE, NAbounds=NA), c(FALSE, NA, FALSE, NA), output="between parallel processing of integer64")
688-
options(opt)
685+
local({
686+
old = options(datatable.verbose=TRUE); on.exit(options(old))
687+
test(24.1, between(n, nanotime(2), nanotime(10)), c(FALSE, NA, TRUE, TRUE), output="between parallel processing of integer64")
688+
test(24.2, between(n, nanotime(3), nanotime(10), incbounds=FALSE), c(FALSE, NA, FALSE, TRUE), output="between parallel processing of integer64")
689+
test(24.3, between(n, nanotime(3), nanotime(NA), incbounds=FALSE, NAbounds=NA), c(FALSE, NA, FALSE, NA), output="between parallel processing of integer64")
690+
})
689691
test(24.4, between(1:10, nanotime(3), nanotime(6)), error="x is not integer64 but.*Please align classes")
690692
test(24.5, between(1:10, 3, nanotime(6)), error="x is not integer64 but.*Please align classes")
691693

@@ -718,14 +720,17 @@ if (loaded[["nanotime"]]) {
718720
test(27.14, lapply(nafill(l, fill=nanotime(0)), as.character), lapply(list(a=nanotime(c(1:2,0L,4:5)), b=nanotime(c(0L,2L,0L,4L,0L))), as.character))
719721

720722
# coerceAs verbose. Was 10.91-10.96 in nafill.Rraw, #6139
721-
x = nanotime(1L)
722-
test(27.21, options=c(datatable.verbose=2L), coerceAs(x, 1), 1, output="double[nanotime] into double[numeric]")
723-
test(27.22, options=c(datatable.verbose=2L), coerceAs(x, 1L), 1L, output="double[nanotime] into integer[integer]")
724-
test(27.23, options=c(datatable.verbose=2L), substring(coerceAs(x, "1"),1,11) %in% c("1","1970-01-01T"), output="double[nanotime] into character[character]")
725-
# ^ https://github.com/eddelbuettel/nanotime/issues/92; %in% so as not to break if nanotime adds as.character method
726-
test(27.24, options=c(datatable.verbose=2L), coerceAs(1, x), x, output="double[numeric] into double[nanotime]")
727-
test(27.25, options=c(datatable.verbose=2L), coerceAs(1L, x), x, output="integer[integer] into double[nanotime]")
728-
test(27.26, options=c(datatable.verbose=2L), coerceAs("1", x), x, output="character[character] into double[nanotime]", warning="Coercing.*character")
723+
local({
724+
x = nanotime(1L)
725+
old = options(datatable.verbose=2L); on.exit(options(old))
726+
test(27.21, coerceAs(x, 1), 1, output="double[nanotime] into double[numeric]")
727+
test(27.22, coerceAs(x, 1L), 1L, output="double[nanotime] into integer[integer]")
728+
test(27.23, substring(coerceAs(x, "1"), 1, 11) %in% c("1", "1970-01-01T"), output="double[nanotime] into character[character]")
729+
# ^ https://github.com/eddelbuettel/nanotime/issues/92; %in% so as not to break if nanotime adds as.character method
730+
test(27.24, coerceAs(1, x), x, output="double[numeric] into double[nanotime]")
731+
test(27.25, coerceAs(1L, x), x, output="integer[integer] into double[nanotime]")
732+
test(27.26, coerceAs("1", x), x, output="character[character] into double[nanotime]", warning="Coercing.*character")
733+
})
729734
}
730735

731736
# that plot works; moved from tests.Rraw 167 to here to save ram of loading graphics package and possible screen device issues on overloaded servers, #5517

0 commit comments

Comments
 (0)