The R Project SVN R

Rev

Rev 83997 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83997 Rev 84105
Line 60... Line 60...
60
abc(e1)
60
abc(e1)
61
abc(e0[[1]])
61
abc(e0[[1]])
62
abc(e1[[1]])
62
abc(e1[[1]])
63
 
63
 
64
 
64
 
-
 
65
## Some tests for `nameOfClass()`, called from inherits()
-
 
66
ClassX <- structure(list(), name = "ClassX",
-
 
67
                    class = c("S3pp_class", "S3pp_object"))
-
 
68
 
-
 
69
classx_instance <- structure(list(), class = c("ClassX", "S3pp_object"))
-
 
70
 
-
 
71
nameOfClass.S3pp_class <- function(x) attr(x, "name", TRUE)
-
 
72
nameOfClass.foo <- function(x) "bar"
-
 
73
 
-
 
74
stopifnot(exprs = {
-
 
75
    inherits(classx_instance, "ClassX")
-
 
76
    inherits(classx_instance, ClassX)
-
 
77
    ## ignore class on a character object
-
 
78
    isTRUE(inherits(1, structure("numeric", class = "foo")))
-
 
79
    ## make sure class is nor evaluated in calling nameOfClass
-
 
80
    isFALSE(inherits(1, structure(quote(stop("should not be evaluated")),
-
 
81
                                  class = "foo")))
-
 
82
})
-
 
83
 
-
 
84
 
65
## Some tests for `@` dispatching
85
## Some tests for `@` dispatching
66
## make sure that
86
## make sure that
67
## - `@` evals the first args only once,
87
## - `@` evals the first args only once,
68
## -  doesn't dispatch for S4
88
## -  doesn't dispatch for S4
69
## -  works on `.Data` even for nonS4 objects
89
## -  works on `.Data` even for nonS4 objects