[rkward-cvs] [rkward] packages/rkwarddev: unit tests, round two -- first tests are working.

m.eik michalke meik.michalke at uni-duesseldorf.de
Sat Dec 13 15:59:44 UTC 2014


Git commit 0237f98faa2f4297e3e1ee186bfb8a33d9bfe2de by m.eik michalke.
Committed on 13/12/2014 at 15:57.
Pushed by meikm into branch 'master'.

unit tests, round two -- first tests are working.

M  +38   -24   packages/rkwarddev/ChangeLog
M  +3    -1    packages/rkwarddev/DESCRIPTION
M  +9    -4    packages/rkwarddev/R/rk.XML.connect.R
M  +1    -1    packages/rkwarddev/R/rkwarddev-package.R
A  +-    --    packages/rkwarddev/inst/tests/XML_test_standards.RData
D  +-    --    packages/rkwarddev/inst/tests/about_XML_standard.Rdata
M  +123  -10   packages/rkwarddev/inst/tests/test_XML_generation.R
M  +9    -32   packages/rkwarddev/man/rk.XML.about.Rd
M  +1    -1    packages/rkwarddev/man/rkwarddev-package.Rd
A  +128  -0    packages/rkwarddev/tests/generate_test_standards.R

http://commits.kde.org/rkward/0237f98faa2f4297e3e1ee186bfb8a33d9bfe2de

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index 3a9769c..c9c01d9 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -1,43 +1,57 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.06-6 (2014-12-12)
+changes in version 0.06-6 (2014-12-13)
 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)
-  - removed arguments "help" and "component" from rk.XML.optionscolumn() again,
-    as these are already being documented via the objects they connect to.
-  - rk.build.plugin() was still only using the "--no-vignettes" option from R < 3
-  - rk.XML.pluginmap() malformed label argument names if they referred to standrad maneu entries
+  - removed arguments "help" and "component" from rk.XML.optionscolumn()
+    again, as these are already being documented via the objects they connect to.
+  - rk.build.plugin() was still only using the "--no-vignettes" option from R
+    < 3
+  - rk.XML.pluginmap() malformed label argument names if they referred to
+    standrad maneu entries
   - rk.plugin.skeleton() still allowed invalid IDs, fixed the regexp
   - rk.XML.snippets() now also accepts <include> as child node
   - rk.XML.tabbook() returns <insert> nodes as-is, not nested in <tab></tab>
-  - rk.JS.scan() now sets "state" as default modifier for checkboxes if guess.getter is TRUE
+  - rk.JS.scan() now sets "state" as default modifier for checkboxes if
+    guess.getter is TRUE
+  - rk.XML.connect() handled modifiers too strict if "client" was a string, and too
+    liberal when "governor" was
 added:
   - all "help" values can now be a list of character strings or XiMpLe nodes,
     to have more control over the markup
-  - added "property" and "duplicates" arguments to rk.XML.valueslot() and rk.XML.varslot().
-  - rk.XML.pluginmap() now adds a "po_id" attribute to pluginmaps, necessary for i18n
-  - new attribute "i18n" added to several XML functions; it takes a list with the named arguments
-    "comment" or "context" to either produce an i18n comment node or an "i18n_context" attribute
+  - added "property" and "duplicates" arguments to rk.XML.valueslot() and
+    rk.XML.varslot().
+  - rk.XML.pluginmap() now adds a "po_id" attribute to pluginmaps, necessary
+    for i18n
+  - new attribute "i18n" added to several XML functions; it takes a list with
+    the named arguments "comment" or "context" to either produce an i18n
+    comment node or an "i18n_context" attribute
   - new function rk.i18n.comment() to give context for translators
-  - new function rk.JS.header() to easily generate JavaScript header code fit for i18n
-  - 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 rk.JS.header() to easily generate JavaScript header code fit
+    for i18n
+  - 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...
-    the i18n features of 0.06-4 will be completely replaced with some proper methods now
-  - comment nodes (<!-- foo -->) are now globally allowed as child nodes in XML; important for
-    i18n comments
-  - modifier checks now point to rkwarddev:::all.valid.modifiers directly in case of errors
-  - internally, moved the definitions of valid child nodes and modifiers as well as default getter
-    functions and modifiers to separate files, so they're more obvious to find and check
+  - 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... the i18n features of 0.06-4 will be
+    completely replaced with some proper methods now
+  - comment nodes (<!-- foo -->) are now globally allowed as child nodes in
+    XML; important for i18n comments
+  - modifier checks now point to rkwarddev:::all.valid.modifiers directly in
+    case of errors
+  - internally, moved the definitions of valid child nodes and modifiers as
+    well as default getter functions and modifiers to separate files, so
+    they're more obvious to find and check
 removed:
