[rkward-cvs] SF.net SVN: rkward:[2614] trunk/rkward/tests

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Aug 20 11:14:37 UTC 2009


Revision: 2614
          http://rkward.svn.sourceforge.net/rkward/?rev=2614&view=rev
Author:   tfry
Date:     2009-08-20 11:14:36 +0000 (Thu, 20 Aug 2009)

Log Message:
-----------
More plugin tests (the import/export plugins should all be covered, now)

Modified Paths:
--------------
    trunk/rkward/tests/import_export_plugins.R
    trunk/rkward/tests/test_framework.R

Added Paths:
-----------
    trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkout
    trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.messages.txt
    trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkout
    trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkout
    trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkout
    trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkout

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkcommands.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,18 @@
+local({
+## Prepare
+## Compute
+source (file="source.R", local=TRUE, verbose=FALSE, print.eval=FALSE, chdir=FALSE)
+## Print result
+rk.header("Source R file", parameters=list("File", "source.R"))
+})
+.rk.rerun.plugin.link(plugin="rkward::load_source", settings="chdir.state=FALSE\necho.state=0\nfile.selection=source.R\nlocal.state=TRUE\nprinteval.state=FALSE", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+## Compute
+source (file="source.R", local=FALSE, echo=TRUE, max.deparse.length=150, verbose=FALSE, print.eval=FALSE, chdir=FALSE)
+## Print result
+rk.header("Source R file", parameters=list("File", "source.R"))
+})
+.rk.rerun.plugin.link(plugin="rkward::load_source", settings="chdir.state=FALSE\necho.state=1\nfile.selection=source.R\nlocal.state=FALSE\nmaxdeparselength.real=150.000000\nprinteval.state=FALSE\npromptecho.text=\nverbose.state=FALSE", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.load_source.rkout	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,20 @@
+<h1>Source R file</h1>
+<h2>Parameters</h2>
+<ul><li>File: source.R</li>
+</ul>
+DATE<br>
+<h2>Messages, warnings, or errors:</h2>
+<pre>[1] "ok"
+</pre>
+<h1>Source R file</h1>
+<h2>Parameters</h2>
+<ul><li>File: source.R</li>
+</ul>
+DATE<br>
+<h2>Messages, warnings, or errors:</h2>
+<pre>
+> testx <- c (20:30)
+
+> print ("ok")
+[1] "ok"
+</pre>

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.messages.txt
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.messages.txt	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.messages.txt	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,7 @@
+Creating directories ...
+Creating DESCRIPTION ...
+Creating Read-and-delete-me ...
+Saving functions and data ...
+Making help files ...
+Done.
+Further steps are described in './anRpackage/Read-and-delete-me'.

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkcommands.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,10 @@
+local({
+## Prepare
+## Compute
+package.skeleton(name="anRpackage", list=c('rktest.setSuiteStandards','rktest.runRKTestSuite'), path=".", force= TRUE)
+## Print result
+rk.header("Create package skeleton", parameters=list("Name", "anRpackage",
+	"Directory", "."))
+})
+.rk.rerun.plugin.link(plugin="rkward::save_skeleton", settings="data.available=rktest.setSuiteStandards\\nrktest.runRKTestSuite\nforce.state=TRUE\nname.text=anRpackage\npath.selection=.", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.package_skeleton.rkout	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,6 @@
+<h1>Create package skeleton</h1>
+<h2>Parameters</h2>
+<ul><li>Name: anRpackage</li>
+<li>Directory: .</li>
+</ul>
+DATE<br>

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkcommands.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,20 @@
+local({
+## Prepare
+## Compute
+save (testx, file="x.RData", ascii=TRUE, compress=TRUE)
+## Print result
+rk.header("Save R objects", parameters=list("File", "x.RData",
+	"Variables", "testx"))
+})
+.rk.rerun.plugin.link(plugin="rkward::save_r", settings="ascii.state=TRUE\ncompress.state=TRUE\ndata.available=testx\nfile.selection=x.RData", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+## Compute
+save (testy, file="y.RData", ascii=TRUE, compress=TRUE)
+## Print result
+rk.header("Save R objects", parameters=list("File", "y.RData",
+	"Variables", "testy"))
+})
+.rk.rerun.plugin.link(plugin="rkward::save_r", settings="ascii.state=TRUE\ncompress.state=TRUE\ndata.available=testy\nfile.selection=y.RData", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.save_r_object.rkout	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,12 @@
+<h1>Save R objects</h1>
+<h2>Parameters</h2>
+<ul><li>File: x.RData</li>
+<li>Variables: testx</li>
+</ul>
+DATE<br>
+<h1>Save R objects</h1>
+<h2>Parameters</h2>
+<ul><li>File: y.RData</li>
+<li>Variables: testy</li>
+</ul>
+DATE<br>

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkcommands.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,10 @@
+local({
+## Prepare
+## Compute
+write.table ( x =  as.environment ("package:datasets")$"women" , file =  "data" , append =  FALSE  ,quote = TRUE ,  sep = '\t' , eol = "\n" , na = "NA" ,  dec = '.' , row.names =  FALSE ,  col.names =  TRUE , qmethod=  'escape' ) 
+## Print result
+rk.header("Write as table", parameters=list("File", "data",
+	"Data", "as.environment (\"package:datasets\")$\"women\""))
+})
+.rk.rerun.plugin.link(plugin="rkward::save_table", settings="append.state=FALSE\ncolumns.string=TRUE\ndata.available=as.environment (\\\"package:datasets\\\")$\\\"women\\\"\ndec.string='.'\neol.text=\\\\n\nfile.selection=data\nna.text=NA\nqmethod.string='escape'\nquote.state=TRUE\nrows.string=FALSE\nsep.string='\\\\t'", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.write_table.rkout	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,7 @@
+<h1>Write as table</h1>
+<h2>Parameters</h2>
+<ul><li>File: data</li>
+<li>Data: as.environment ("package:datasets")$"women"</li>
+</ul>
+DATE<br>
+<p class='character'>"height"	"weight"</p><p class='character'>58	115</p><p class='character'>59	117</p><p class='character'>60	120</p><p class='character'>61	123</p><p class='character'>62	126</p><p class='character'>63	129</p><p class='character'>64	132</p><p class='character'>65	135</p><p class='character'>66	139</p><p class='character'>67	142</p><p class='character'>68	146</p><p class='character'>69	150</p><p class='character'>70	154</p><p class='character'>71	159</p><p class='character'>72	164</p>
\ No newline at end of file

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkcommands.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,10 @@
+local({
+## Prepare
+## Compute
+write (x=testx, file="data", ncolumns=2, append=FALSE, sep=",")
+## Print result
+rk.header("Write Variables", parameters=list("File", "data",
+	"Data", "testx"))
+})
+.rk.rerun.plugin.link(plugin="rkward::save_variables", settings="append.state=FALSE\ndata.available=testx\nfile.selection=data\nncolumns.real=2.000000\nsep.string=,", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.write_vector_matrix.rkout	2009-08-20 11:14:36 UTC (rev 2614)
@@ -0,0 +1,7 @@
+<h1>Write Variables</h1>
+<h2>Parameters</h2>
+<ul><li>File: data</li>
+<li>Data: testx</li>
+</ul>
+DATE<br>
+<p class='character'>1,2</p><p class='character'>3,4</p><p class='character'>5,6</p><p class='character'>7,8</p><p class='character'>9,10</p>
\ No newline at end of file

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2009-08-19 13:12:19 UTC (rev 2613)
+++ trunk/rkward/tests/import_export_plugins.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -59,7 +59,53 @@
 
 			# WARNING: TODO: We don't use the value labels of the third
 			# variable, yet.
-		}, libraries=c("foreign"))
+		}, libraries=c("foreign")),
+		new ("RKTest", id="load_source", call=function () {
+			stopifnot (!exists ("testx", globalenv ()))
+
+			cat ("testx <- c (20:30)\nprint (\"ok\")\n", file="source.R")
+
+			rk.call.plugin ("rkward::load_source", chdir.state="FALSE", echo.state="0", file.selection="source.R", local.state="TRUE", printeval.state="FALSE", submit.mode="submit")
+
+			stopifnot (!exists ("testx", globalenv ()))
+
+			rk.call.plugin ("rkward::load_source", chdir.state="FALSE", echo.state="1", file.selection="source.R", local.state="FALSE", printeval.state="FALSE", submit.mode="submit")
+
+			stopifnot (globalenv()$testx == c (20:30))
+		}),
+		new ("RKTest", id="save_r_object", call=function () {
+			# in this test we try to save to object with different settings, then reload them.
+			assign ("testx", datasets::warpbreaks, envir=globalenv())
+			assign ("testy", datasets::volcano, envir=globalenv())
+			rk.sync.global()
+
+			rk.call.plugin ("rkward::save_r", ascii.state="TRUE", compress.state="TRUE", data.available="testx", file.selection="x.RData", submit.mode="submit")
+			rk.call.plugin ("rkward::save_r", ascii.state="TRUE", compress.state="TRUE", data.available="testy", file.selection="y.RData", submit.mode="submit")
+
+			rm (testx, testy, envir=globalenv())
+			load ("x.RData")
+			stopifnot (testx == datasets::warpbreaks)
+			load ("y.RData")
+			stopifnot (testy == datasets::volcano)
+		}),
+		new ("RKTest", id="write_vector_matrix", call=function () {
+			assign ("testx", c (1:10), globalenv())
+			rk.sync.global()
+
+			rk.call.plugin ("rkward::save_variables", append.state="FALSE", data.available="testx", file.selection="data", ncolumns.real="2.000000", sep.string=",", submit.mode="submit")
+
+			x <- readLines ("data")
+			for (line in x) rk.print (line)
+		}),
+		new ("RKTest", id="write_table", call=function () {
+			rk.call.plugin ("rkward::save_table", append.state="FALSE", columns.string="TRUE", data.available="women", dec.string="'.'", eol.text="\\n", file.selection="data", na.text="NA", qmethod.string="'escape'", quote.state="TRUE", rows.string="FALSE", sep.string="'\\t'", submit.mode="submit")
+
+			x <- readLines ("data")
+			for (line in x) rk.print (line)
+		}),
+		new ("RKTest", id="package_skeleton", call=function () {
+			rk.call.plugin ("rkward::save_skeleton", data.available="rktest.setSuiteStandards\nrktest.runRKTestSuite", force.state="TRUE", name.text="anRpackage", path.selection=".", submit.mode="submit")
+		})
 	), postCalls = list ()	# like initCalls: run after all tests to clean up. Empty in this case.
 )
 

Modified: trunk/rkward/tests/test_framework.R
===================================================================
--- trunk/rkward/tests/test_framework.R	2009-08-19 13:12:19 UTC (rev 2613)
+++ trunk/rkward/tests/test_framework.R	2009-08-20 11:14:36 UTC (rev 2614)
@@ -195,7 +195,7 @@
 	# do not delete the standards!
 	files <- grep ("^RKTestStandard\\..*\\.(messages.txt|rkcommands.R|rkout)$", files, value=TRUE, invert=TRUE)
 
-	file.remove (files)
+	unlink (files)
 
 	invisible (NULL)
 }
@@ -263,6 +263,8 @@
 	.rk.cat.output (gsub ("^\"", "", gsub ("=", "=\"", gsub ("\n", "\", ", settings))))
 	.rk.cat.output ("\", submit.mode=\"submit\")</pre>")
 }
+# Run this line to do the replacement:
+# .rk.rerun.plugin.link <- .rk.rerun.plugin.link.replacement
 
 ## Initialize test environment
 # By default .rk.rerun.plugin.link() and .rk.make.hr() are silenced during the test runs


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list