The R Project SVN R

Rev

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

Rev 56186 Rev 56287
Line 140... Line 140...
140
 
140
 
141
cd1 <- new("cdate", "abcdef", date = Sys.Date())
141
cd1 <- new("cdate", "abcdef", date = Sys.Date())
142
 
142
 
143
cd2 <- new("vdate", "abcdef", date = Sys.Date())
143
cd2 <- new("vdate", "abcdef", date = Sys.Date())
144
 
144
 
-
 
145
stopifnot(identical(cc(letters, character(), cd1),
145
stopifnot(identical(cc(letters, character(), cd1), paste(letters, character(), cd1))) # the "character" method
146
           paste(letters, character(), cd1))) # the "character" method
146
 
147
 
-
 
148
stopifnot(identical(cc(letters, character(), cd2),
-
 
149
                    c(letters, character(), cd2)))
147
stopifnot(identical(cc(letters, character(), cd2), c(letters, character(), cd2))) # the default, because "vdate" doesn't extend "character"
150
# the default, because "vdate" doesn't extend "character"
148
 
151
 
149
stopifnot(identical(cc(1:10, 1+1i), sum(1:10, 1+1i))) # the "Number" method
152
stopifnot(identical(cc(1:10, 1+1i), sum(1:10, 1+1i))) # the "Number" method
150
 
153
 
151
stopifnot(identical(cc(1:10, 1+1i, TRUE), c(1:10, 1+1i, TRUE))) # the default
154
stopifnot(identical(cc(1:10, 1+1i, TRUE), c(1:10, 1+1i, TRUE))) # the default
152
 
155
 
153
stopifnot(identical(cc(), c())) # no arguments implies the default method
156
stopifnot(identical(cc(), c())) # no arguments implies the default method
154
 
157
 
155
setGeneric("numMax", function(...)standardGeneric("numMax"))
158
setGeneric("numMax", function(...)standardGeneric("numMax"))
156
 
159
 
157
setMethod("numMax", "numeric", function(...)max(...)) # won't work for complex data
160
setMethod("numMax", "numeric", function(...)max(...))
-
 
161
# won't work for complex data
158
setMethod("numMax", "Number", function(...) paste(...)) # should not be selected w/o complex args
162
setMethod("numMax", "Number", function(...) paste(...))
-
 
163
# should not be selected w/o complex args
159
 
164
 
160
stopifnot(identical(numMax(1:10, pi, 1+1i), paste(1:10, pi, 1+1i)))
165
stopifnot(identical(numMax(1:10, pi, 1+1i), paste(1:10, pi, 1+1i)))
161
stopifnot(identical(numMax(1:10, pi, 1), max(1:10, pi, 1)))
166
stopifnot(identical(numMax(1:10, pi, 1), max(1:10, pi, 1)))
162
 
167
 
163
try(numMax(1:10, pi, TRUE)) # should be an error:  no default method
168
try(numMax(1:10, pi, TRUE)) # should be an error:  no default method