-  - the functions rk.set.language() rk.get.language() were no longer useful and therefore removed
-  - also removed the option "lang" from rk.rkh.doc(), rk.XML.plugin(), rk.XML.pluginmap()
-    and rk.plugin.skeleton()
+  - the functions rk.set.language() rk.get.language() were no longer useful
+    and therefore removed
+  - also removed the option "lang" from rk.rkh.doc(), rk.XML.plugin(),
+    rk.XML.pluginmap() and rk.plugin.skeleton()
 
 changes in version 0.06-5 (2014-10-19)
 fixed:
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index 6b6acd8..73fa146 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -5,6 +5,8 @@ Author: m.eik michalke <meik.michalke at hhu.de>
 Maintainer: m.eik michalke <meik.michalke at hhu.de>
 Depends:
     R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)
+Suggests:
+    testthat
 Enhances: rkward
 Description: Provides functions to create plugin skeletons and XML structures
     for RKWard.
@@ -15,7 +17,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-12
+Date: 2014-12-13
 Collate:
     '00_class_01_rk.JS.arr.R'
     '00_class_02_rk.JS.var.R'
diff --git a/packages/rkwarddev/R/rk.XML.connect.R b/packages/rkwarddev/R/rk.XML.connect.R
index 247f1a5..7a9558f 100644
--- a/packages/rkwarddev/R/rk.XML.connect.R
+++ b/packages/rkwarddev/R/rk.XML.connect.R
@@ -70,7 +70,9 @@ rk.XML.connect <- function(governor, client, get="state", set="enabled", not=FAL
         governor.id <- paste(governor.id, get, sep=".")
       } else {}
     } else {}
-  } else {}
+  } else {
+    modif.validity("all", modifier=get)
+  }
   if(isTRUE(not)){
     governor.id <- paste(governor.id, "not", sep=".")
   } else {}
@@ -78,9 +80,12 @@ rk.XML.connect <- function(governor, client, get="state", set="enabled", not=FAL
   attr.list <- list(governor=as.character(governor.id))
 
   # validate set modifier
-  if(modif.validity(client, modifier=set, warn.only=FALSE)){
-    attr.list[["client"]] <- paste(client.id, set, sep=".")
-  } else {}
+  if(is.XiMpLe.node(client)){
+    modif.validity(client, modifier=set, warn.only=FALSE)
+  } else {
+    modif.validity("all", modifier=set, warn.only=FALSE)
+  }
+  attr.list[["client"]] <- paste(client.id, set, sep=".")
 
   if(isTRUE(reconcile)){
       attr.list[["reconcile"]] <- "true"
diff --git a/packages/rkwarddev/R/rkwarddev-package.R b/packages/rkwarddev/R/rkwarddev-package.R
index dc322c0..4469591 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-12\cr
+#' Date: \tab 2014-12-13\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/XML_test_standards.RData b/packages/rkwarddev/inst/tests/XML_test_standards.RData
new file mode 100644
index 0000000..6f87f15
Binary files /dev/null and b/packages/rkwarddev/inst/tests/XML_test_standards.RData differ
diff --git a/packages/rkwarddev/inst/tests/about_XML_standard.Rdata b/packages/rkwarddev/inst/tests/about_XML_standard.Rdata
deleted file mode 100644
index 0f811fe..0000000
Binary files a/packages/rkwarddev/inst/tests/about_XML_standard.Rdata and /dev/null differ
diff --git a/packages/rkwarddev/inst/tests/test_XML_generation.R b/packages/rkwarddev/inst/tests/test_XML_generation.R
index 2c1901f..a04a6ea 100644
--- a/packages/rkwarddev/inst/tests/test_XML_generation.R
+++ b/packages/rkwarddev/inst/tests/test_XML_generation.R
@@ -1,10 +1,11 @@
 # testing basic tokenizing and POS tagging
 
+# all test standards are stored in a list object called "XML_test_standards"
+# it was saved to the file "XML_test_standards.RData"
+
 context("XML")
 
 test_that("about", {
-  load("about_XML_standard.RData")
-
   thisNode <- rk.XML.about(
     name="Square the circle",
     author=c(
@@ -16,21 +17,133 @@ test_that("about", {
     about=list(
       desc="Squares the circle using Heisenberg compensation.",
       version="0.1-3",
-      date=Sys.Date(),
+      date=as.Date("2014-12-12"),
       url="http://eternalwondermaths.example.org/23/stc.html",
       license="GPL",
       category="Geometry")
   )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["about"]])
+  )
+})
+
+test_that("attribute", {
+  thisNode <- rk.XML.attribute(
+    id="testID",
+    label="an attribute label",
+    value="checked"
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["attribute"]])
+  )
+})
+
+test_that("browser", {
+  thisNode <- rk.XML.browser(
+    label="a browser label",
+    type="dir",
+    initial="/tmp/initial",
+    filter=c("*initial", "*csv"),
+    required=TRUE,
+    i18n=list(context="context info here")
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["browser"]])
+  )
+})
+
+test_that("checkbox", {
+  thisNode <- rk.XML.cbox(
+    label="a checbox label",
+    value="checked",
+    chk=TRUE,
+    un.value="unchecked",
+    i18n=list(context="context info here")
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["checkbox"]])
+  )
+})
 
