SCM

SCM Repository

[inlinedocs] Diff of /pkg/inlinedocs/R/test.R
ViewVC logotype

Diff of /pkg/inlinedocs/R/test.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 112, Mon Jun 7 12:35:44 2010 UTC revision 113, Fri Jun 18 09:40:30 2010 UTC
# Line 6  Line 6 
6  ### extract.docs.file to the file. We check for identity of elements  ### extract.docs.file to the file. We check for identity of elements
7  ### of elements of the list, so the order of elements should not  ### of elements of the list, so the order of elements should not
8  ### matter, and thus this should be a good robust unit test.  ### matter, and thus this should be a good robust unit test.
9  (f  (f,
10  ### File name of R code file with inlinedocs to parse and check.  ### File name of R code file with inlinedocs to parse and check.
11     verbose=TRUE
12    ### Show output?
13   ){   ){
14    result <- extract.docs.file(f)    result <- extract.docs.file(f)
15    e <- new.env()    e <- new.env()
16    sys.source(f,e)    sys.source(f,e)
17    ## these are the items to check for, in no particular order    ## these are the items to check for, in no particular order
18    .result <- e$.result    .result <- e$.result
19    for(FUN in names(.result))for(N in names(.result[[FUN]])){    for(FUN in names(.result)){
20        if(verbose)cat(FUN,"")
21        for(N in names(.result[[FUN]])){
22      .res <- .result[[FUN]][[N]]      .res <- .result[[FUN]][[N]]
23      res <- result[[FUN]][[N]]      res <- result[[FUN]][[N]]
24      if(is.null(res) || .res!=res){      if(is.null(res) || .res!=res){
# Line 22  Line 26 
26      }      }
27    }    }
28  }  }
29      if(verbose)cat("\n")
30    }
31  save.test.result <- function  save.test.result <- function
32  ### For unit tests, this is an easy way of getting a text  ### For unit tests, this is an easy way of getting a text
33  ### representation of the list result of extract.docs.file.  ### representation of the list result of extract.docs.file.
34  (f  (f
35  ### R code file with inlinedocs to process with extract.docs.file.  ### R code file with inlinedocs to process with extract.docs.file.
36   ){   ){
37    L <- extract.docs.file(f)    .result <- extract.docs.file(f)
38    dump("L",control=NULL)    dump(".result",control=NULL)
39    lines <- readLines("dumpdata.R")    lines <- readLines("dumpdata.R")
40    cat(lines)    cat(paste(lines,"\n"))
41  }  }

Legend:
Removed from v.112  
changed lines
  Added in v.113

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge