connected
  7   坙栞m_J	򳅯2燵��阞芽慆E尙墉��刃?熍�D�柿� +�    zero_width_xts <- xts()

info_msg <- "test.merge_empty_xts_with_2_scalars"
m1 <- merge(zero_width_xts, 1, 1)
m2 <- merge(merge(zero_width_xts, 1), 1)
expect_identical(m1, zero_width_xts)
expect_identical(m2, zero_width_xts)

info_msg <- "test.merge_more_than_2_zero_width_objects"
m1 <- merge(zero_width_xts, zero_width_xts, zero_width_xts)
expect_identical(m1, zero_width_xts)

### Tests for NA in index. Construct xts object using structure() because
### xts constructors should not allow users to create objects with NA in
### the index
indexHasNA_dbl <-
structure(1:5, .Dim = c(5L, 1L),
          index = structure(c(1, 2, 3, 4, NA), tzone = "",
                            tclass = c("POSIXct", "POSIXt")),
          .indexCLASS = c("POSIXct", "POSIXt"),
          .indexTZ = "", tclass = c("POSIXct", "POSIXt"),
          tzone = "", class = c("xts", "zoo"))

indexHasNA_int <-
structure(1:5, .Dim = c(5L, 1L),
          index = structure(c(1L, 2L, 3L, 4L, NA), tzone = "",
                            tclass = c("POSIXct", "POSIXt")),
          .indexCLASS = c("POSIXct", "POSIXt"),
          .indexTZ = "", tclass = c("POSIXct", "POSIXt"),
          tzone = "", class = c("xts", "zoo"))

info_msg <- "test.merge_index_contains_NA_integer"
expect_error(merge(indexHasNA_int, indexHasNA_int), info = info_msg)

info_msg <- "test.merge_index_contains_NA_double"
expect_error(merge(indexHasNA_dbl, indexHasNA_dbl), info = info_msg)

info_msg <- "test.merge_index_contains_NaN"
x <- indexHasNA_dbl
idx <- attr(x, "index")
idx[length(idx)] <- NaN
attr(x, "index") <- idx
expect_error(merge(x, x), info = info_msg)

info_msg <- "test.merge_index_contains_Inf"
x <- indexHasNA_dbl
idx <- attr(x, "index")
idx[length(idx)] <- Inf
attr(x, "index") <- idx
expect_error(merge(x, x), info = info_msg)

idx <- rev(idx)
idx[1L] <- -Inf
attr(x, "index") <- idx
expect_error(merge(x, x), info = info_msg)
### /end Tests for NA in index


### zero-length fill argument
info_msg <- "test.merge_fill_NULL"
x1 <- .xts(1, 1)
x2 <- .xts(2, 2)
x <- merge(x1, x2, fill = NULL)
out <- .xts(matrix(c(1, NA, NA, 2), 2), c(1,2))
colnames(out) <- c("x1", "x2")
expect_identical(x, out, info = info_msg)

info_msg <- "test.merge_fill_zero_length"
x1 <- .xts(1, 1)
x2 <- .xts(2, 2)
x <- merge(x1, x2, fill = numeric())
out <- .xts(matrix(c(1, NA, NA, 2), 2), c(1,2))
colnames(out) <- c("x1", "x2")
expect_identical(x, out, info = info_msg)

info_msg <- "test.merge_with_zero_width_returns_original_type"
M1 <- .xts(1:3, 1:3, dimnames = list(NULL, "m1"))
types <- c("double", "integer", "logical", "character")
for (type in types) {
  m1 <- M1
  storage.mode(m1) <- type
  e1 <- .xts(,1:3)
  m2 <- merge(m1, e1)
  expect_identical(m1, m2, info = paste(info_msg, "- type =", type))
}

info_msg <- "test.n_way_merge_on_all_types"
D1 <- as.Date("2018-01-03")-2:0
M1 <- xts(1:3, D1, dimnames = list(NULL, "m"))
M3 <- xts(cbind(1:3, 1:3, 1:3), D1,
          dimnames = list(NULL, c("m", "m.1", "m.2")))
types <- c("double", "integer", "logical", "character", "complex")
for (type in types) {
  m1 <- M1
  m3 <- M3
  storage.mode(m1) <- storage.mode(m3) <- type
  m <- merge(m1, m1, m1)
  expect_identical(m, m3, info = paste(info_msg, "- type =", type))
}

info_msg <- "test.shorter_colnames_for_unnamed_args"
X <- .xts(rnorm(10, 10), 1:10)
types <- c("double", "integer", "logical", "character", "complex")
for (type in types) {
  x <- X
  storage.mode(x) <- type
  mx <- do.call(merge, list(x, x))
  expect_true(all(nchar(colnames(mx)) < 200),
              info = paste(info_msg, "- type = ", type))
}


info_msg <- "test.check_names_false"
x <- .xts(1:3, 1:3, dimnames = list(NULL, "42"))
y <- .xts(1:3, 1:3, dimnames = list(NULL, "21"))
z <- merge(x, y)                       # leading "X" added
expect_identical(colnames(z), c("X42", "X21"), info = info_msg)
z <- merge(x, y, check.names = TRUE)   # same
expect_identical(colnames(z), c("X42", "X21"), info = info_msg)
z <- merge(x, y, check.names = FALSE)  # should have numeric column 