[R] tests Rin Rout
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Mar 30 19:42:19 CEST 2008
On 30/03/2008 10:44 AM, Christophe Genolini wrote:
> Hi the list,
>
> Some rumour (!) say that is it possible to prepare some tests for
> checking our code using .Rin and .Rout. It seems to be a very good
> practice, but I did not manage to find information on it.
> So does someone know how it works ? What are we suppose to write in Rin ?
See the paragraph in Writing R Extensions which explains this, near the
end of the section on Package Subdirectories (section 1.1.3 in the
version I'm looking at).
Rin would be fairly rarely needed: it is supposed to write a script to
perform the tests. Normally you write your script directly, in a .R file.
>
> More precisely :
> - I have a package myPack.r in directories ~/myR/myPack/R/
> - I create the directory ~/myR/myPack/tests
>
> myPack.r is :
>
> `f1` <- function(x){cat("\nXXX F1 = ",x,"XXX\n")}
> `f2` <- function(x){cat("\nXXX F2 = ",f1(x^2),"XXX\n")}
>
> What am I suppose to do to test it? Create myPack.Rin, but what in it?
Create tests/myPack.R with those lines in it plus lines to actually run
the code. If the code generates errors, your test will fail. If you
want to see reports of changes to the output, also include
tests/myPack.Rout.save with the known correct versions of the output.
Duncan Murdoch
>
> Thanks for your help.
>
> Christophe
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list