diff -Nru r-cran-r.methodss3-1.6.1/debian/changelog r-cran-r.methodss3-1.7.0/debian/changelog --- r-cran-r.methodss3-1.6.1/debian/changelog 2014-06-10 19:42:19.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/changelog 2015-07-04 10:02:35.000000000 +0000 @@ -1,3 +1,11 @@ +r-cran-r.methodss3 (1.7.0-1) unstable; urgency=medium + + * New upstream version + * cme fix dpkg-control + * Add autopkg test + + -- Andreas Tille Sat, 04 Jul 2015 12:02:32 +0200 + r-cran-r.methodss3 (1.6.1-1) unstable; urgency=low * Initial release (Closes: #751151) diff -Nru r-cran-r.methodss3-1.6.1/debian/control r-cran-r.methodss3-1.7.0/debian/control --- r-cran-r.methodss3-1.6.1/debian/control 2014-06-10 19:27:12.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/control 2015-07-04 09:39:44.000000000 +0000 @@ -6,7 +6,7 @@ Build-Depends: debhelper (>= 9), cdbs, r-base-dev (>= 3.0.0) -Standards-Version: 3.9.5 +Standards-Version: 3.9.6 Vcs-Browser: http://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-r.methodss3/trunk/ Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-r.methodss3/trunk/ Homepage: http://cran.r-project.org/web/packages/R.methodsS3/ diff -Nru r-cran-r.methodss3-1.6.1/debian/docs r-cran-r.methodss3-1.7.0/debian/docs --- r-cran-r.methodss3-1.6.1/debian/docs 2014-06-10 19:24:28.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/docs 2014-06-13 23:06:54.000000000 +0000 @@ -1 +1,3 @@ +tests debian/README.test +debian/tests/run-unit-test diff -Nru r-cran-r.methodss3-1.6.1/debian/README.test r-cran-r.methodss3-1.7.0/debian/README.test --- r-cran-r.methodss3-1.6.1/debian/README.test 2014-06-10 19:24:12.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/README.test 2015-07-04 09:46:07.000000000 +0000 @@ -1,5 +1,8 @@ Notes on how this package can be tested. ──────────────────────────────────────── -This package can be tested by loading it into R with the command -‘library(R.methodsS3)’ in order to confirm its integrity. +This package can be tested by running the provided test: + + sh ./run-unit-test + +in order to confirm its integrity. diff -Nru r-cran-r.methodss3-1.6.1/debian/tests/control r-cran-r.methodss3-1.7.0/debian/tests/control --- r-cran-r.methodss3-1.6.1/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/tests/control 2015-07-04 09:47:25.000000000 +0000 @@ -0,0 +1,3 @@ +Tests: run-unit-test +Depends: @ +Restrictions: allow-stderr diff -Nru r-cran-r.methodss3-1.6.1/debian/tests/run-unit-test r-cran-r.methodss3-1.7.0/debian/tests/run-unit-test --- r-cran-r.methodss3-1.6.1/debian/tests/run-unit-test 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/debian/tests/run-unit-test 2015-07-04 10:01:26.000000000 +0000 @@ -0,0 +1,16 @@ +#!/bin/sh -e + +oname=R.methodsS3 +pkg=r-cran-`echo $oname | tr [A-Z] [a-z]` + +if [ "$ADTTMP" = "" ] ; then + ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX` +fi +cd $ADTTMP +cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP +find . -name "*.gz" -exec gunzip \{\} \; +for rfile in *.[rR] ; do + R CMD BATCH $rfile +done +rm -fr $ADTTMP/* + diff -Nru r-cran-r.methodss3-1.6.1/DESCRIPTION r-cran-r.methodss3-1.7.0/DESCRIPTION --- r-cran-r.methodss3-1.6.1/DESCRIPTION 2014-01-05 22:09:59.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/DESCRIPTION 2015-02-20 08:16:51.000000000 +0000 @@ -1,9 +1,9 @@ Package: R.methodsS3 -Version: 1.6.1 +Version: 1.7.0 Depends: R (>= 2.2.0) Imports: utils -Date: 2014-01-04 -Title: Utility function for defining S3 methods +Date: 2015-02-19 +Title: S3 Methods Simplified Authors@R: c(person("Henrik", "Bengtsson", role=c("aut", "cre", "cph"), email = "henrikb@braju.com")) Author: Henrik Bengtsson [aut, cre, cph] @@ -11,7 +11,7 @@ Description: Methods that simplify the setup of S3 generic functions and S3 methods. Major effort has been made in making definition of methods as simple as possible with a minimum of maintenance for package developers. For example, generic functions are created automatically, if missing, and naming conflict are automatically solved, if possible. The method setMethodS3() is a good start for those who in the future may want to migrate to S4. This is a cross-platform package implemented in pure R that generates standard S3 methods. License: LGPL (>= 2.1) LazyLoad: TRUE -Packaged: 2014-01-05 07:12:06 UTC; hb NeedsCompilation: no +Packaged: 2015-02-20 03:15:35 UTC; hb Repository: CRAN -Date/Publication: 2014-01-05 23:09:59 +Date/Publication: 2015-02-20 09:16:51 diff -Nru r-cran-r.methodss3-1.6.1/inst/NEWS r-cran-r.methodss3-1.7.0/inst/NEWS --- r-cran-r.methodss3-1.6.1/inst/NEWS 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/inst/NEWS 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -Package: R.methodsS3 -==================== - -Version: 1.6.1 [2014-01-04] -o CLEANUP: Dropped obsolete argument 'ellipsesOnly' from setGenericS3(). - It was not used. Thanks Antonio Piccolboni for reporting on this. - - -Version: 1.6.0 [2013-11-12] -o BUG FIX: Generic function created by setGenericS3("foo<-") would not - have a last argument name 'value', which 'R CMD check' complains about. - - -Version: 1.5.3 [2013-11-05] -o ROBUSTNESS: Now setMethodS3(name, class, ...) and - setGenericS3(name, ...) assert that arguments 'name' and 'class' - are non-empty. - - -Version: 1.5.2 [2013-10-06] -o BETA: Added an in-official option to make setGenericS3() and - setMethodsS3() look for existing (generic) functions also in - imported namespaces. This will eventually become the default. -o ROBUSTNESS: Now isGenericS3() also compares to known generic - functions in the 'base' package. It also does a better job on - checking whether the function calls UseMethod() or not. -o Added argument 'inherits' to getGenericS3(). -o The above improvement of isGenericS3() means that setGenericS3() - does a better job to decided whether a generic function should be - created or not, which in turn means 'createGeneric=FALSE' is needed - much less in setMethodS3(). - - -Version: 1.5.1 [2013-09-15] -o BUG FIX: Forgot to explicitly import capture.output() from 'utils' - which could give an error on function "capture.output" not available - when setMethodS3() was used to define a "replacement" function. - This was only observed on the R v3.0.1 release version but not with - the more recent patched or devel versions. - In addition, two other 'utils' functions are now explicitly imported. - - -Version: 1.5.0 [2013-08-29] -o Added pkgStartupMessage() which acknowledges library(..., quietly=TRUE). - - -Version: 1.4.5 [2013-08-23] -o CLEANUP: Dropped deprecated inst/HOWTOSITE replaced by inst/CITATION. -o CLEANUP: No longer utilizing ':::' for "self" (i.e. R.methodsS3) methods. - - -Version: 1.4.4 [2013-05-19] -o CRAN POLICY: Now all Rd \usage{} lines are at most 90 characters long. - - -Version: 1.4.3 [2013-03-08] -o Added an Authors@R field to the DESCRIPTION. - - -Version: 1.4.2 [2012-06-22] -o Now setMethodS3(..., appendVarArgs=TRUE) ignores 'appendVarArgs' if - the method name is "==", "+", "-", "*", "/", "^", "%%", or "%/%", - (in addition to "$", "$<-", "[[", "[[<-", "[", "[<-"). It will also - ignore it if the name matches regular expressions "<-$" or "^%[^%]*%$". - The built in RCC validators were updated accordingly. - - -Version: 1.4.1 [2012-06-20] -o Added argument 'overwrite' to setGenericS3(). - - -Version: 1.4.0 [2012-04-20] -o Now setMethodS3() sets attribute "S3class" to the class. -o Added argument 'export' to setMethodS3() and setGenericS3(), which - sets attribute "export" to the same value. - - -Version: 1.3.0 [2012-04-16] -o Now only generic funcions are exported, and not all of them. -o Now all S3 methods are properly declared in NAMESPACE. - - -Version: 1.2.3 [2012-03-08] -o Now arguments '...' of setMethodS3() are passed to setGenericS3(). - - -Version: 1.2.2 [2011-11-17] -o CLEANUP: Dropped example(getMethodS3), which was for setMethodS3(). - - -Version: 1.2.1 [2010-09-18] -o BUG FIX: isGenericS3(), isGenericS4(), getGenericS3() and getMethodS3() - failed to locate functions created in the global environment while - there exist a function with the same name in the 'base' package. - The problem only affects the above functions and nothing else and it - did not exist prior to R.methodsS3 v1.2.0 when the package did not yet - have a namespace. Thanks John Oleynick for reporting on this problem. -o BUG FIX: isGenericS3() and isGenericS4() did not support specifying - the function by name as a character string, despite it was documented - to do so. Thanks John Oleynick for reporting on this. - - -Version: 1.2.0 [2010-03-13] -o Added a NAMESPACE. - - -Version: 1.1.0 [2010-01-02] -o Added getDispatchMethodS3() and findDispatchMethodsS3(). - - -Version: 1.0.3 [2008-07-02] -o Renamed HISTORY file to NEWS. - - -Version: 1.0.2 [2008-05-08] -o Added getMethodS3() and getGenericS3(). -o BUG FIX: isGenericS3() and isGenericS4() gave an error if - a function was passed. - - -Version: 1.0.1 [2008-03-06] -o Added paper to citation("R.methodsS3"). -o BUG FIX: Regular expression pattern 'a-Z' is illegal on (at least) - some locale, e.g. 'C' (where 'A-z' works). The only way to specify - the ASCII alphabet is to list all characters explicitly, which we now - do in all methods of the package. See the r-devel thread - "invalid regular expression '[a-Z]'" on 2008-03-05 for details. - - -Version: 1.0.0 [2007-09-17] -o Created by extracting setMethodS3() and related methods from the - R.oo package. The purpose is to provide setMethodS3() without - having to load (the already lightweight) R.oo package. For - previous history related to the methods in this package, please - see the history of the R.oo package. - diff -Nru r-cran-r.methodss3-1.6.1/MD5 r-cran-r.methodss3-1.7.0/MD5 --- r-cran-r.methodss3-1.6.1/MD5 2014-01-05 22:09:59.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/MD5 2015-02-20 08:16:51.000000000 +0000 @@ -1,24 +1,24 @@ -ccce9f2fe423c4b98e400e7c7903266f *DESCRIPTION +313d917cfb8006fb52235de6132a3c04 *DESCRIPTION f2de135e6d9960bdb3af2a8cbe691496 *NAMESPACE -e8aa0d7131b2f16358a67d1cb480d9e5 *R/000.R +b9f3d04596af355e6c25c7396dfe6feb *NEWS +2e86e8b470b9e59384be62210c3da00b *R/000.R 576ff223c1df906b32590e3e78d06d57 *R/001.R.KEYWORDS.R 1b1f9bd06d558a455d3f9374d2a378a3 *R/005.varArgs.R f1d34d487e5092e88713531cf6f10a6c *R/006.fixVarArgs.R -1568414e4379f7a1ca06c821723e17b8 *R/010.setGenericS3.R -5eba95ba62bb1c9ecec0f5c35a2edd4c *R/030.setMethodS3.R +085e40e0b603eb14de11e0fb86e6187b *R/010.setGenericS3.R +c2ca3d6adab3aefe4ff7ed3729583f70 *R/030.setMethodS3.R a4ab3969cbc2da96a8a2c1c2ed77b206 *R/999.NonDocumentedObjects.R 18dce216cff64556a53b1cd3916184f8 *R/999.package.R -4567347357a2ca42180863fa13347056 *R/findDispatchMethodsS3.R +dfaf4d7589eb5a039b562e3cb6d447f2 *R/findDispatchMethodsS3.R 919beccc0425b2a5bd93bfe4fbf78264 *R/getDispatchMethodS3.R 0628c16ffde62e06702c6a4570bb9123 *R/getGenericS3.R 11769e9934d6e9fae57f15b583f57d0a *R/getMethodS3.R -43277d6793df14b193b8ad3ef7e39f2d *R/isGenericS3.R -973afd36aad1aedc3ec54c7a74fa591d *R/pkgStartupMessage.R +44f342186a376d7e38555b28de85936e *R/isGenericS3.R +91b40723acbdd29d4143330b862d61b3 *R/pkgStartupMessage.R a1103ffdfd1c7ed50b0366f939d8549f *R/rccValidators.R 0e0caf77368e0fbee1650a5161a72a42 *R/throw.default.R -6e49cafc3623470fb8b61d45324cb1c6 *R/zzz.R +778b1ae1c9ef6801f7f9c1bf6344135d *R/zzz.R d8150d1411942582b7175c2bd26bf5eb *inst/CITATION -33d3347c3cbaa401344c2b037c4b9999 *inst/NEWS e62840f5029923bb7fde68ff03c85ba7 *man/Non-documented_objects.Rd 1b3a605645f2bf15b72946858f67a3bb *man/R.KEYWORDS.Rd af63cbe05b850b79cfa16ebb9b0acd42 *man/R.methodsS3-package.Rd @@ -32,3 +32,12 @@ d0ad086d52e72c12787dc638dd019a5a *man/setGenericS3.Rd 519552cddec0a9e862f9401ad0eb1206 *man/setMethodS3.Rd 08f7aee8b35261e03de5cf4e245a405a *man/throw.Rd +b24a7cd174fded033c7469ca5fe4f8b9 *tests/appendVarArgs.R +082b8b68b44a100236505a95ab9d6589 *tests/attributes.R +ed696bed0b50020f8ed486c34dd58219 *tests/findDispatchMethodsS3.R +0f76ef7503849bf045737401e47a3a3d *tests/getDispatchMethodS3.R +f2a3e7bf4f61342c91f284944d7888a2 *tests/isGenericS3S4.R +1c3c57bf749393c8dff21b2a3089688b *tests/pkgStartupMessage.R +292f96279990101660ccb20487c0f851 *tests/setGenericS3.R +c200d5724ee5e90a244a72643f106394 *tests/setMethodS3.R +b452094c7796d50a9aa77eac96407479 *tests/throw.R diff -Nru r-cran-r.methodss3-1.6.1/NEWS r-cran-r.methodss3-1.7.0/NEWS --- r-cran-r.methodss3-1.6.1/NEWS 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/NEWS 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,156 @@ +Package: R.methodsS3 +==================== + +Version: 1.7.0 [2015-02-19] +o ROBUSTNESS: Added several package tests. +o CONSISTENCY: Now isGenericS4() returns FALSE for non-existing + functions, just as isGenericS3() does. +o BUG FIX: isGenericS3() on a function gave error "object 'Math' of + mode 'function' was not found" when the 'methods' package was not + loaded, e.g. Rscript -e "R.methodsS3::isGenericS3(function(...) NULL)". +o BUG FIX/WORKAROUND: findDispatchMethodsS3() could in rare cases return + an extra set of false functions in R (< 3.1.2). This was due to a + bug in R (< 3.1.2) where the output of getAnywhere() contained + garbage results, e.g. getAnywhere(".Options")$objs. For backward + compatibility, findDispatchMethodsS3() now detects this case and works + around it. This bug was only detected after adding an explicit package + test for findDispatchMethodsS3(). + + +Version: 1.6.2 [2014-05-04] +o CLEANUP: Internal directory restructuring. + + +Version: 1.6.1 [2014-01-04] +o CLEANUP: Dropped obsolete argument 'ellipsesOnly' from setGenericS3(). + It was not used. Thanks Antonio Piccolboni for reporting on this. + + +Version: 1.6.0 [2013-11-12] +o BUG FIX: Generic function created by setGenericS3("foo<-") would not + have a last argument name 'value', which 'R CMD check' complains about. + + +Version: 1.5.3 [2013-11-05] +o ROBUSTNESS: Now setMethodS3(name, class, ...) and + setGenericS3(name, ...) assert that arguments 'name' and 'class' + are non-empty. + + +Version: 1.5.2 [2013-10-06] +o BETA: Added an in-official option to make setGenericS3() and + setMethodsS3() look for existing (generic) functions also in + imported namespaces. This will eventually become the default. +o ROBUSTNESS: Now isGenericS3() also compares to known generic + functions in the 'base' package. It also does a better job on + checking whether the function calls UseMethod() or not. +o Added argument 'inherits' to getGenericS3(). +o The above improvement of isGenericS3() means that setGenericS3() + does a better job to decided whether a generic function should be + created or not, which in turn means 'createGeneric=FALSE' is needed + much less in setMethodS3(). + + +Version: 1.5.1 [2013-09-15] +o BUG FIX: Forgot to explicitly import capture.output() from 'utils' + which could give an error on function "capture.output" not available + when setMethodS3() was used to define a "replacement" function. + This was only observed on the R v3.0.1 release version but not with + the more recent patched or devel versions. + In addition, two other 'utils' functions are now explicitly imported. + + +Version: 1.5.0 [2013-08-29] +o Added pkgStartupMessage() which acknowledges library(..., quietly=TRUE). + + +Version: 1.4.5 [2013-08-23] +o CLEANUP: Dropped deprecated inst/HOWTOSITE replaced by inst/CITATION. +o CLEANUP: No longer utilizing ':::' for "self" (i.e. R.methodsS3) methods. + + +Version: 1.4.4 [2013-05-19] +o CRAN POLICY: Now all Rd \usage{} lines are at most 90 characters long. + + +Version: 1.4.3 [2013-03-08] +o Added an Authors@R field to the DESCRIPTION. + + +Version: 1.4.2 [2012-06-22] +o Now setMethodS3(..., appendVarArgs=TRUE) ignores 'appendVarArgs' if + the method name is "==", "+", "-", "*", "/", "^", "%%", or "%/%", + (in addition to "$", "$<-", "[[", "[[<-", "[", "[<-"). It will also + ignore it if the name matches regular expressions "<-$" or "^%[^%]*%$". + The built in RCC validators were updated accordingly. + + +Version: 1.4.1 [2012-06-20] +o Added argument 'overwrite' to setGenericS3(). + + +Version: 1.4.0 [2012-04-20] +o Now setMethodS3() sets attribute "S3class" to the class. +o Added argument 'export' to setMethodS3() and setGenericS3(), which + sets attribute "export" to the same value. + + +Version: 1.3.0 [2012-04-16] +o Now only generic funcions are exported, and not all of them. +o Now all S3 methods are properly declared in NAMESPACE. + + +Version: 1.2.3 [2012-03-08] +o Now arguments '...' of setMethodS3() are passed to setGenericS3(). + + +Version: 1.2.2 [2011-11-17] +o CLEANUP: Dropped example(getMethodS3), which was for setMethodS3(). + + +Version: 1.2.1 [2010-09-18] +o BUG FIX: isGenericS3(), isGenericS4(), getGenericS3() and getMethodS3() + failed to locate functions created in the global environment while + there exist a function with the same name in the 'base' package. + The problem only affects the above functions and nothing else and it + did not exist prior to R.methodsS3 v1.2.0 when the package did not yet + have a namespace. Thanks John Oleynick for reporting on this problem. +o BUG FIX: isGenericS3() and isGenericS4() did not support specifying + the function by name as a character string, despite it was documented + to do so. Thanks John Oleynick for reporting on this. + + +Version: 1.2.0 [2010-03-13] +o Added a NAMESPACE. + + +Version: 1.1.0 [2010-01-02] +o Added getDispatchMethodS3() and findDispatchMethodsS3(). + + +Version: 1.0.3 [2008-07-02] +o Renamed HISTORY file to NEWS. + + +Version: 1.0.2 [2008-05-08] +o Added getMethodS3() and getGenericS3(). +o BUG FIX: isGenericS3() and isGenericS4() gave an error if + a function was passed. + + +Version: 1.0.1 [2008-03-06] +o Added paper to citation("R.methodsS3"). +o BUG FIX: Regular expression pattern 'a-Z' is illegal on (at least) + some locale, e.g. 'C' (where 'A-z' works). The only way to specify + the ASCII alphabet is to list all characters explicitly, which we now + do in all methods of the package. See the r-devel thread + "invalid regular expression '[a-Z]'" on 2008-03-05 for details. + + +Version: 1.0.0 [2007-09-17] +o Created by extracting setMethodS3() and related methods from the + R.oo package. The purpose is to provide setMethodS3() without + having to load (the already lightweight) R.oo package. For + previous history related to the methods in this package, please + see the history of the R.oo package. + diff -Nru r-cran-r.methodss3-1.6.1/R/000.R r-cran-r.methodss3-1.7.0/R/000.R --- r-cran-r.methodss3-1.6.1/R/000.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/000.R 2015-02-20 03:15:32.000000000 +0000 @@ -55,7 +55,15 @@ if (exists(name, mode="function", envir=env, inherits=inh)) { fcn <- get(name, mode="function", envir=env, inherits=inh); pkg <- attr(env, "name"); - pkg <- if (is.null(pkg)) "base" else gsub("^package:", "", pkg); + if (is.null(pkg)) { + pkg <- "base" + if (identical(env, baseenv())) { + } else if (identical(env, globalenv())) { + pkg <- "" + } + } else { + pkg <- gsub("^package:", "", pkg); + } break; } } # for (kk ...) diff -Nru r-cran-r.methodss3-1.6.1/R/010.setGenericS3.R r-cran-r.methodss3-1.7.0/R/010.setGenericS3.R --- r-cran-r.methodss3-1.6.1/R/010.setGenericS3.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/010.setGenericS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -59,9 +59,7 @@ if (is.element("enforceRCC", names(args))) { warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'."); # Turn off validators? - if (args$enforceRCC == FALSE) { - validators <- NULL; - } + if (args$enforceRCC == FALSE) validators <- NULL; } @@ -125,7 +123,8 @@ if (checkImports) inherits[1:2] <- TRUE; fcn <- .findFunction(name, envir=envirs, inherits=inherits); - fcnDef <- fcn$fcn; fcnPkg <- fcn$pkg; + fcnDef <- fcn$fcn; + fcnPkg <- fcn$pkg; if (!overwrite && !is.null(fcnDef)) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -145,13 +144,14 @@ # Search for preexisting default function in the same environments as above. nameDefault <- paste(name, ".default", sep=""); fcn <- .findFunction(nameDefault, envir=envirs, inherits=inherits); - defaultExists <- !is.null(fcn$fcn); defaultPkg <- fcn$pkg; + defaultExists <- !is.null(fcn$fcn); + defaultPkg <- fcn$pkg; if (defaultExists) { warning("Could not create generic function. There is already a", " non-generic function named ", name, "() in package ", fcnPkg, " with the same name as an existing default function ", - nameDefault, "() in package", defaultPkg, "."); + nameDefault, "() in ", defaultPkg, "."); return(); } diff -Nru r-cran-r.methodss3-1.6.1/R/030.setMethodS3.R r-cran-r.methodss3-1.7.0/R/030.setMethodS3.R --- r-cran-r.methodss3-1.6.1/R/030.setMethodS3.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/030.setMethodS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -91,9 +91,7 @@ if (is.element("enforceRCC", names(args))) { warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'."); # Turn off validators? - if (!args$enforceRCC) { - validators <- NULL; - } + if (!args$enforceRCC) validators <- NULL; } @@ -228,6 +226,7 @@ fStr <- sub("[\t\n\f\r ]*$", "", fStr); # when package loads! if (names(f)[length(f)] != "value") { + ## covr: skip=2 stop("Last argument of a ", name, "() method should be named 'value': ", fStr); } @@ -254,12 +253,14 @@ # Check for correct number of arguments if (length(f) != nbrOfReqArgs) { + ## covr: skip=2 stop("There should be exactly ", nbrOfReqArgs, " arguments of a ", name, "() method: ", fStr); } for (kk in 1:nbrOfReqArgs) { if (!is.na(reqArgs[kk]) && (names(f)[kk] != reqArgs[kk])) { + ## covr: skip=2 stop("Argument #", kk, " in a ", name, "() method, should be named '", reqArgs[kk], "': ", fStr); } diff -Nru r-cran-r.methodss3-1.6.1/R/findDispatchMethodsS3.R r-cran-r.methodss3-1.7.0/R/findDispatchMethodsS3.R --- r-cran-r.methodss3-1.6.1/R/findDispatchMethodsS3.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/findDispatchMethodsS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -61,6 +61,28 @@ next; } + # WORKAROUND: In R (< 3.1.?) there is a bug in getAnywhere() + # causing it to return garbage in parts of the 'objs' list. + hasBug <- (length(obj$objs) > length(obj$where)) + if (hasBug) { + ## Rebuild 'objs' manually + n <- length(obj$where) + obj$objs <- vector("list", length=n) + for (ii in seq_len(n)) { + where <- obj$where[[ii]] + tryCatch({ + if (grepl("^namespace:", where)) { + env <- asNamespace(gsub("^namespace:", "", where)) + } else { + env <- as.environment(where) + } + if (exists(fcnName, envir=env)) { + obj$objs[[ii]] <- get(fcnName, envir=env) + } + }, error = function(ex) {}) + } # for (ii ...) + } + # Keep only functions keep <- which(sapply(obj$objs, FUN=is.function)); if (length(keep) == 0) { @@ -94,6 +116,11 @@ ############################################################################ # HISTORY: +# 2015-02-02 +# o WORKAROUND: In R (< 3.1.?) there is a bug in getAnywhere() causing it +# to return garbage in parts of the 'objs' list. This bug has been +# there all the time, but was only detected now when a package test +# for findDispatchMethodsS3() was added. # 2010-12-02 # o Added Rdoc comments. # o Made findDispatchMethodsS3() a default method. diff -Nru r-cran-r.methodss3-1.6.1/R/isGenericS3.R r-cran-r.methodss3-1.7.0/R/isGenericS3.R --- r-cran-r.methodss3-1.6.1/R/isGenericS3.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/isGenericS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -118,8 +118,10 @@ # Finally, compare to all known internal generics for (name in knownInternalGenericS3()) { - generic <- get(name, mode="function", inherits=TRUE); - if (identical(fcn, generic)) return(TRUE); + if (exists(name, mode="function", inherits=TRUE)) { + generic <- get(name, mode="function", inherits=TRUE); + if (identical(fcn, generic)) return(TRUE); + } } FALSE; @@ -165,6 +167,9 @@ #*/########################################################################### isGenericS4.default <- function(fcn, envir=parent.frame(), ...) { if (is.character(fcn)) { + if (!exists(fcn, mode="function", envir=envir, inherits=TRUE)) { + return(FALSE); + } fcn <- get(fcn, mode="function", envir=envir, inherits=TRUE); } body <- body(fcn); @@ -182,6 +187,12 @@ ############################################################################ # HISTORY: +# 2015-01-13 +# o CONSISTENCY: Now isGenericS4() returns FALSE for non-existing +# functions, just as isGenericS3() does. +# o BUG FIX: isGenericS3() on a function gave error "object 'Math' of +# mode 'function' was not found" when the 'methods' package was not +# loaded, e.g. Rscript -e "R.methodsS3::isGenericS3(function(...) NULL)". # 2013-10-05 # o ROBUSTNESS: Now isGenericS3() also compares to known generic functions # in the 'base' package. It also does a better job on checking whether diff -Nru r-cran-r.methodss3-1.6.1/R/pkgStartupMessage.R r-cran-r.methodss3-1.7.0/R/pkgStartupMessage.R --- r-cran-r.methodss3-1.6.1/R/pkgStartupMessage.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/pkgStartupMessage.R 2015-02-20 03:15:32.000000000 +0000 @@ -63,7 +63,6 @@ missing <- eval(expression(missing(quietly)), envir=env); if (!missing) { quietly <- get("quietly", envir=env, inherits=FALSE); - # Done break; } diff -Nru r-cran-r.methodss3-1.6.1/R/zzz.R r-cran-r.methodss3-1.7.0/R/zzz.R --- r-cran-r.methodss3-1.6.1/R/zzz.R 2014-01-05 07:12:05.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/R/zzz.R 2015-02-20 03:15:32.000000000 +0000 @@ -1,17 +1,13 @@ +## covr: skip=all + .onAttach <- function(libname, pkgname) { - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set up RCC validators for R.methodsS3. - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - validators <- getOption("R.methodsS3:validators:setGenericS3"); - if (is.null(validators)) - validators <- list(); - validators <- c(validators, list(rccValidateSetGenericS3)); - validators <- getOption("R.methodsS3:validators:setMethodS3"); - if (is.null(validators)) - validators <- list(); - validators <- c(validators, list(rccValidateSetMethodS3)); + # Set up RCC validators for R.methodsS3 + validators <- getOption("R.methodsS3:validators:setGenericS3", list()) + validators <- c(validators, list(rccValidateSetGenericS3)) + validators <- getOption("R.methodsS3:validators:setMethodS3", list()) + validators <- c(validators, list(rccValidateSetMethodS3)) - pi <- utils::packageDescription(pkgname); + pi <- utils::packageDescription(pkgname) pkgStartupMessage(pkgname, " v", pi$Version, " (", pi$Date, - ") successfully loaded. See ?", pkgname, " for help."); + ") successfully loaded. See ?", pkgname, " for help.") } diff -Nru r-cran-r.methodss3-1.6.1/tests/appendVarArgs.R r-cran-r.methodss3-1.7.0/tests/appendVarArgs.R --- r-cran-r.methodss3-1.6.1/tests/appendVarArgs.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/appendVarArgs.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,17 @@ +library("R.methodsS3") + +message("TESTING: appendVarArgs()...") + +foobar <- function(a=1) print(a) +print(foobar) + +foobar <- appendVarArgs(foobar) +print(foobar) + +foobar <- appendVarArgs(foobar) +print(foobar) + +# Cleanup +rm(list=ls()) + +message("TESTING: appendVarArgs()...done") diff -Nru r-cran-r.methodss3-1.6.1/tests/attributes.R r-cran-r.methodss3-1.7.0/tests/attributes.R --- r-cran-r.methodss3-1.6.1/tests/attributes.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/attributes.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,27 @@ +library("R.methodsS3") + +message("TESTING: attributes()...") + +export <- R.methodsS3:::export +`export<-` <- R.methodsS3:::`export<-` +noexport <- R.methodsS3:::noexport +`S3class<-` <- R.methodsS3:::`S3class<-` + + +foo <- function() NULL +str(foo) + +foo <- export(foo) +str(foo) + +export(foo) <- TRUE +str(foo) + +foo <- noexport(foo) +str(foo) + +foo.Bar <- function(...) NULL +S3class(foo.Bar) <- "Bar" +str(foo) + +message("TESTING: attributes()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/findDispatchMethodsS3.R r-cran-r.methodss3-1.7.0/tests/findDispatchMethodsS3.R --- r-cran-r.methodss3-1.6.1/tests/findDispatchMethodsS3.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/findDispatchMethodsS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,11 @@ +library("R.methodsS3") + +message("TESTING: findDispatchMethodS3()...") + +## Odds and ends +# Trying to retrieve base::.Options, but should be +# detected as a non-function and return an empty result +fcn <- findDispatchMethodsS3("", "Options") +stopifnot(length(fcn) == 0L) + +message("TESTING: findDispatchMethodS3()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/getDispatchMethodS3.R r-cran-r.methodss3-1.7.0/tests/getDispatchMethodS3.R --- r-cran-r.methodss3-1.6.1/tests/getDispatchMethodS3.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/getDispatchMethodS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,15 @@ +library("R.methodsS3") + +message("TESTING: getDispatchMethodS3()...") + +fcn <- getDispatchMethodS3("print", "default") +print(fcn) + +tryCatch({ + fcn <- getDispatchMethodS3("print", "unknown") + print(fcn) +}, error = function(ex) { + print(ex) +}) + +message("TESTING: getDispatchMethodS3()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/isGenericS3S4.R r-cran-r.methodss3-1.7.0/tests/isGenericS3S4.R --- r-cran-r.methodss3-1.6.1/tests/isGenericS3S4.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/isGenericS3S4.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,21 @@ +library("R.methodsS3") + +message("TESTING: isGenericS3/S4()...") + +FUNs <- list( + isGenericS3=isGenericS3, + isGenericS4=isGenericS4 +) + +for (name in names(FUNs)) { + cat(sprintf("%s():\n", name)) + FUN <- FUNs[[name]] + print(FUN("print")) + print(FUN("show")) + print(FUN("unknown")) + print(FUN(print)) + print(FUN(sum)) + print(FUN(function() NULL)) +} + +message("TESTING: isGenericS3/S4()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/pkgStartupMessage.R r-cran-r.methodss3-1.7.0/tests/pkgStartupMessage.R --- r-cran-r.methodss3-1.6.1/tests/pkgStartupMessage.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/pkgStartupMessage.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,13 @@ +library("R.methodsS3") + +message("TESTING: pkgStartupMessage()...") + +msg <- "Hello world!" +pkgStartupMessage(msg) + +for (quietly in c(NA, FALSE, TRUE)) { + msg <- sprintf("Hello world! (quietly=%s)", quietly) + pkgStartupMessage(msg, quietly=quietly) +} + +message("TESTING: pkgStartupMessage()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/setGenericS3.R r-cran-r.methodss3-1.7.0/tests/setGenericS3.R --- r-cran-r.methodss3-1.6.1/tests/setGenericS3.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/setGenericS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,40 @@ +library("R.methodsS3") + +message("TESTING: setGenericS3()...") + +myCat.matrix <- function(..., sep=", ") { + cat("A matrix:\n") + cat(..., sep=sep) + cat("\n") +} + +myCat.default <- function(..., sep=", ") { + cat(..., sep=sep) + cat("\n") +} + +setGenericS3("myCat") + +myCat(1:10) +mat <- matrix(1:10, ncol=5) +myCat(mat) + +setGenericS3("foo", validators=list(R.methodsS3:::rccValidateSetGenericS3)) +setGenericS3("foo<-") + +bar.default <- function(...) cat("bar.default\n") +bar <- function(...) cat("bar\n") +setGenericS3("bar") + +print(getGenericS3("print")) + + +# Your defintion will redefine bar() above to bar.default(). +foobar <- function() print("foobar()") +setGenericS3("foobar") + + +# Cleanup +rm(list=ls()) + +message("TESTING: setGenericS3()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/setMethodS3.R r-cran-r.methodss3-1.7.0/tests/setMethodS3.R --- r-cran-r.methodss3-1.6.1/tests/setMethodS3.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/setMethodS3.R 2015-02-20 03:15:32.000000000 +0000 @@ -0,0 +1,82 @@ +library("R.methodsS3") + +message("TESTING: setMethodS3()...") + +###################################################################### +# Example 1 +###################################################################### +setMethodS3("foo", "default", function(x, ...) { + cat("In default foo():\n") + print(x, ...) +}) + + +setMethodS3("foo", "character", function(s) { + cat("In foo() for class 'character':\n") + print(s, ...) +}) + +# The generic function is automatically created! +print(foo) + +foo(123) +foo("123") + + +###################################################################### +# Example 2 +# +# Assume that in a loaded package there is already a function bar(), +# but you also want to use the name 'bar' for the character string. +# It may even be the case that you do not know of the other package, +# but your users do! +###################################################################### +# bar() in other package +bar <- function(x, y, ...) { + cat("In bar() of 'other' package.\n") +} + + +# Your defintion will redefine bar() above to bar.default(). +setMethodS3("bar", "character", function(object, ...) { + cat("In bar() for class 'character':\n") + print(object, ...) +}) + +bar(123) +bar("123") + +setMethodS3("bar<-", "character", function(x, value) { + attr(x, "bar") <- value + x +}) + +x <- "a" +bar(x) <- "hello" +str(x) + + +setMethodS3("$", "SomeClass", function(x, name) { + attr(x, name) +}) + +setMethodS3("$<-", "SomeClass", function(x, name, value) { + attr(x, name) <- value + x +}) + + + +setMethodS3("yaa", "character", abstract=TRUE, validators=list(R.methodsS3:::rccValidateSetMethodS3)) + +print(getMethodS3("yaa", "character")) + +# Redefine +setMethodS3("yaa", "character", abstract=TRUE, validators=list(R.methodsS3:::rccValidateSetMethodS3)) + + + +# Cleanup +rm(list=ls()) + +message("TESTING: setMethodS3()...DONE") diff -Nru r-cran-r.methodss3-1.6.1/tests/throw.R r-cran-r.methodss3-1.7.0/tests/throw.R --- r-cran-r.methodss3-1.6.1/tests/throw.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.7.0/tests/throw.R 2015-02-20 03:15:33.000000000 +0000 @@ -0,0 +1,19 @@ +library("R.methodsS3") + +message("TESTING: throw()...") + +rbern <- function(n=1, prob=1/2) { + if (prob < 0 || prob > 1) + throw("Argument 'prob' is out of range: ", prob) + rbinom(n=n, size=1, prob=prob) +} + +rbern(10, 0.4) +# [1] 0 1 0 0 0 1 0 0 1 0 +tryCatch({ + rbern(10, 10*0.4) +}, error=function(ex) { + print(ex) +}) + +message("TESTING: throw()...DONE")