Skip to content

Commit e5709a1

Browse files
fix test error messages, remove extra '[]' from brackify errors
1 parent 11b3d7b commit e5709a1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

R/mergelist.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ mergepair = function(lhs, rhs, on, how, mult, lhs.cols=names(lhs), rhs.cols=name
157157
stopf("'on' is missing and necessary key is not present")
158158
}
159159
if (any(bad.on <- !on %chin% names(lhs)))
160-
stopf("'on' argument specifies columns to join [%s] that are not present in %s table [%s]", brackify(on[bad.on]), "LHS", brackify(names(lhs)))
160+
stopf("'on' argument specifies columns to join %s that are not present in %s table %s", brackify(on[bad.on]), "LHS", brackify(names(lhs)))
161161
if (any(bad.on <- !on %chin% names(rhs)))
162-
stopf("'on' argument specifies columns to join [%s] that are not present in %s table [%s]", brackify(on[bad.on]), "RHS", brackify(names(rhs)))
162+
stopf("'on' argument specifies columns to join %s that are not present in %s table %s", brackify(on[bad.on]), "RHS", brackify(names(rhs)))
163163
} else if (is.null(on)) {
164164
on = character() ## cross join only
165165
}
@@ -203,7 +203,7 @@ mergepair = function(lhs, rhs, on, how, mult, lhs.cols=names(lhs), rhs.cols=name
203203
copy_x = TRUE
204204
## ensure no duplicated column names in merge results
205205
if (any(dup.i <- names(out.i) %chin% names(out.x)))
206-
stopf("merge result has duplicated column names [%s], use 'cols' argument or rename columns in 'l' tables", brackify(names(out.i)[dup.i]))
206+
stopf("merge result has duplicated column names %s, use 'cols' argument or rename columns in 'l' tables", brackify(names(out.i)[dup.i]))
207207
}
208208

