| Line 1... |
Line -... |
| 1 |
options(error = recover)
|
- |
|
| 2 |
## simple call, only field names
|
1 |
## simple call, only field names
|
| 3 |
fg <- setRefClass("foo", c("bar", "flag"))
|
2 |
fg <- setRefClass("foo", c("bar", "flag"))
|
| 4 |
f1<- new("foo")
|
3 |
f1<- new("foo")
|
| 5 |
f1$bar
|
4 |
f1$bar
|
| 6 |
f1 <- fg$new(flag = "testing")
|
5 |
f1 <- fg$new(flag = "testing")
|
| Line 261... |
Line 260... |
| 261 |
identical(v2$text, "Hello, world"))
|
260 |
identical(v2$text, "Hello, world"))
|
| 262 |
v3 <- v1$copy(TRUE)
|
261 |
v3 <- v1$copy(TRUE)
|
| 263 |
v3$viewer$data <- t(xMat) # should modify v1$viewer as well
|
262 |
v3$viewer$data <- t(xMat) # should modify v1$viewer as well
|
| 264 |
stopifnot(identical(v1$viewer$data, t(xMat)))
|
263 |
stopifnot(identical(v1$viewer$data, t(xMat)))
|
| 265 |
|
264 |
|
| - |
|
265 |
## the field() method
|
| - |
|
266 |
stopifnot(identical(v1$text, v1$field("text")))
|
| - |
|
267 |
v1$field("text", "Now is the time")
|
| - |
|
268 |
stopifnot(identical(v1$field("text"), "Now is the time"))
|
| - |
|
269 |
|
| - |
|
270 |
## setting a non-existent field, or a method, should throw an error
|
| - |
|
271 |
stopifnot(is(tryCatch(v1$field("foobar", 0), error = function(e)e), "error"),
|
| - |
|
272 |
is(tryCatch(v1$field("copy", 0), error = function(e)e), "error") )
|
| - |
|
273 |
|
| 266 |
## the methods to extract class definition and generator
|
274 |
## the methods to extract class definition and generator
|
| 267 |
## stopifnot(identical(v3$getRefClass(), mv),
|
275 |
stopifnot(identical(v3$getRefClass()$def, getRefClass("viewerPlus")$def),
|
| 268 |
## identical(v3$getClass(), getClass("viewerPlus")))
|
276 |
identical(v3$getClass(), getClass("viewerPlus")))
|
| 269 |
|
277 |
|
| 270 |
## deal correctly with inherited methods and overriding existing
|
278 |
## deal correctly with inherited methods and overriding existing
|
| 271 |
## methods from $methods(...)
|
279 |
## methods from $methods(...)
|
| 272 |
refClassA <- setRefClass("refClassA", methods=list(foo=function() "A"))
|
280 |
refClassA <- setRefClass("refClassA", methods=list(foo=function() "A"))
|
| 273 |
refClassB <- setRefClass("refClassB", contains="refClassA")
|
281 |
refClassB <- setRefClass("refClassB", contains="refClassA")
|