[med-svn] [r-cran-backports] 07/12: New upstream version 1.0.5
Andreas Tille
tille at debian.org
Thu Sep 28 15:47:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository r-cran-backports.
commit e21d40d8c1b14719e7e45466662d9fa7d9e622d3
Author: Andreas Tille <tille at debian.org>
Date: Thu Sep 28 19:42:57 2017 +0200
New upstream version 1.0.5
---
DESCRIPTION | 23 ++++++++++++++++++++
MD5 | 41 +++++++++++++++++++++++++++++++++++
NAMESPACE | 16 ++++++++++++++
NEWS.md | 25 ++++++++++++++++++++++
R/anyNA.R | 18 ++++++++++++++++
R/dir.exists.R | 17 +++++++++++++++
R/endsWith.R | 20 +++++++++++++++++
R/file.info.R | 20 +++++++++++++++++
R/file.mode.R | 6 ++++++
R/file.mtime.R | 6 ++++++
R/file.size.R | 22 +++++++++++++++++++
R/get0.R | 23 ++++++++++++++++++++
R/hasName.R | 17 +++++++++++++++
R/lengths.R | 17 +++++++++++++++
R/startsWith.R | 19 +++++++++++++++++
R/strrep.R | 26 +++++++++++++++++++++++
R/trimws.R | 23 ++++++++++++++++++++
R/zzz.R | 2 ++
debian/README.test | 10 ---------
debian/changelog | 14 ------------
debian/compat | 1 -
debian/control | 26 -----------------------
debian/copyright | 24 ---------------------
debian/docs | 3 ---
debian/rules | 5 -----
debian/source/format | 1 -
debian/tests/control | 3 ---
debian/tests/run-unit-test | 23 --------------------
debian/watch | 2 --
man/anyNA.Rd | 20 +++++++++++++++++
man/dir.exists.Rd | 20 +++++++++++++++++
man/endsWith.Rd | 20 +++++++++++++++++
man/file.info.Rd | 21 ++++++++++++++++++
man/file.size.Rd | 31 +++++++++++++++++++++++++++
man/get0.Rd | 25 ++++++++++++++++++++++
man/hasName.Rd | 20 +++++++++++++++++
man/lengths.Rd | 20 +++++++++++++++++
man/startsWith.Rd | 20 +++++++++++++++++
man/strrep.Rd | 20 +++++++++++++++++
man/trimws.Rd | 21 ++++++++++++++++++
tests/helper/helper.R | 24 +++++++++++++++++++++
tests/test_anyNA.R | 14 ++++++++++++
tests/test_dir.exists.R | 11 ++++++++++
tests/test_file.info.R | 10 +++++++++
tests/test_file.mode.R | 9 ++++++++
tests/test_file.mtime.R | 9 ++++++++
tests/test_file.size.R | 9 ++++++++
tests/test_get0.R | 27 +++++++++++++++++++++++
tests/test_hasName.R | 12 +++++++++++
tests/test_lengths.R | 11 ++++++++++
tests/test_startsWith.R | 53 ++++++++++++++++++++++++++++++++++++++++++++++
tests/test_strrep.R | 40 ++++++++++++++++++++++++++++++++++
tests/test_trimws.R | 16 ++++++++++++++
53 files changed, 824 insertions(+), 112 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100644
index 0000000..b2b2bb7
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,23 @@
+Package: backports
+Type: Package
+Title: Reimplementations of Functions Introduced Since R-3.0.0
+Version: 1.0.5
+Author: Michel Lang <michellang at gmail.com>
+Maintainer: Michel Lang <michellang at gmail.com>
+Description: Implementations of functions which have been introduced in
+ R since version 3.0.0. The backports are conditionally exported which
+ results in R resolving the function names to the version shipped with R (if
+ available) and uses the implemented backports as fallback. This way package
+ developers can make use of the new functions without worrying about the
+ minimum required R version.
+URL: https://github.com/mllg/backports
+BugReports: https://github.com/mllg/backports/issues
+License: GPL-2
+NeedsCompilation: no
+ByteCompile: yes
+Depends: R (>= 3.0.0)
+Imports: utils
+RoxygenNote: 5.0.1
+Packaged: 2017-01-18 08:47:45 UTC; lang
+Repository: CRAN
+Date/Publication: 2017-01-18 18:07:29
diff --git a/MD5 b/MD5
new file mode 100644
index 0000000..95ec011
--- /dev/null
+++ b/MD5
@@ -0,0 +1,41 @@
+32d1d445f09bb092d53ef99d3bbf8e44 *DESCRIPTION
+ab1d7fcd59d3ddd9ea3743fecdc17146 *NAMESPACE
+d59425cdec7efac9488b6bcc223352a1 *NEWS.md
+41879b295859b9f3dd0efc69737d4a12 *R/anyNA.R
+e1fb60c17ea8a6677c3a80637f88c830 *R/dir.exists.R
+8d6708837ab0c9222d582576160dcdeb *R/endsWith.R
+daf73a06568906502efabcfa63cc3f45 *R/file.info.R
+f03ad94562dfb233f213366ceb192900 *R/file.mode.R
+9733ea86cf7e4e2ad39c226b68ab73ff *R/file.mtime.R
+fd795349608133c5b9b4850c8bce7115 *R/file.size.R
+14e2f4982a54c0309a4fa7ca4309c286 *R/get0.R
+b8bd9db45b49fe62e5101de2d80ac4ef *R/hasName.R
+1c40ec181e9e985ecd5d779c8f0e0395 *R/lengths.R
+1d59834fa8a4c2572b8a047376837618 *R/startsWith.R
+a4f40e3e2747b16bfe0cc6e80766e0f7 *R/strrep.R
+16341e541b227fbea9ec39503aee1181 *R/trimws.R
+78381589fed1c969ffe6c29970c4f2a0 *R/zzz.R
+bcc319894b0b1d5b341cd19c6552d0bc *man/anyNA.Rd
+908494c399056711f8df5003109b66b9 *man/dir.exists.Rd
+2942707dce880344eee9f730ae3c80d8 *man/endsWith.Rd
+e127ecfea33a757e681ba337e9c34103 *man/file.info.Rd
+ba75af7eaebfb1aad2e8a1866a7d7541 *man/file.size.Rd
+cd6eb792757e179bdb1a2d107c1b223a *man/get0.Rd
+d5dcfc16f981142e262427e8b13d95b1 *man/hasName.Rd
+4acd0d857fe0f05100e786c0b2f89e00 *man/lengths.Rd
+c0f25ff641325cf872c8bfa29e7d0837 *man/startsWith.Rd
+3c2dae33d42ba1fa42aacb482887597b *man/strrep.Rd
+f21fa9bd13531a4865910ae41a576179 *man/trimws.Rd
+f941990fd3a8aae0d97cfb6de2a62871 *tests/helper/helper.R
+1b97afed1a49ba2f7e7588661dd78481 *tests/test_anyNA.R
+d012f4fc8d451334726a1609bb6d0584 *tests/test_dir.exists.R
+d20ca8e00de706dfca77fc4e7e079a30 *tests/test_file.info.R
+8863972af374c21d56ea2625f357d1c1 *tests/test_file.mode.R
+80309a60390999f8c875299d5343311a *tests/test_file.mtime.R
+608d8ef6d47fde8c311efeb92600e7c5 *tests/test_file.size.R
+8bbb0281ed2c45c26a8b1fe8829a8426 *tests/test_get0.R
+224c4b67349277afb9ab178127d03470 *tests/test_hasName.R
+01ea7785d2d97d7364427f69ee028e43 *tests/test_lengths.R
+f5a7d4c6f5a89cd18a06029135ad1e57 *tests/test_startsWith.R
+f7bb3f7fe9fcfd990f6090c5fce29870 *tests/test_strrep.R
+7ff35bbbb455c565d8ebcac87a015d22 *tests/test_trimws.R
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..d283b1a
--- /dev/null
+++ b/NAMESPACE
@@ -0,0 +1,16 @@
+# Generated by roxygen2: do not edit by hand
+
+if (getRversion() < "3.2.0") export(anyNA)
+if (getRversion() < "3.2.0") export(dir.exists)
+if (getRversion() < "3.2.0") export(file.info)
+if (getRversion() < "3.2.0") export(file.mode)
+if (getRversion() < "3.2.0") export(file.mtime)
+if (getRversion() < "3.2.0") export(file.size)
+if (getRversion() < "3.2.0") export(get0)
+if (getRversion() < "3.2.0") export(trimws)
+if (getRversion() < "3.3.0") export(endsWith)
+if (getRversion() < "3.3.0") export(lengths)
+if (getRversion() < "3.3.0") export(startsWith)
+if (getRversion() < "3.3.0") export(strrep)
+if (getRversion() < "3.4.0") export(hasName)
+importFrom(utils,getFromNamespace)
diff --git a/NEWS.md b/NEWS.md
new file mode 100644
index 0000000..a1885da
--- /dev/null
+++ b/NEWS.md
@@ -0,0 +1,25 @@
+# backports 1.0.5
+
+* Added `get0()` for R versions prior to 3.2.0.
+* Added examples.
+
+# backports 1.0.4
+
+* Added `hasName()` for R versions prior to 3.4.0
+* Added `file.info()` with backport for argument `extra_cols`.
+
+# backports 1.0.3
+
+* Removed stringi dependency
+
+# backports 1.0.2
+
+* Fixed `file.size()`, `file.mtime()` and `file.mode()` for R-3.1.x.
+
+# backports 1.0.1
+
+* Added `file.size()`, `file.mtime()` and `file.mode()` for R versions prior to 3.2.0
+
+# backports 1.0.0
+
+* Initial version.
diff --git a/R/anyNA.R b/R/anyNA.R
new file mode 100644
index 0000000..d46b6a0
--- /dev/null
+++ b/R/anyNA.R
@@ -0,0 +1,18 @@
+#' @title Backport of anyNA for R versions < 3.2.0.
+#'
+#' @description
+#' See the original description in \code{base::anyNA}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(anyNA)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_anyNA = getFromNamespace("anyNA", "backports")
+#'
+#' bp_anyNA(letters)
+anyNA = function(x, recursive = FALSE) {
+ if (isTRUE(recursive) && (is.list(x) || is.pairlist(x)))
+ return(any(rapply(x, anyNA, how = "unlist", recursive = FALSE)))
+ any(is.na(x))
+}
diff --git a/R/dir.exists.R b/R/dir.exists.R
new file mode 100644
index 0000000..68b75bf
--- /dev/null
+++ b/R/dir.exists.R
@@ -0,0 +1,17 @@
+#' @title Backport of dir.exists for R < 3.2.0
+#'
+#' @description
+#' See the original description in \code{base::dir.exists}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(dir.exists)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_dir.exists = getFromNamespace("dir.exists", "backports")
+#'
+#' bp_dir.exists(tempdir())
+dir.exists = function(paths) {
+ x = base::file.info(paths)$isdir
+ !is.na(x) & x
+}
diff --git a/R/endsWith.R b/R/endsWith.R
new file mode 100644
index 0000000..a851cbc
--- /dev/null
+++ b/R/endsWith.R
@@ -0,0 +1,20 @@
+#' @title Backport of endsWith for R < 3.3.0
+#' @rdname endsWith
+#'
+#' @description
+#' See the original description in \code{base::endsWith}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.3.0") export(endsWith)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_endsWith = getFromNamespace("endsWith", "backports")
+#'
+#' bp_endsWith(c("aabb", "bbcc"), "bb")
+endsWith = function(x, suffix) {
+ if (!is.character(x) || !is.character(suffix))
+ stop("non-character object(s)")
+ n = nchar(x)
+ suppressWarnings(substr(x, n - nchar(suffix) + 1L, n) == suffix)
+}
diff --git a/R/file.info.R b/R/file.info.R
new file mode 100644
index 0000000..24a2f1d
--- /dev/null
+++ b/R/file.info.R
@@ -0,0 +1,20 @@
+#' @title Backport of \code{file.info} for R < 3.2.0
+#'
+#' @description
+#' Argument \code{extra_cols} has been backported.
+#' See the original description in \code{base::file.info}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(file.info)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_file.info = getFromNamespace("file.info", "backports")
+#'
+#' bp_file.info(file.path(R.home(), "COPYING"), extra_cols = FALSE)
+file.info = function (..., extra_cols = TRUE) {
+ if (isTRUE(extra_cols))
+ base::file.info(...)
+ else
+ base::file.info(...)[, 1:6, drop = FALSE]
+}
diff --git a/R/file.mode.R b/R/file.mode.R
new file mode 100644
index 0000000..18333b0
--- /dev/null
+++ b/R/file.mode.R
@@ -0,0 +1,6 @@
+#' @rdname file.size
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(file.mode)
+file.mode = function(...) {
+ base::file.info(...)$mode
+}
diff --git a/R/file.mtime.R b/R/file.mtime.R
new file mode 100644
index 0000000..2126a00
--- /dev/null
+++ b/R/file.mtime.R
@@ -0,0 +1,6 @@
+#' @rdname file.size
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(file.mtime)
+file.mtime = function(...) {
+ base::file.info(...)$mtime
+}
diff --git a/R/file.size.R b/R/file.size.R
new file mode 100644
index 0000000..537434d
--- /dev/null
+++ b/R/file.size.R
@@ -0,0 +1,22 @@
+#' @title Backports of wrappers around \code{file.info} for R < 3.2.0
+#' @rdname file.size
+#'
+#' @description
+#' See the original description in \code{base::file.size}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(file.size)
+#' @examples
+#' # get functions from namespace instead of possibly getting
+#' # implementations shipped with recent R versions:
+#' bp_file.size = getFromNamespace("file.size", "backports")
+#' bp_file.mode = getFromNamespace("file.size", "backports")
+#' bp_file.mtime = getFromNamespace("file.size", "backports")
+#'
+#' fn = file.path(R.home(), "COPYING")
+#' bp_file.size(fn)
+#' bp_file.mode(fn)
+#' bp_file.size(fn)
+file.size = function(...) {
+ base::file.info(...)$size
+}
diff --git a/R/get0.R b/R/get0.R
new file mode 100644
index 0000000..229280f
--- /dev/null
+++ b/R/get0.R
@@ -0,0 +1,23 @@
+#' @title Backport of get0 for R < 3.2.0
+#' @rdname get0
+#'
+#' @description
+#' See the original description in \code{base::get0}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(get0)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_get0 = getFromNamespace("get0", "backports")
+#'
+#' bp_get0("a")
+#' bp_get0("a", ifnotfound = 0)
+#'
+#' foo = 12
+#' bp_get0("foo")
+get0 = function(x, envir = pos.to.env(-1L), mode = "any", inherits = TRUE, ifnotfound = NULL) {
+ if (!is.character(x) || length(x) == 0L)
+ stop("Invalid first argument")
+ mget(x[1L], envir = envir, mode = mode, inherits = inherits, ifnotfound = list(ifnotfound))[[1L]]
+}
diff --git a/R/hasName.R b/R/hasName.R
new file mode 100644
index 0000000..f45ae7b
--- /dev/null
+++ b/R/hasName.R
@@ -0,0 +1,17 @@
+#' @title Backport of hasName for R < 3.4.0
+#' @rdname hasName
+#'
+#' @description
+#' See the original description in \code{utils::hasName}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.4.0") export(hasName)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_hasName = getFromNamespace("hasName", "backports")
+#'
+#' bp_hasName(list(a = 1, b = 2), c("a", "b", "c"))
+hasName = function(x, name) {
+ match(name, names(x), nomatch = 0L) > 0L
+}
diff --git a/R/lengths.R b/R/lengths.R
new file mode 100644
index 0000000..6612633
--- /dev/null
+++ b/R/lengths.R
@@ -0,0 +1,17 @@
+#' @title Backport of lengths for R < 3.2.0
+#' @rdname lengths
+#'
+#' @description
+#' See the original description in \code{base::lengths}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.3.0") export(lengths)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_lengths = getFromNamespace("lengths", "backports")
+#'
+#' bp_lengths(list(1:3, 2))
+lengths = function(x, use.names = TRUE) {
+ vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
+}
diff --git a/R/startsWith.R b/R/startsWith.R
new file mode 100644
index 0000000..2f99fb5
--- /dev/null
+++ b/R/startsWith.R
@@ -0,0 +1,19 @@
+#' @title Backport of startsWith for R < 3.3.0
+#' @rdname startsWith
+#'
+#' @description
+#' See the original description in \code{base::startsWith}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.3.0") export(startsWith)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_startsWith = getFromNamespace("startsWith", "backports")
+#'
+#' bp_startsWith(c("aabb", "bbcc"), "bb")
+startsWith = function(x, prefix) {
+ if (!is.character(x) || !is.character(prefix))
+ stop("non-character object(s)")
+ suppressWarnings(substr(x, 1L, nchar(prefix)) == prefix)
+}
diff --git a/R/strrep.R b/R/strrep.R
new file mode 100644
index 0000000..afa89d3
--- /dev/null
+++ b/R/strrep.R
@@ -0,0 +1,26 @@
+#' @title Backport of strrep for R < 3.3.0
+#' @rdname strrep
+#'
+#' @description
+#' See the original description in \code{base::strrep}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.3.0") export(strrep)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_strrep = getFromNamespace("strrep", "backports")
+#'
+#' bp_strrep("-", 10)
+strrep = function(x, times) {
+ x = as.character(x)
+ if (length(x) == 0L)
+ return(x)
+ unlist(.mapply(function(x, times) {
+ if (is.na(x) || is.na(times))
+ return(NA_character_)
+ if (times <= 0L)
+ return("")
+ paste0(replicate(times, x), collapse = "")
+ }, list(x = x, times = times), MoreArgs = list()), use.names = FALSE)
+}
diff --git a/R/trimws.R b/R/trimws.R
new file mode 100644
index 0000000..a059871
--- /dev/null
+++ b/R/trimws.R
@@ -0,0 +1,23 @@
+#' @title Backport of trimws for R < 3.3.0
+#' @rdname trimws
+#'
+#' @description
+#' See the original description in \code{base::trimws}.
+#'
+#' @keywords internal
+#' @rawNamespace if (getRversion() < "3.2.0") export(trimws)
+#' @examples
+#' # get function from namespace instead of possibly getting
+#' # implementation shipped with recent R versions:
+#' bp_trimws = getFromNamespace("trimws", "backports")
+#' bp_trimws(c(" a ", "b ", " c"))
+#'
+#' bp_trimws(c(" a ", "b ", " c"), which = "left")
+trimws = function(x, which = c("both", "left", "right")) {
+ which = match.arg(which)
+ if (which %in% c("left", "both"))
+ x = gsub("^[[:space:]]", "", x)
+ if (which %in% c("right", "both"))
+ x = gsub("[[:space:]]$", "", x)
+ return(x)
+}
diff --git a/R/zzz.R b/R/zzz.R
new file mode 100644
index 0000000..1841b12
--- /dev/null
+++ b/R/zzz.R
@@ -0,0 +1,2 @@
+#' @importFrom utils getFromNamespace
+NULL
diff --git a/debian/README.test b/debian/README.test
deleted file mode 100644
index e330aad..0000000
--- a/debian/README.test
+++ /dev/null
@@ -1,10 +0,0 @@
-Notes on how this package can be tested.
-────────────────────────────────────────
-
-To run the unit tests provided by the package you can do
-
- sh run-unit-test
-
-in this directory.
-
- -- Andreas Tille <tille at debian.org> Fri, 27 Jun 2014 19:02:17 +0200
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 92d1f53..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,14 +0,0 @@
-r-cran-backports (1.0.5-1) unstable; urgency=medium
-
- * New upstream version
- * Debug line in autopkgtest
- * Fix Vcs-Svn
- * Debhelper 10
-
- -- Andreas Tille <tille at debian.org> Fri, 20 Jan 2017 09:50:21 +0100
-
-r-cran-backports (1.0.4-1) unstable; urgency=medium
-
- * Initial release (closes: #842562)
-
- -- Andreas Tille <tille at debian.org> Sun, 30 Oct 2016 13:11:48 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index f599e28..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-10
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 8c1e788..0000000
--- a/debian/control
+++ /dev/null
@@ -1,26 +0,0 @@
-Source: r-cran-backports
-Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
-Section: gnu-r
-Priority: optional
-Build-Depends: debhelper (>= 10),
- dh-r,
- r-base-dev
-Standards-Version: 3.9.8
-Vcs-Browser: https://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-backports/trunk/
-Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-backports/trunk/
-Homepage: https://cran.r-project.org/package=backports
-
-Package: r-cran-backports
-Architecture: all
-Depends: ${R:Depends},
- ${misc:Depends}
-Recommends: ${R:Recommends}
-Suggests: ${R:Suggests}
-Description: reimplementation of functions introduced since R-3.0.0
- Implementations of functions which have been introduced in
- R since version 3.0.0. The backports are conditionally exported which
- results in R resolving the function names to the version shipped with R (if
- available) and uses the implemented backports as fallback. This way package
- developers can make use of the new functions without worrying about the
- minimum required R version.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index a4a6b79..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,24 +0,0 @@
-Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: backports
-Source: https://cran.r-project.org/package=backports
-
-Files: *
-Copyright: Michel Lang <michellang at gmail.com>
-License: GPL-2
-
-Files: debian/*
-Copyright: 2016 Andreas Tille <tille at debian.org>
-License: GPL-2
-
-License: GPL-2
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
- .
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- .
- On Debian systems, the complete text of the GNU General Public
- License can be found in `/usr/share/common-licenses/GPL-2'.
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 960011c..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,3 +0,0 @@
-tests
-debian/README.test
-debian/tests/run-unit-test
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 529c38a..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/make -f
-
-%:
- dh $@ --buildsystem R
-
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/tests/control b/debian/tests/control
deleted file mode 100644
index d2aa55a..0000000
--- a/debian/tests/control
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests: run-unit-test
-Depends: @
-Restrictions: allow-stderr
diff --git a/debian/tests/run-unit-test b/debian/tests/run-unit-test
deleted file mode 100644
index 5ca64f9..0000000
--- a/debian/tests/run-unit-test
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh -e
-
-pkg=r-cran-backports
-if [ "$ADTTMP" = "" ] ; then
- ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
- trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
-fi
-cd $ADTTMP
-cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP
-# gunzip *.gz
-export LC_ALL=C
-for test in *R
-do
- echo "Testing ${test}"
- R CMD BATCH ${test}
- if [ ! $? ] ; then
- echo "Test ${test} failed"
- exit 1
- else
- echo "Test ${test} passed"
- fi
- rm -f ${test}out .RData
-done
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index ac86d4f..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=4
-https://cran.r-project.org/src/contrib/backports_([-\d.]*)\.tar\.gz
diff --git a/man/anyNA.Rd b/man/anyNA.Rd
new file mode 100644
index 0000000..a7ca36d
--- /dev/null
+++ b/man/anyNA.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/anyNA.R
+\name{anyNA}
+\alias{anyNA}
+\title{Backport of anyNA for R versions < 3.2.0.}
+\usage{
+anyNA(x, recursive = FALSE)
+}
+\description{
+See the original description in \code{base::anyNA}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_anyNA = getFromNamespace("anyNA", "backports")
+
+bp_anyNA(letters)
+}
+\keyword{internal}
+
diff --git a/man/dir.exists.Rd b/man/dir.exists.Rd
new file mode 100644
index 0000000..e341220
--- /dev/null
+++ b/man/dir.exists.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/dir.exists.R
+\name{dir.exists}
+\alias{dir.exists}
+\title{Backport of dir.exists for R < 3.2.0}
+\usage{
+dir.exists(paths)
+}
+\description{
+See the original description in \code{base::dir.exists}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_dir.exists = getFromNamespace("dir.exists", "backports")
+
+bp_dir.exists(tempdir())
+}
+\keyword{internal}
+
diff --git a/man/endsWith.Rd b/man/endsWith.Rd
new file mode 100644
index 0000000..a914e0b
--- /dev/null
+++ b/man/endsWith.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/endsWith.R
+\name{endsWith}
+\alias{endsWith}
+\title{Backport of endsWith for R < 3.3.0}
+\usage{
+endsWith(x, suffix)
+}
+\description{
+See the original description in \code{base::endsWith}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_endsWith = getFromNamespace("endsWith", "backports")
+
+bp_endsWith(c("aabb", "bbcc"), "bb")
+}
+\keyword{internal}
+
diff --git a/man/file.info.Rd b/man/file.info.Rd
new file mode 100644
index 0000000..375b406
--- /dev/null
+++ b/man/file.info.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/file.info.R
+\name{file.info}
+\alias{file.info}
+\title{Backport of \code{file.info} for R < 3.2.0}
+\usage{
+file.info(..., extra_cols = TRUE)
+}
+\description{
+Argument \code{extra_cols} has been backported.
+See the original description in \code{base::file.info}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_file.info = getFromNamespace("file.info", "backports")
+
+bp_file.info(file.path(R.home(), "COPYING"), extra_cols = FALSE)
+}
+\keyword{internal}
+
diff --git a/man/file.size.Rd b/man/file.size.Rd
new file mode 100644
index 0000000..88acfec
--- /dev/null
+++ b/man/file.size.Rd
@@ -0,0 +1,31 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/file.mode.R, R/file.mtime.R, R/file.size.R
+\name{file.mode}
+\alias{file.mode}
+\alias{file.mtime}
+\alias{file.size}
+\title{Backports of wrappers around \code{file.info} for R < 3.2.0}
+\usage{
+file.mode(...)
+
+file.mtime(...)
+
+file.size(...)
+}
+\description{
+See the original description in \code{base::file.size}.
+}
+\examples{
+# get functions from namespace instead of possibly getting
+# implementations shipped with recent R versions:
+bp_file.size = getFromNamespace("file.size", "backports")
+bp_file.mode = getFromNamespace("file.size", "backports")
+bp_file.mtime = getFromNamespace("file.size", "backports")
+
+fn = file.path(R.home(), "COPYING")
+bp_file.size(fn)
+bp_file.mode(fn)
+bp_file.size(fn)
+}
+\keyword{internal}
+
diff --git a/man/get0.Rd b/man/get0.Rd
new file mode 100644
index 0000000..4d88fca
--- /dev/null
+++ b/man/get0.Rd
@@ -0,0 +1,25 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/get0.R
+\name{get0}
+\alias{get0}
+\title{Backport of get0 for R < 3.2.0}
+\usage{
+get0(x, envir = pos.to.env(-1L), mode = "any", inherits = TRUE,
+ ifnotfound = NULL)
+}
+\description{
+See the original description in \code{base::get0}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_get0 = getFromNamespace("get0", "backports")
+
+bp_get0("a")
+bp_get0("a", ifnotfound = 0)
+
+foo = 12
+bp_get0("foo")
+}
+\keyword{internal}
+
diff --git a/man/hasName.Rd b/man/hasName.Rd
new file mode 100644
index 0000000..6b01dbf
--- /dev/null
+++ b/man/hasName.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/hasName.R
+\name{hasName}
+\alias{hasName}
+\title{Backport of hasName for R < 3.4.0}
+\usage{
+hasName(x, name)
+}
+\description{
+See the original description in \code{utils::hasName}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_hasName = getFromNamespace("hasName", "backports")
+
+bp_hasName(list(a = 1, b = 2), c("a", "b", "c"))
+}
+\keyword{internal}
+
diff --git a/man/lengths.Rd b/man/lengths.Rd
new file mode 100644
index 0000000..16193ed
--- /dev/null
+++ b/man/lengths.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/lengths.R
+\name{lengths}
+\alias{lengths}
+\title{Backport of lengths for R < 3.2.0}
+\usage{
+lengths(x, use.names = TRUE)
+}
+\description{
+See the original description in \code{base::lengths}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_lengths = getFromNamespace("lengths", "backports")
+
+bp_lengths(list(1:3, 2))
+}
+\keyword{internal}
+
diff --git a/man/startsWith.Rd b/man/startsWith.Rd
new file mode 100644
index 0000000..d252cd3
--- /dev/null
+++ b/man/startsWith.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/startsWith.R
+\name{startsWith}
+\alias{startsWith}
+\title{Backport of startsWith for R < 3.3.0}
+\usage{
+startsWith(x, prefix)
+}
+\description{
+See the original description in \code{base::startsWith}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_startsWith = getFromNamespace("startsWith", "backports")
+
+bp_startsWith(c("aabb", "bbcc"), "bb")
+}
+\keyword{internal}
+
diff --git a/man/strrep.Rd b/man/strrep.Rd
new file mode 100644
index 0000000..4ee5c31
--- /dev/null
+++ b/man/strrep.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/strrep.R
+\name{strrep}
+\alias{strrep}
+\title{Backport of strrep for R < 3.3.0}
+\usage{
+strrep(x, times)
+}
+\description{
+See the original description in \code{base::strrep}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_strrep = getFromNamespace("strrep", "backports")
+
+bp_strrep("-", 10)
+}
+\keyword{internal}
+
diff --git a/man/trimws.Rd b/man/trimws.Rd
new file mode 100644
index 0000000..0dc2178
--- /dev/null
+++ b/man/trimws.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/trimws.R
+\name{trimws}
+\alias{trimws}
+\title{Backport of trimws for R < 3.3.0}
+\usage{
+trimws(x, which = c("both", "left", "right"))
+}
+\description{
+See the original description in \code{base::trimws}.
+}
+\examples{
+# get function from namespace instead of possibly getting
+# implementation shipped with recent R versions:
+bp_trimws = getFromNamespace("trimws", "backports")
+bp_trimws(c(" a ", "b ", " c"))
+
+bp_trimws(c(" a ", "b ", " c"), which = "left")
+}
+\keyword{internal}
+
diff --git a/tests/helper/helper.R b/tests/helper/helper.R
new file mode 100644
index 0000000..442b33b
--- /dev/null
+++ b/tests/helper/helper.R
@@ -0,0 +1,24 @@
+library(backports)
+
+expect_identical = function(x, y) {
+ stopifnot(identical(x, y))
+}
+
+expect_true = function(x) {
+ stopifnot(isTRUE(x))
+}
+
+makeCompareFun = function(f1, f2, ...) {
+ f1 = match.fun(f1)
+ f2 = match.fun(f2)
+
+ function(...) {
+ r1 = try(f1(...), silent = TRUE)
+ r2 = try(f2(...), silent = TRUE)
+ if (inherits(r1, "try-error")) {
+ stopifnot(inherits(r2, "try-error"))
+ } else {
+ expect_identical(r1, r2)
+ }
+ }
+}
diff --git a/tests/test_anyNA.R b/tests/test_anyNA.R
new file mode 100644
index 0000000..f5341ef
--- /dev/null
+++ b/tests/test_anyNA.R
@@ -0,0 +1,14 @@
+source("helper/helper.R")
+
+if (exists("anyNA", envir = baseenv())) {
+ f = get("anyNA", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::anyNA)
+
+ expect_same(1)
+ expect_same(NA)
+ expect_same(iris)
+ if (getRversion() >= "3.2.0") {
+ expect_same(list(1, 2, list(3, 4, list(NA))), recursive = FALSE)
+ expect_same(list(1, 2, list(3, 4, list(NA))), recursive = TRUE)
+ }
+}
diff --git a/tests/test_dir.exists.R b/tests/test_dir.exists.R
new file mode 100644
index 0000000..9ce5c1e
--- /dev/null
+++ b/tests/test_dir.exists.R
@@ -0,0 +1,11 @@
+source("helper/helper.R")
+
+if (exists("dir.exists", envir = baseenv())) {
+ f = get("dir.exists", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::dir.exists)
+
+ expect_same(tempdir())
+ expect_same(tempfile())
+ expect_same(rep.int(tempdir(), 2))
+ expect_same(TRUE)
+}
diff --git a/tests/test_file.info.R b/tests/test_file.info.R
new file mode 100644
index 0000000..71225ac
--- /dev/null
+++ b/tests/test_file.info.R
@@ -0,0 +1,10 @@
+source("helper/helper.R")
+
+x = tempdir()
+res1 = backports:::file.info(x, extra_cols = TRUE)
+res2 = backports:::file.info(x, extra_cols = FALSE)
+stopifnot(is.data.frame(res1), nrow(res1) == 1L, ncol(res1) >= 7L)
+stopifnot(is.data.frame(res2), nrow(res2) == 1L, ncol(res2) == 6L)
+
+expect_identical(res1, base::file.info(x))
+expect_identical(res1[, 1:6, drop = FALSE], res2)
diff --git a/tests/test_file.mode.R b/tests/test_file.mode.R
new file mode 100644
index 0000000..158af58
--- /dev/null
+++ b/tests/test_file.mode.R
@@ -0,0 +1,9 @@
+source("helper/helper.R")
+
+if (exists("file.mode", envir = baseenv())) {
+ f = get("file.mode", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::file.mode)
+
+ expect_same(R.home())
+ expect_same(file.path(R.home(), "COPYING"))
+}
diff --git a/tests/test_file.mtime.R b/tests/test_file.mtime.R
new file mode 100644
index 0000000..124354f
--- /dev/null
+++ b/tests/test_file.mtime.R
@@ -0,0 +1,9 @@
+source("helper/helper.R")
+
+if (exists("file.mtime", envir = baseenv())) {
+ f = get("file.mtime", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::file.mtime)
+
+ expect_same(R.home())
+ expect_same(file.path(R.home(), "COPYING"))
+}
diff --git a/tests/test_file.size.R b/tests/test_file.size.R
new file mode 100644
index 0000000..e6f91d6
--- /dev/null
+++ b/tests/test_file.size.R
@@ -0,0 +1,9 @@
+source("helper/helper.R")
+
+if (exists("file.size", envir = baseenv())) {
+ f = get("file.size", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::file.size)
+
+ expect_same(R.home())
+ expect_same(file.path(R.home(), "COPYING"))
+}
diff --git a/tests/test_get0.R b/tests/test_get0.R
new file mode 100644
index 0000000..922614b
--- /dev/null
+++ b/tests/test_get0.R
@@ -0,0 +1,27 @@
+source("helper/helper.R")
+
+if (exists("get0", envir = baseenv())) {
+ f = get("get0", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::get0)
+
+ foo = 1
+ ee = new.env()
+ ee$bar = 1
+ ee$foobar = function(x) x^2
+
+ expect_same(character(0), ifnotfound = 1)
+ expect_same(NA_character_, ifnotfound = 1)
+ expect_same(factor("a"), ifnotfound = 1)
+
+ expect_same("bar")
+ expect_same("bar", ifnotfound = 42)
+ expect_same("foo")
+ expect_same("foo", ifnotfound = 42)
+ expect_same(c("foo", "bar", "iris"), ifnotfound = 42)
+ expect_same(c("bar", "foo", "iris"), ifnotfound = 42)
+ expect_same(c("iris", "foo", "bar"), ifnotfound = 42)
+ expect_same("bar", envir = ee)
+ expect_same("bar", envir = ee, mode = "function")
+ expect_same("bar", envir = ee, mode = "function")
+ expect_same("foobar", envir = ee, mode = "function")
+}
diff --git a/tests/test_hasName.R b/tests/test_hasName.R
new file mode 100644
index 0000000..d547507
--- /dev/null
+++ b/tests/test_hasName.R
@@ -0,0 +1,12 @@
+source("helper/helper.R")
+
+if (exists("hasName", envir = getNamespace("utils"))) {
+ f = get("hasName", envir = getNamespace("utils"))
+ expect_same = makeCompareFun(f, backports:::hasName)
+
+ x = list(1, a = 12, bbb = 99)
+ expect_same(x, "a")
+ expect_same(x, "c")
+ expect_same(x, "bbb")
+ expect_same(x, "b")
+}
diff --git a/tests/test_lengths.R b/tests/test_lengths.R
new file mode 100644
index 0000000..836532b
--- /dev/null
+++ b/tests/test_lengths.R
@@ -0,0 +1,11 @@
+source("helper/helper.R")
+
+if (exists("lengths", envir = baseenv())) {
+ f = get("lengths", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::lengths)
+
+ expect_same(1:3)
+ expect_same(setNames(1:3, letters[1:3]))
+ expect_same(setNames(1:3, letters[1:3]), use.names = FALSE)
+ expect_same(iris)
+}
diff --git a/tests/test_startsWith.R b/tests/test_startsWith.R
new file mode 100644
index 0000000..92b9765
--- /dev/null
+++ b/tests/test_startsWith.R
@@ -0,0 +1,53 @@
+source("helper/helper.R")
+
+if (exists("startsWith", envir = baseenv())) {
+ f = get("startsWith", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::startsWith)
+
+ expect_same("a", "a")
+ expect_same(NA, "a")
+ expect_same("a", NA)
+ expect_same("a", "")
+ expect_same("", "a")
+ expect_same("", "")
+ expect_same(c("a", NA, "b"), "b")
+ expect_same("b", c("a", NA, "b"))
+ expect_same(letters, c("m", NA, ""))
+}
+
+if (exists("endsWith", envir = baseenv())) {
+ f = get("endsWith", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::endsWith)
+
+ expect_same("a", "a")
+ expect_same(NA, "a")
+ expect_same("a", NA)
+ expect_same("a", "")
+ expect_same("", "a")
+ expect_same("", "")
+ expect_same(c("a", NA, "b"), "b")
+ expect_same("b", c("a", NA, "b"))
+ expect_same(letters, c("m", NA, ""))
+}
+
+# adapted from R's unit tests
+t1 = c("Foobar", "bla bla", "something", "another", "blu", "brown", "blau blüht der Enzian")
+t2 = c("some text", "any text")
+t3 = c("Martin", "Zürich", "Mächler")
+
+expect_true(all(backports:::startsWith(t1, "")))
+expect_true(all(backports:::endsWith(t1, "")))
+expect_true(all(backports:::endsWith(t2, "")))
+expect_true(all(backports:::startsWith(t2, "")))
+expect_true(all(backports:::endsWith(t3, "")))
+expect_true(all(backports:::startsWith(t3, "")))
+expect_true(all(backports:::endsWith(t2, "text")))
+expect_true(all(backports:::endsWith(t2, " text")))
+expect_identical(backports:::startsWith(t1, "b" ), c(FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE))
+expect_identical(backports:::startsWith(t1, "bl"), c(FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE))
+expect_identical(backports:::startsWith(t1, "bla"),c(FALSE, TRUE, FALSE, FALSE,FALSE, FALSE, TRUE))
+expect_identical(backports:::endsWith(t1, "n"), c(FALSE,FALSE, FALSE, FALSE,FALSE, TRUE, TRUE))
+expect_identical(backports:::endsWith(t1, "an"), c(FALSE,FALSE, FALSE, FALSE,FALSE, FALSE, TRUE))
+expect_identical(backports:::startsWith(t3, "M" ), c( TRUE, FALSE, TRUE))
+expect_identical(backports:::startsWith(t3, "Ma"), c( TRUE, FALSE, FALSE))
+expect_identical(backports:::startsWith(t3, "Mä"), c(FALSE, FALSE, TRUE))
diff --git a/tests/test_strrep.R b/tests/test_strrep.R
new file mode 100644
index 0000000..989e34b
--- /dev/null
+++ b/tests/test_strrep.R
@@ -0,0 +1,40 @@
+source("helper/helper.R")
+
+if (exists("strrep", envir = baseenv())) {
+ f = get("strrep", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::strrep)
+
+ expect_same(NULL, 0)
+ expect_same(NULL, 1)
+ expect_same(NULL, 2)
+ expect_same(NULL, 1:2)
+ expect_same(character(0), 0)
+ expect_same(character(0), 1)
+ expect_same(character(0), 2)
+ expect_same(character(0), 1:2)
+ expect_same("", 0)
+ expect_same("", 1)
+ expect_same("", 2)
+ expect_same("", 1:2)
+ expect_same("a", 0)
+ expect_same("a", 1)
+ expect_same("a", 2)
+ expect_same("a", 1:2)
+ expect_same(NA, 0)
+ expect_same(NA, 1)
+ expect_same(NA, 1:2)
+ expect_same(NA_character_, 0)
+ expect_same(NA_character_, 1)
+ expect_same(NA_character_, 2)
+ expect_same(NA_character_, 1:2)
+ expect_same(letters[1:2], 0)
+ expect_same(letters[1:2], 1)
+ expect_same(letters[1:2], 2)
+ expect_same(letters[2:2], 1:2)
+ expect_same(TRUE, 0)
+ expect_same(TRUE, 1)
+ expect_same(TRUE, 2)
+ expect_same(TRUE, 1:2)
+ expect_same("a", NA)
+ expect_same("a", c(1, NA, 2))
+}
diff --git a/tests/test_trimws.R b/tests/test_trimws.R
new file mode 100644
index 0000000..8b933f7
--- /dev/null
+++ b/tests/test_trimws.R
@@ -0,0 +1,16 @@
+source("helper/helper.R")
+
+if (exists("trimws", envir = baseenv())) {
+ f = get("trimws", envir = baseenv())
+ expect_same = makeCompareFun(f, backports:::trimws)
+
+ expect_same("")
+ expect_same(NA)
+ expect_same(NA_character_)
+ expect_same(sprintf(" %s ", letters))
+ expect_same(" x ")
+ expect_same(" x ", which = "both")
+ expect_same(" x ", which = "left")
+ expect_same(" x ", which = "right")
+ expect_same(1)
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-backports.git
More information about the debian-med-commit
mailing list