[rkward-cvs] [rkward] packages/rkwarddev: adding unit tests, first round (not working yet, but already fixing some issues brought up by R CMD check)

m.eik michalke meik.michalke at uni-duesseldorf.de
Fri Dec 12 22:19:03 UTC 2014


Git commit 0e06c6d7417226edc1f0c7c6c414d86f6f4eec33 by m.eik michalke.
Committed on 12/12/2014 at 22:17.
Pushed by meikm into branch 'master'.

adding unit tests, first round (not working yet, but already fixing some issues brought up by R CMD check)

A  +3    -0    packages/rkwarddev/.Rinstignore
M  +2    -1    packages/rkwarddev/ChangeLog
M  +1    -1    packages/rkwarddev/DESCRIPTION
M  +6    -1    packages/rkwarddev/R/rk-internal.R
M  +7    -32   packages/rkwarddev/R/rk.XML.about.R
M  +1    -1    packages/rkwarddev/R/rk.XML.component.R
M  +1    -1    packages/rkwarddev/R/rk.XML.external.R
M  +2    -0    packages/rkwarddev/R/rk.XML.pluginmap.R
M  +0    -2    packages/rkwarddev/R/rk.XML.values.R
M  +2    -2    packages/rkwarddev/R/rk.XML.valueslot.R
M  +2    -0    packages/rkwarddev/R/rk.i18n.comment.R
M  +1    -1    packages/rkwarddev/R/rkwarddev-package.R
A  +-    --    packages/rkwarddev/inst/tests/about_XML_standard.Rdata
A  +36   -0    packages/rkwarddev/inst/tests/test_XML_generation.R
M  +1    -1    packages/rkwarddev/man/rk.XML.component.Rd
M  +1    -1    packages/rkwarddev/man/rk.XML.external.Rd
M  +4    -0    packages/rkwarddev/man/rk.XML.pluginmap.Rd
M  +3    -0    packages/rkwarddev/man/rk.i18n.comment.Rd
M  +1    -1    packages/rkwarddev/man/rkwarddev-package.Rd
A  +5    -0    packages/rkwarddev/tests/test_rkwarddev_package.R

http://commits.kde.org/rkward/0e06c6d7417226edc1f0c7c6c414d86f6f4eec33

diff --git a/packages/rkwarddev/.Rinstignore b/packages/rkwarddev/.Rinstignore
new file mode 100644
index 0000000..56d8512
--- /dev/null
+++ b/packages/rkwarddev/.Rinstignore
@@ -0,0 +1,3 @@
+RKWard_vign_example_dialog_wcode.png
+RKWard_vign_example_dialog_wcode_JS.png
+
diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index 40f489d..3a9769c 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -1,6 +1,6 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.06-6 (2014-12-04)
+changes in version 0.06-6 (2014-12-12)
 fixed:
   - rk.XML.optionset() does now allow to re-use objects defined in the same
     function call (i.e., refer to optioncolumns in the logic section)
@@ -24,6 +24,7 @@ added:
   - rk.JS.doc(), rk.plugin.skeleton() and rk.plugin.component() now use rk.JS.header() instead of
     rk.header(), and also accept its "header.add" attribute
   - new function R.comment() to generate JavaScript "comment()" calls
