The R Project SVN R

Rev

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

Rev 53693 Rev 54575
Line 287... Line 287...
287
refClassB$methods(foo=function() paste(callSuper(), "Version 2"))
287
refClassB$methods(foo=function() paste(callSuper(), "Version 2"))
288
stopifnot(identical(refClassB$new()$foo(), "A Version 2"))
288
stopifnot(identical(refClassB$new()$foo(), "A Version 2"))
289
stopifnot(identical(mnames2, objects(getClass("refClassB")@refMethods)))
289
stopifnot(identical(mnames2, objects(getClass("refClassB")@refMethods)))
290
 
290
 
291
if(methods:::.hasCodeTools()) {
291
if(methods:::.hasCodeTools()) {
292
    ## code warnings assigning locally to, or hiding, field names
292
    ## code warnings assigning locally to field names
293
    stopifnot(is(tryCatch(mv$methods(test = function(x) {data <- x[!is.na(x)]; mean(data)}), warning = function(e)e), "warning"))
293
    stopifnot(is(tryCatch(mv$methods(test = function(x) {data <- x[!is.na(x)]; mean(data)}), warning = function(e)e), "warning"))
294
 
294
 
295
### formal arg test suppressed--see comment in .checkFieldsInMethod
295
    ## warnings for nonlocal assignment that is not a field
296
    ## stopifnot(is(tryCatch(mv$methods(test2 = function(data) {data[!is.na(x)]}), warning = function(e)e), "warning"))
296
    stopifnot(is(tryCatch(mv$methods(test2 = function(x) {something <<- data[!is.na(x)]}), warning = function(e)e), "warning"))
-
 
297
 
-
 
298
    ## error for trying to assign to a method name
-
 
299
    stopifnot(is(tryCatch(mv$methods(test3 = function(x) {edit <<- data[!is.na(x)]}), error = function(e)e), "error"))
297
} else
300
} else
298
    warning("Can't run some tests:  recommended package codetools is not available")
301
    warning("Can't run some tests:  recommended package codetools is not available")
299
 
302
 
300
## tests (fragmentary by necessity) of promptClass for reference class
303
## tests (fragmentary by necessity) of promptClass for reference class
301
ccon <- textConnection("ctxt", "w")
304
ccon <- textConnection("ctxt", "w")
Line 379... Line 382...
379
  )
382
  )
380
tt <- TestClass2$new("test", version = 1)
383
tt <- TestClass2$new("test", version = 1)
381
stopifnot(identical(tt$text, "test:"), identical(tt$version, as.integer(2)))
384
stopifnot(identical(tt$text, "test:"), identical(tt$version, as.integer(2)))
382
tt <- TestClass2$new(version=3) # default text
385
tt <- TestClass2$new(version=3) # default text
383
stopifnot(identical(tt$text, ":"), identical(tt$version, as.integer(4)))
386
stopifnot(identical(tt$text, ":"), identical(tt$version, as.integer(4)))
-
 
387
 
-
 
388