-  expect_that(thisNode,
-    equals(thisNodeStandard))
+test_that("code", {
+  thisNode <- rk.XML.code(
+    file="some_file.js"
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["code"]])
+  )
+})
+
+test_that("col", {
+  thisNode <- rk.XML.col(
+    rk.XML.cbox(label="a column label")
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["col"]])
+  )
+})
+
+test_that("component", {
+  thisNode <- rk.XML.component(
+    label="a component label",
+    file="plugins/MyGUIdialog.xml",
+    i18n=list(context="context info here")
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["component"]])
+  )
+})
+
+test_that("components", {
+  thisNode <- rk.XML.components(
+    rk.XML.component(
+      label="a components label",
+      file="plugins/MyOtherGUIdialog.xml"
+    )
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["components"]])
+  )
+})
+
+test_that("connect", {
+  thisNode <- rk.XML.connect(
+    governor="myGovernor",
+    client="myCLient",
+    get="visible",
+    set="string",
+    not=TRUE,
+    reconcile=TRUE
+  )
+  load("XML_test_standards.RData")
+  expect_that(
+    thisNode, equals(XML_test_standards[["connect"]])
+  )
 })
 
 # test_that("", {
-#   thisNodeStandard <- dget("_XML_dput.txt")
-# 
-#   thisNode <- rk.XML.()
+#   thisNode <-
+#   load("XML_test_standards.RData")
+#   expect_that(
+#     thisNode, equals(XML_test_standards[[""]])
+#   )
+# })
 # 
-#   expect_that(thisNode,
-#     equals(thisNodeStandard))
+# test_that("", {
+#   thisNode <-
+#   load("XML_test_standards.RData")
+#   expect_that(
+#     thisNode, equals(XML_test_standards[[""]])
+#   )
 # })
+# 
+# test_that("", {
+#   thisNode <-
diff --git a/packages/rkwarddev/man/rk.XML.about.Rd b/packages/rkwarddev/man/rk.XML.about.Rd
index 5f39cb9..77ceb0f 100644
--- a/packages/rkwarddev/man/rk.XML.about.Rd
+++ b/packages/rkwarddev/man/rk.XML.about.Rd
@@ -33,27 +33,14 @@ See \code{\link[utils:person]{person}} for more details on this,
   \item{long.desc}{A long description (optional, defaults to \code{desc})}
 }}
 
-\item{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)}
-}}
+\item{dependencies}{Deprecated,
+      use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.}
 
-\item{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)}
-}}
+\item{package}{Deprecated,
+      use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.}
 
-\item{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)}
-}}
+\item{pluginmap}{Deprecated,
+      use \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} instead.}
 }
 \description{
 Create XML node "about" for RKWard pluginmaps
@@ -73,23 +60,13 @@ about.node <- rk.XML.about(
     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))
 }
 \seealso{
-\href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+\code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}},
+   \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 }
 
