The R Project SVN R

Rev

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

Rev 57841 Rev 59654
Line 229... Line 229...
229
 
229
 
230
## add a method to save the object
230
## add a method to save the object
231
mEditor$methods(
231
mEditor$methods(
232
     save = function(file) {
232
     save = function(file) {
233
       'Save the current object on the file
233
       'Save the current object on the file
234
        in R external object format.
234
 in R external object format.
235
       '
235
'
236
         base::save(.self, file = file)
236
         base::save(.self, file = file)
-
 
237
     },
-
 
238
     counter = function(i) {
-
 
239
         'The number of items in the i-th edit.
-
 
240
 (Used to test usingMethods())
-
 
241
'
-
 
242
         if(i > 0 && i <= length(edits))
-
 
243
             length(edits[[i]][[3]])
-
 
244
         else
-
 
245
             0L
237
     }
246
     }
238
)
247
)
239
 
248
 
240
tf <- tempfile()
249
tf <- tempfile()
241
xx$save(tf) #$
250
xx$save(tf) #$
Line 275... Line 284...
275
  finalize = function() {
284
  finalize = function() {
276
    dev.off(viewerDevice)
285
    dev.off(viewerDevice)
277
    setMarkViewer("OFF")
286
    setMarkViewer("OFF")
278
  })
287
  })
279
 
288
 
-
 
289
## a counts method to test usingMethods()
-
 
290
mv$methods( counts = function() {
-
 
291
    usingMethods("counter")
-
 
292
    sapply(seq_along(edits), "counter")
-
 
293
})
-
 
294
 
-
 
295
 
280
ff <- mv$new( data = xMat)
296
ff <- mv$new( data = xMat)
281
stopifnot(identical(markViewer, "ON")) # check initialize
297
stopifnot(identical(markViewer, "ON")) # check initialize
282
ff$edit(2,2,0)
298
ff$edit(2,2,0)
283
ff$data
299
ff$data
-
 
300
stopifnot(identical(ff$counts(), length(ff$edits[[1]][[3]])))
284
ff$undo()
301
ff$undo()
285
stopifnot(all.equal(ff$data, xMat))
302
stopifnot(all.equal(ff$data, xMat))
286
rm(ff)
303
rm(ff)
287
gc()
304
gc()
288
stopifnot(identical(markViewer, "OFF")) #check finalize
305
stopifnot(identical(markViewer, "OFF")) #check finalize