+  - first unit tests using the testthat package
 changed:
   - function i18n() was changed to be used in JavaScript generation only; this breaks code
     using the function introduced with 0.06-4, but that was to be shortlived from the start...
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index 0155aa4..6b6acd8 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -15,7 +15,7 @@ URL: http://rkward.sourceforge.net
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.06-6
-Date: 2014-12-04
+Date: 2014-12-12
 Collate:
     '00_class_01_rk.JS.arr.R'
     '00_class_02_rk.JS.var.R'
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 5350428..c29d7e7 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -1187,6 +1187,11 @@ rk.check.options <- function(options, parent){
         valid.child(parent, children=options[[this.num]])
         return(options[[this.num]])
       } else {
+        if("val" %in% names(options[[this.num]])){
+          value <- options[[this.num]][["val"]]
+        } else {
+          value <- NULL
+        }
         if("chk" %in% names(options[[this.num]])){
           checked <- isTRUE(as.logical(options[[this.num]][["chk"]]))
         } else {
@@ -1200,7 +1205,7 @@ rk.check.options <- function(options, parent){
         return(
           rk.XML.option(
             label=names(options)[[this.num]],
-            val=options[[this.num]][["val"]],
+            val=value,
             chk=checked,
             id.name=NULL,
             i18n=i18n
diff --git a/packages/rkwarddev/R/rk.XML.about.R b/packages/rkwarddev/R/rk.XML.about.R
index df88853..f9af9b2 100644
--- a/packages/rkwarddev/R/rk.XML.about.R
+++ b/packages/rkwarddev/R/rk.XML.about.R
@@ -37,27 +37,13 @@
 #'      \item{category}{A category for this plugin (optional)}
 #'      \item{long.desc}{A long description (optional, defaults to \code{desc})}
 #'    }
-#' @param dependencies A named list with these elements:
-#'    \describe{
-#'      \item{rkward.min}{Minimum RKWard version needed for this plugin (optional)}
-#'      \item{rkward.max}{Maximum RKWard version needed for this plugin (optional)}
-#'      \item{R.min}{Minimum R version needed for this plugin (optional)}
-#'      \item{R.max}{Maximum R version needed for this plugin (optional)}
-#'    }
-#' @param package A list of named character vectors, each with these elements:
-#'    \describe{
-#'      \item{name}{Name of a package this plugin depends on (optional)}
-#'      \item{min}{Minimum version of the package (optional)}
-#'      \item{max}{Maximum version of the package (optional)}
-#'      \item{repository}{Repository to download the package (optional)}
-#'    }
-#' @param pluginmap A named list with these elements:
-#'    \describe{
-#'      \item{name}{Identifier of a pluginmap this plugin depends on (optional)}
-#'      \item{url}{URL to get the pluginmap (optional)}
-#'    }
+#' @param dependencies Deprecated, use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.
+#' @param package Deprecated, use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.
+#' @param pluginmap Deprecated, use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.
 #' @export
-#' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+#' @seealso
+#'    \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}},
+#'    \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @examples
 #' about.node <- rk.XML.about(
 #'   name="Square the circle",
@@ -73,18 +59,7 @@
 #'     date=Sys.Date(),
 #'     url="http://eternalwondermaths.example.org/23/stc.html",
 #'     license="GPL",
-#'     category="Geometry"),
-#'   dependencies=list(
-#'     rkward.min="0.5.3",
-#'     rkward.max="",
-#'     R.min="2.10",
-#'     R.max=""),
-#'   package=list(
-#'     c(name="heisenberg", min="0.11-2", max="",
-#'       repository="http://rforge.r-project.org"),
-#'     c(name="DreamsOfPi", min="0.2", max="", repository="")),
-#'   pluginmap=list(
-#'     c(name="heisenberg.pluginmap", url="http://eternalwondermaths.example.org/hsb"))
+#'     category="Geometry")
 #' )
 #' 
 #' cat(pasteXML(about.node, shine=2))
diff --git a/packages/rkwarddev/R/rk.XML.component.R b/packages/rkwarddev/R/rk.XML.component.R
index 8f83893..f9ad4ad 100644
--- a/packages/rkwarddev/R/rk.XML.component.R
+++ b/packages/rkwarddev/R/rk.XML.component.R
@@ -27,7 +27,7 @@
 #' @param type Character string, type of component. As of now, only "standard" is supported. The option is
 #'    just implemented for completeness.
 #' @param dependencies An object of class \code{XiMpLe.node} to define \code{<dependencies>} for this component.
-#'    See \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.
+#'    See \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.
 #' @param i18n Either a character string or a named list with the optional element \code{context},
 #'    to give some \code{i18n_context}
 #'    information for this node. If set to \code{FALSE}, the attribute \code{label} will be renamed into 
diff --git a/packages/rkwarddev/R/rk.XML.external.R b/packages/rkwarddev/R/rk.XML.external.R
index 807882d..a578b72 100644
--- a/packages/rkwarddev/R/rk.XML.external.R
+++ b/packages/rkwarddev/R/rk.XML.external.R
@@ -24,7 +24,7 @@
 #' @export
 #' @seealso
 #'    \code{\link[rkwarddev:rk.XML.connect]{rk.XML.connect}},
-#'    \code{\link[rkwarddev:rk.XML.covert]{rk.XML.convert}},
+#'    \code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}},
 #'    \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}},
 #'    \code{\link[rkwarddev:rk.XML.set]{rk.XML.set}},
 #'    \code{\link[rkwarddev:rk.XML.switch]{rk.XML.switch}},
diff --git a/packages/rkwarddev/R/rk.XML.pluginmap.R b/packages/rkwarddev/R/rk.XML.pluginmap.R
index 01a8196..c8ac9fc 100644
--- a/packages/rkwarddev/R/rk.XML.pluginmap.R
+++ b/packages/rkwarddev/R/rk.XML.pluginmap.R
@@ -48,6 +48,8 @@
 #' @param namespace Character string, the namespace attribute of the \code{<document>} node, defaults to the plugin name (which you probably shouldn't touch...)
 #' @param priority Character string, the priority attribute of the \code{<document>} node. Must be either "hidden", "low", "medium", or "high",
 #'    defaults to "medium".
+#' @param id.name Character string, a unique ID for this plugin element.
+#'    If \code{"auto"} and a label was provided, an ID will be generated automatically from the label.
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
diff --git a/packages/rkwarddev/R/rk.XML.values.R b/packages/rkwarddev/R/rk.XML.values.R
index cfac1ec..d50adbb 100644
--- a/packages/rkwarddev/R/rk.XML.values.R
+++ b/packages/rkwarddev/R/rk.XML.values.R
@@ -68,8 +68,6 @@ rk.XML.values <- function(label, slot.text, required=FALSE, multi=FALSE, min=1,
     value.slot.id <- id.name[[3]]
   } else {}
 
-  value.sel.attr[["label"]] <- label
-
   v.selector <- rk.XML.valueselector(
     label=label,
     id.name=value.sel.attr[["id"]])
diff --git a/packages/rkwarddev/R/rk.XML.valueslot.R b/packages/rkwarddev/R/rk.XML.valueslot.R
index 788fd87..98bea33 100644
--- a/packages/rkwarddev/R/rk.XML.valueslot.R
+++ b/packages/rkwarddev/R/rk.XML.valueslot.R
@@ -70,11 +70,11 @@ rk.XML.valueslot <- function(label, source, property=NULL, required=FALSE, multi
 
   if(is.XiMpLe.node(source)){
     source.name <- slot(source, "name")
-    if(identical(source.name, "varselector")){
+    if(identical(source.name, "valueselector")){
       value.slot.attr[["source"]] <- check.ID(source)
     } else {
       if(is.null(property)){
-        stop(simpleError(paste0("'source' must either be a <varselector> node or come with an appropripate 'property' value!")))
+        stop(simpleError(paste0("'source' must either be a <valueselector> node or come with an appropripate 'property' value!")))
       } else if(modif.validity(source, modifier=property)){
         value.slot.attr[["source_property"]] <- paste(check.ID(source), property, sep=".")
       } else {}
diff --git a/packages/rkwarddev/R/rk.i18n.comment.R b/packages/rkwarddev/R/rk.i18n.comment.R
index b9368b4..7b16e0a 100644
--- a/packages/rkwarddev/R/rk.i18n.comment.R
+++ b/packages/rkwarddev/R/rk.i18n.comment.R
@@ -22,6 +22,8 @@
 #' keyword \code{"i18n:"} to give context to translators.
 #'
 #' @param text Character string, the text to be displayed.
+#' @param prefix Character string, the text to be prefixed to indicate this is
+#'    an i18n comment.
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
 #' @examples
diff --git a/packages/rkwarddev/R/rkwarddev-package.R b/packages/rkwarddev/R/rkwarddev-package.R
index 4b85d2d..dc322c0 100644
--- a/packages/rkwarddev/R/rkwarddev-package.R
+++ b/packages/rkwarddev/R/rkwarddev-package.R
@@ -4,7 +4,7 @@
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
 #' Version: \tab 0.06-6\cr
-#' Date: \tab 2014-12-04\cr
+#' Date: \tab 2014-12-12\cr
 #' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr
diff --git a/packages/rkwarddev/inst/tests/about_XML_standard.Rdata b/packages/rkwarddev/inst/tests/about_XML_standard.Rdata
new file mode 100644
index 0000000..0f811fe
Binary files /dev/null and b/packages/rkwarddev/inst/tests/about_XML_standard.Rdata differ
diff --git a/packages/rkwarddev/inst/tests/test_XML_generation.R b/packages/rkwarddev/inst/tests/test_XML_generation.R
new file mode 100644
index 0000000..2c1901f
--- /dev/null
+++ b/packages/rkwarddev/inst/tests/test_XML_generation.R
@@ -0,0 +1,36 @@
+# testing basic tokenizing and POS tagging
+
+context("XML")
+
+test_that("about", {
+  load("about_XML_standard.RData")
+
+  thisNode <- rk.XML.about(
+    name="Square the circle",
+    author=c(
+      person(given="E.A.", family="Dölle",
+        email="doelle at eternalwondermaths.example.org", role="aut"),
+      person(given="A.", family="Assistant",
+        email="alterego at eternalwondermaths.example.org", role=c("cre","ctb"))
+      ),
+    about=list(
+      desc="Squares the circle using Heisenberg compensation.",
+      version="0.1-3",
+      date=Sys.Date(),
+      url="http://eternalwondermaths.example.org/23/stc.html",
+      license="GPL",
+      category="Geometry")
+  )
+
+  expect_that(thisNode,
+    equals(thisNodeStandard))
+})
+
+# test_that("", {
+#   thisNodeStandard <- dget("_XML_dput.txt")
+# 
+#   thisNode <- rk.XML.()
+# 
+#   expect_that(thisNode,
+#     equals(thisNodeStandard))
+# })
diff --git a/packages/rkwarddev/man/rk.XML.component.Rd b/packages/rkwarddev/man/rk.XML.component.Rd
index 9bf911e..f4209fe 100644
--- a/packages/rkwarddev/man/rk.XML.component.Rd
+++ b/packages/rkwarddev/man/rk.XML.component.Rd
@@ -19,7 +19,7 @@ If \code{"auto"}, an ID will be generated automatically from the label.}
 just implemented for completeness.}
 
 \item{dependencies}{An object of class \code{XiMpLe.node} to define \code{<dependencies>} for this component.
-See \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.}
+See \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.}
 
 \item{i18n}{Either a character string or a named list with the optional element \code{context},
 to give some \code{i18n_context}
diff --git a/packages/rkwarddev/man/rk.XML.external.Rd b/packages/rkwarddev/man/rk.XML.external.Rd
index 7577b1c..3f10e93 100644
--- a/packages/rkwarddev/man/rk.XML.external.Rd
+++ b/packages/rkwarddev/man/rk.XML.external.Rd
@@ -22,7 +22,7 @@ cat(pasteXML(test.external))
 }
 \seealso{
 \code{\link[rkwarddev:rk.XML.connect]{rk.XML.connect}},
-   \code{\link[rkwarddev:rk.XML.covert]{rk.XML.convert}},
+   \code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}},
    \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}},
    \code{\link[rkwarddev:rk.XML.set]{rk.XML.set}},
    \code{\link[rkwarddev:rk.XML.switch]{rk.XML.switch}},
diff --git a/packages/rkwarddev/man/rk.XML.pluginmap.Rd b/packages/rkwarddev/man/rk.XML.pluginmap.Rd
index ba63e45..cbca01e 100644
--- a/packages/rkwarddev/man/rk.XML.pluginmap.Rd
+++ b/packages/rkwarddev/man/rk.XML.pluginmap.Rd
@@ -63,6 +63,10 @@ See \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} for details
 \item{priority}{Character string,
       the priority attribute of the \code{<document>} node. Must be either "hidden", "low", "medium", or "high",
 defaults to "medium".}
+
+\item{id.name}{Character string, a unique ID for this plugin element.
+If \code{"auto"} and a label was provided,
+      an ID will be generated automatically from the label.}
 }
 \value{
 An object of class \code{XiMpLe.node}.
diff --git a/packages/rkwarddev/man/rk.i18n.comment.Rd b/packages/rkwarddev/man/rk.i18n.comment.Rd
index 68cc140..89b4d07 100644
--- a/packages/rkwarddev/man/rk.i18n.comment.Rd
+++ b/packages/rkwarddev/man/rk.i18n.comment.Rd
@@ -7,6 +7,9 @@ rk.i18n.comment(text, prefix = "i18n:")
 }
 \arguments{
 \item{text}{Character string, the text to be displayed.}
+
+\item{prefix}{Character string, the text to be prefixed to indicate this is
+an i18n comment.}
 }
 \value{
 An object of class \code{XiMpLe.node}.
diff --git a/packages/rkwarddev/man/rkwarddev-package.Rd b/packages/rkwarddev/man/rkwarddev-package.Rd
index fcd7392..bc14375 100644
--- a/packages/rkwarddev/man/rkwarddev-package.Rd
+++ b/packages/rkwarddev/man/rkwarddev-package.Rd
@@ -11,7 +11,7 @@ A collection of tools for RKWard plugin development.
 Package: \tab rkwarddev\cr
 Type: \tab Package\cr
 Version: \tab 0.06-6\cr
-Date: \tab 2014-12-04\cr
+Date: \tab 2014-12-12\cr
 Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 Enhances: \tab rkward\cr
 Encoding: \tab UTF-8\cr
diff --git a/packages/rkwarddev/tests/test_rkwarddev_package.R b/packages/rkwarddev/tests/test_rkwarddev_package.R
new file mode 100644
index 0000000..73ee73a
--- /dev/null
+++ b/packages/rkwarddev/tests/test_rkwarddev_package.R
@@ -0,0 +1,5 @@
+# the tests are realized using the "testthat" package
+# and can be found in ../inst/tests
+
+require(testthat)
+test_package("rkwarddev")





More information about the rkward-tracker mailing list