diff --git a/packages/rkwarddev/man/rkwarddev-package.Rd b/packages/rkwarddev/man/rkwarddev-package.Rd
index bc14375..d8f3b13 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-12\cr
+Date: \tab 2014-12-13\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/generate_test_standards.R b/packages/rkwarddev/tests/generate_test_standards.R
new file mode 100644
index 0000000..26ca2f4
--- /dev/null
+++ b/packages/rkwarddev/tests/generate_test_standards.R
@@ -0,0 +1,128 @@
+## this function can be used to generate a list of XiMpLe nodes as testing standards
+require(rkwarddev)
+
+# returns the list if file=NULL
+XMLTestNodes <- function(file=NULL, compress="xz", compression_level=-9){
+  XML_test_standards <- list(
+    about=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=as.Date("2014-12-12"),
+          url="http://eternalwondermaths.example.org/23/stc.html",
+          license="GPL",
+          category="Geometry")
+      ),
+      attribute=rk.XML.attribute(
+        id="testID",
+        label="an attribute label",
+        value="checked"
+      ),
+      browser=rk.XML.browser(
+        label="a browser label",
+        type="dir",
+        initial="/tmp/initial",
+        filter=c("*initial", "*csv"),
+        required=TRUE,
+        i18n=list(context="context info here")
+      ),
+      checkbox=rk.XML.cbox(
+        label="a checbox label",
+        value="checked",
+        chk=TRUE,
+        un.value="unchecked",
+        i18n=list(context="context info here")
+      ),
+      code=rk.XML.code(
+        file="some_file.js"
+      ),
+      col=rk.XML.col(
+        rk.XML.cbox(label="a column label")
+      ),
+      component=rk.XML.component(
+        label="a component label",
+        file="plugins/MyGUIdialog.xml",
+        i18n=list(context="context info here")
+      ),
+      components=rk.XML.components(
+        rk.XML.component(
+          label="a components label",
+          file="plugins/MyOtherGUIdialog.xml"
+        )
+      ),
+      connect=rk.XML.connect(
+        governor="myGovernor",
+        client="myCLient",
+        get="visible",
+        set="string",
+        not=TRUE,
+        reconcile=TRUE
+      )#,
+#     context=rk.XML.context(),
+#     convert=rk.XML.convert(),
+#     copy=rk.XML.copy(),
+#     dependencies=rk.XML.dependencies(),
+#     dependency_check=rk.XML.dependency_check(),
+#     dialog=rk.XML.dialog(),
+#     dropdown=rk.XML.dropdown(),
+#     embed=rk.XML.embed(),
+#     entry=rk.XML.entry(),
+#     external=rk.XML.external(),
+#     formula=rk.XML.formula(),
+#     frame=rk.XML.frame(),
+#     help=rk.XML.help(),
+#     hierarchy=rk.XML.hierarchy(),
+#     include=rk.XML.include(),
+#     input=rk.XML.input(),
+#     insert=rk.XML.insert(),
+#     logic=rk.XML.logic(),
+#     matrix=rk.XML.matrix(),
+#     menu=rk.XML.menu(),
+#     optioncolumn=rk.XML.optioncolumn(),
+#     optiondisplay=rk.XML.optiondisplay(),
+#     option=rk.XML.option(),
+#     optionset=rk.XML.optionset(),
+#     page=rk.XML.page(),
+#     pluginmap=rk.XML.pluginmap(),
+#     plugin=rk.XML.plugin(),
+#     preview=rk.XML.preview(),
+#     radio=rk.XML.radio(),
+#     require=rk.XML.require(),
+#     row=rk.XML.row(),
+#     saveobj=rk.XML.saveobj(),
+#     select=rk.XML.select(),
+#     set=rk.XML.set(),
+#     snippet=rk.XML.snippet(),
+#     snippets=rk.XML.snippets(),
+#     spinbox=rk.XML.spinbox(),
+#     stretch=rk.XML.stretch(),
+#     switch=rk.XML.switch(),
+#     tabbook=rk.XML.tabbook(),
+#     text=rk.XML.text(),
+#     valueselector=rk.XML.valueselector(),
+#     valueslot=rk.XML.valueslot(),
+#     values=rk.XML.values(),
+#     varselector=rk.XML.varselector(),
+#     varslot=rk.XML.varslot(),
+#     vars=rk.XML.vars(),
+#     wizard=rk.XML.wizard()
+  )
+
+  if(is.null(file)){
+    return(XML_test_standards)
+  } else {
+    save(XML_test_standards,
+      file=file,
+      compress=compress,
+      compression_level=compression_level)
+    message(paste0("written to file ", file))
+    return(invisible(NULL))
+  }
+}





More information about the rkward-tracker mailing list