HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Program Files/R/R-4.4.0/library/methods/tests/namesAndSlots.R
setClass("B", contains = "numeric")
xx <- new("B", 1)
names(xx) <- "A"
stopifnot(identical(names(xx), "A"))
setClass("A", representation(xx = "numeric"))
a <- new("A", xx = 1)
stopifnot(is(tryCatch(names(a) <- "A" , error = function(e)e), "error"))
setClass("C", representation(xx = "numeric", names= "character"))
c <- new("C", xx = 1, names = "A")
c@names <- "B"
stopifnot(is(tryCatch(names(c) <- "A" , error = function(e)e), "error"))
setClass("D", contains = "numeric", representation(names = "character"))
d <- new("D", 1)
names(d) <- "A"
stopifnot(identical(d@names, "A"))
## test the checks on @<- primitive assignment
stopifnot(is(tryCatch(a@yy <- 1 , error = function(e)e), "error"))
stopifnot(is(tryCatch(a@xx <- "A" , error = function(e)e), "error"))