209209
## stack i and x
@@ -269,7 +269,7 @@ mergelist_impl_ = function(l, on, cols, how, mult, join.many, copy) {
269269
if (!all(idx <- lengths(l) > 0L))
270270
stopf("Tables in 'l' must all have columns, but these entries have 0: %s", brackify(which(!idx)))
271271
if (any(idx <- vapply_1i(l, function(x) anyDuplicated(names(x))) > 0L))
272-
stopf("Column names in individual 'l' entries must be unique, but these have some duplicates: [%s]", brackify(which(idx)))
272+
stopf("Column names in individual 'l' entries must be unique, but these have some duplicates: %s", brackify(which(idx)))
273273

274274
if (!isTRUEorFALSE(copy))
275275
stopf("'%s' must be TRUE or FALSE", "copy")

inst/tests/mergelist.Rraw

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,16 @@ test(101.11, mergelist(l, on="xx"), error="are not present in LHS")
395395
test(101.12, mergelist(l, on="x", join.many=NA), error="must be TRUE or FALSE")
396396
test(101.13, mergelist(list(data.table(a=1L), data.table(a=c(1L,1L))), on="a", mult="all"), data.table(a=c(1L,1L))) ## copyCols(, cols=integer())
397397
test(101.14, mergelist(list()), data.table())
398-
test(101.15, mergelist(list(data.table())), error="must be non-zero columns tables")
399-
test(101.16, mergelist(list(data.table(), data.table())), error="must be non-zero columns tables")
398+
test(101.15, mergelist(list(data.table())), error="must all have columns")
399+
test(101.16, mergelist(list(data.table(), data.table())), error="must all have columns")
400400
test(101.17, mergelist(list(data.table(a=integer()), data.table(a=integer())), on="a"), data.table(a=integer()))
401-
test(101.18, mergelist(list(data.table(a=1L), data.table(a=1L, b=1L, b=1L)), on="a"), error="have duplicated column names")
401+
test(101.18, mergelist(list(data.table(a=1L), data.table(a=1L, b=1L, b=1L)), on="a"), error="must be unique")
402402
test(101.19, mergelist(list(data.table(a=1L, b=1L), data.table(a=1L, b=2L)), on="a"), error="merge result has duplicated column names")
403403
test(101.20, mergelist(list(data.table(a=1L, b=1L), data.table(a=1L, b=2L)), on="a", cols=list(NULL, character())), data.table(a=1L, b=1L))
404404
test(101.21, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", cols=list(NULL, c("a",NA))), error="must be a list of non-zero length, non-NA, non-duplicated, character vectors")
405405
test(101.22, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", cols=list(NULL, c("a","a"))), error="must be a list of non-zero length, non-NA, non-duplicated, character vectors")
406-
test(101.23, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", join.many=list(TRUE, TRUE)), error="must be TRUE or FALSE, or a list of such which length must be")
407-
test(101.24, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", join.many=list(NA)), error="must be TRUE or FALSE, or a list of such which length must be")
406+
test(101.23, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", join.many=list(TRUE, TRUE)), error="must be TRUE or FALSE, or a list of such whose length must be")
407+
test(101.24, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on="a", join.many=list(NA)), error="must be TRUE or FALSE, or a list of such whose length must be")
408408
test(101.25, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on=c("a","a")), error="non-NA, non-duplicated, character vector, or a list")
409409
test(101.26, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L)), on=c("a",NA)), error="non-NA, non-duplicated, character vector, or a list")
410410
test(101.27, mergelist(list(data.table(a=1L, d=1L), data.table(a=1L, b=2L), data.table(a=1L)), on=list("a", c("a",NA))), error="non-NA, non-duplicated, character vector, or a list")
@@ -451,13 +451,13 @@ test(102.33, mergelist(l, how="right"), data.table(x=2:3, key="x"))
451451
test(102.34, mergelist(l, how="full"), data.table(x=1:3))
452452
l = list(data.table(x=1:2, y=1:2, z=1:2, zz=1:2, key=c("y","x","z","zz")), data.table(a=2:3, b=2:3, x=2:3, y=2:3, key=c("x","y","a")))
453453
test(102.41, mergelist(l, how="inner"), data.table(x=2L, y=2L, z=2L, zz=2L, a=2L, b=2L, key=c("y","x","z","zz"))) ## key len 2+ to take intersect, and align order, for inner and full
454-
test(102.42, mergelist(l, how="left"), error="specify columns to join.*that are not present in LHS table")
455-
test(102.43, mergelist(l, how="right"), error="specify columns to join.*that are not present in RHS table")
454+
test(102.42, mergelist(l, how="left"), error="specifies columns to join.*that are not present in LHS table")
455+
test(102.43, mergelist(l, how="right"), error="specifies columns to join.*that are not present in RHS table")
456456
test(102.44, mergelist(l, how="full"), data.table(x=1:3, y=1:3, z=c(1:2,NA), zz=c(1:2,NA), a=c(NA,2:3), b=c(NA,2:3)))
457457
l = list(data.table(a=1:2, x=1:2, key=c("x","a")), data.table(x=2:3, y=2:3, z=2:3, key=c("y","x","z")))
458458
test(102.51, mergelist(l, how="inner"), data.table(x=2L, a=2L, y=2L, z=2L, key=c("x","a"))) ## align order to shorter
459-
test(102.52, mergelist(l, how="left"), error="specify columns to join.*that are not present in LHS table")
460-
test(102.53, mergelist(l, how="right"), error="specify columns to join.*that are not present in RHS table")
459+
test(102.52, mergelist(l, how="left"), error="specifies columns to join.*that are not present in LHS table")
460+
test(102.53, mergelist(l, how="right"), error="specifies columns to join.*that are not present in RHS table")
461461
test(102.54, mergelist(l, how="full"), data.table(x=1:3, a=c(1:2,NA), y=c(NA,2:3), z=c(NA,2:3)))
462462
## missing on, cascade join fields
463463
l = list(
@@ -496,7 +496,7 @@ rm(ans1, ans2)
496496
## on list
497497
test(102.71, mergelist(list(data.table(x=1L, y=2L), data.table(a=1L, y=2L), data.table(a=1L, z=2L)), on=list("y","a")), data.table(a=1L, y=2L, x=1L, z=2L))
498498
test(102.72, mergelist(list(data.table(x=1L, y=2L), data.table(a=1L, y=2L, b=3L), data.table(a=1L, b=3L, z=2L)), on=list("y",c("a","b"))), data.table(a=1L, b=3L, y=2L, x=1L, z=2L))
499-
test(102.73, mergelist(list(data.table(x=1L, y=2L), data.table(a=1L, y=2L, b=3L), data.table(a=1L, b=3L, z=2L)), on=list("y",c("a","x"))), error="specify columns to join.*that are not present in RHS table")
499+
test(102.73, mergelist(list(data.table(x=1L, y=2L), data.table(a=1L, y=2L, b=3L), data.table(a=1L, b=3L, z=2L)), on=list("y",c("a","x"))), error="specifies columns to join.*that are not present in RHS table")
500500

501501
## cols argument
502502
l = list(data.table(id1=1:2, v1=1:2, v2=2:1, key="id1"), data.table(id1=2:3, v3=1:2, v4=2:1, key="id1"))

0 commit comments

Comments
 (0)