The R Project SVN R

Rev

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

Rev 54575 Rev 55779
Line 116... Line 116...
116
setOldClass(c("simple.list", "list"))
116
setOldClass(c("simple.list", "list"))
117
fg4 <- setRefClass("foo4",
117
fg4 <- setRefClass("foo4",
118
            contains = "foo2",
118
            contains = "foo2",
119
            methods = list(
119
            methods = list(
120
              initialize = function(...) {
120
              initialize = function(...) {
121
                  .self <- initFields(...)
121
                  .self$initFields(...)
122
                  .self@made = R.version
122
                  .self@made <<- R.version
123
                  .self
123
                  .self
124
              }),
124
              }),
125
            representation = list(made = "simple.list")
125
            representation = list(made = "simple.list")
126
            )
126
            )
127
 
127
 
Line 384... Line 384...
384
stopifnot(identical(tt$text, "test:"), identical(tt$version, as.integer(2)))
384
stopifnot(identical(tt$text, "test:"), identical(tt$version, as.integer(2)))
385
tt <- TestClass2$new(version=3) # default text
385
tt <- TestClass2$new(version=3) # default text
386
stopifnot(identical(tt$text, ":"), identical(tt$version, as.integer(4)))
386
stopifnot(identical(tt$text, ":"), identical(tt$version, as.integer(4)))
387
 
387
 
388
 
388
 
-
 
389
## test some capabilities but read-only for .self
-
 
390
.changeAllFields <- function(replacement) {
-
 
391
    fields <- names(.refClassDef@fieldClasses)
-
 
392
    for(field in fields)
-
 
393
        eval(substitute(.self$FIELD <- replacement$FIELD,
-
 
394
                        list(FIELD = field)))
-
 
395
}
-
 
396
 
-
 
397
mEditor$methods(change = .changeAllFields)
-
 
398
xx <- mEditor$new(data = xMat)
-
 
399
xx$edit(2, 2, 0)
-
 
400
 
-
 
401
yy <- mEditor$new(data = xMat+1)
-
 
402
yy$change(xx)
-
 
403
stopifnot(identical(yy$data, xx$data), identical(yy$edits, xx$edits))
-
 
404
 
-
 
405
## but don't allow assigment
-
 
406
if(methods:::.hasCodeTools())
-
 
407
        stopifnot(is(tryCatch(yy$.self$data <- xMat, error = function(e)e), "error"))