The R Project SVN R

Rev

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

Rev 53470 Rev 53564
Line 288... Line 288...
288
## and caused inf. recursion when the arguments to the [[<- case were changed in base.
288
## and caused inf. recursion when the arguments to the [[<- case were changed in base.
289
setClass("myEnv", contains = "environment")
289
setClass("myEnv", contains = "environment")
290
m <- new("myEnv")
290
m <- new("myEnv")
291
m[["x"]] <- 1; m$y <- 2
291
m[["x"]] <- 1; m$y <- 2
292
stopifnot(identical(c(m[["x"]], m$y), c(1,2)))
292
stopifnot(identical(c(m[["x"]], m$y), c(1,2)))
-
 
293
rm(x, envir = m)
-
 
294
stopifnot(identical(objects(m), "y"))
-
 
295
 
-
 
296
## tests of binding & environment tools with subclases of environment
-
 
297
lockBinding("y", m)
-
 
298
stopifnot(bindingIsLocked("y", m))
-
 
299
unlockBinding("y", m)
-
 
300
stopifnot(!bindingIsLocked("y", m))
-
 
301
 
-
 
302
makeActiveBinding("z", function(value) {
-
 
303
    if(missing(value))
-
 
304
        "dummy"
-
 
305
    else
-
 
306
        "dummy assignment"
-
 
307
}, m)
-
 
308
stopifnot(identical(get("z", m),"dummy"))
-
 
309
## assignment will return the value but do nothing
-
 
310
stopifnot(identical(assign("z","other", m), "other"),
-
 
311
          identical(get("z", m),"dummy"))
-
 
312
 
-
 
313
 
-
 
314
## this has to be last--Seems no way to unlock an environment!
-
 
315
lockEnvironment(m)
-
 
316
stopifnot(environmentIsLocked(m))
-
 
317
 
293
 
318
 
294
## test of callSuper() to a hidden default method for initialize() (== initFields)
319
## test of callSuper() to a hidden default method for initialize() (== initFields)
295
TestClass <- setRefClass ("TestClass",
320
TestClass <- setRefClass ("TestClass",
296
     fields = list (text = "character"),
321
     fields = list (text = "character"),
297
     methods = list(
322
     methods = list(