Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
find class definitions with same name, different packages
git-svn-id: https://svn.r-project.org/R/trunk@56345 00db46b3-68df-0310-9c12-caf00c1e9a41
- Loading branch information
jmc
committed
Jul 9, 2011
1 parent
3af22bd
commit 3133d47
Showing
5 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Tests for handling classes with same name & different package slots | ||
## First: Can we define the classes and get the separate definitions | ||
## from the appropriate namespace or from the package slot in class(x)? | ||
stopifnot(require(Matrix)) | ||
|
||
## from: example(chol) | ||
sy2 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, NA,32,77)) | ||
c2 <- chol(sy2) | ||
|
||
clM <- getClass("Cholesky") | ||
|
||
setClass("Cholesky", contains = "numeric", representation(size = "integer")) | ||
|
||
clG <- getClass("Cholesky", where = .GlobalEnv) | ||
|
||
stopifnot(identical(getClass("Cholesky", where = asNamespace("Matrix")), | ||
clM)) | ||
|
||
stopifnot(identical(getClass(class(c2)), clM)) | ||
|
||
stopifnot(identical(evalq(getClass("Cholesky"), asNamespace("Matrix")), | ||
clM)) | ||
stopifnot(identical(getClass("Cholesky"), clG)) | ||
|
||
## Second: tests of methods defined for the same generic | ||
## (NOT YET!) | ||
|
||
## setAs("Cholesky", "matrix", | ||
## function(from) { | ||
## p <- from@size | ||
## value <- matrix(0, p, p) | ||
## start <- 0 | ||
## for(i in seq(length = p)) { | ||
## ii <- seq(length = i) | ||
## value[i, ii] <- from[start + ii] | ||
## start <- start + i | ||
## } | ||
## value | ||
## }, | ||
## replace = function(from, value) stop("Sorry, not implemented") | ||
## ) | ||
|