The R Project SVN R

Rev

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

Rev 53564 Rev 53641
Line 285... Line 285...
285
 
285
 
286
 
286
 
287
## tests of [[<- and $<- for subclasses of environment.  At one point methods for these assignments were defined
287
## tests of [[<- and $<- for subclasses of environment.  At one point methods for these assignments were defined
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", a="test")
-
 
291
m2 <- new("myEnv"); m3 <- new("myEnv")
-
 
292
## test that new.env() is called for each new object
-
 
293
stopifnot(!identical(as.environment(m), as.environment(m2)),
-
 
294
          !identical(as.environment(m3), as.environment(m2)))
291
m[["x"]] <- 1; m$y <- 2
295
m[["x"]] <- 1; m$y <- 2
292
stopifnot(identical(c(m[["x"]], m$y), c(1,2)))
296
stopifnot(identical(c(m[["x"]], m$y), c(1,2)))
293
rm(x, envir = m)
297
rm(x, envir = m) # check rm() works, does not clobber class
294
stopifnot(identical(objects(m), "y"))
298
stopifnot(identical(sort(objects(m)), sort(c("a", "y"))),
-
 
299
          is(m, "myEnv"))
295
 
300
 
296
## tests of binding & environment tools with subclases of environment
301
## tests of binding & environment tools with subclases of environment
297
lockBinding("y", m)
302
lockBinding("y", m)
298
stopifnot(bindingIsLocked("y", m))
303
stopifnot(bindingIsLocked("y", m))
299
unlockBinding("y", m)
304
unlockBinding("y", m)