[CHNOSZ-commits] r355 - in pkg/CHNOSZ: . R inst tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 17 00:10:36 CET 2019


Author: jedick
Date: 2019-01-17 00:10:35 +0100 (Thu, 17 Jan 2019)
New Revision: 355

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/tests/testthat/test-subcrt.R
Log:
subcrt(): improve error message for invalid property names


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-01-15 04:03:19 UTC (rev 354)
+++ pkg/CHNOSZ/DESCRIPTION	2019-01-16 23:10:35 UTC (rev 355)
@@ -1,6 +1,6 @@
 Date: 2019-01-15
 Package: CHNOSZ
-Version: 1.1.3-62
+Version: 1.1.3-63
 Title: Thermodynamic Calculations and Diagrams for Geo(bio)chemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/R/subcrt.R
===================================================================
--- pkg/CHNOSZ/R/subcrt.R	2019-01-15 04:03:19 UTC (rev 354)
+++ pkg/CHNOSZ/R/subcrt.R	2019-01-16 23:10:35 UTC (rev 355)
@@ -51,8 +51,8 @@
   # property checking
   calcprop <- property
   notprop <- property[!calcprop %in% properties]
-  if(length(notprop) > 0) stop(paste(notprop,
-    "are not valid properties\ntry rho, logK, G, H, S, V, Cp, kT, or E"))
+  if(length(notprop) == 1) stop(paste("invalid property name:", paste(notprop, collapse=" ")))
+  if(length(notprop) > 1) stop(paste("invalid property names:", paste(notprop, collapse=" ")))
   # length checking
   if(do.reaction & length(species)!=length(coeff)) 
     stop('coeff must be same length as the number of species.')

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-01-15 04:03:19 UTC (rev 354)
+++ pkg/CHNOSZ/inst/NEWS	2019-01-16 23:10:35 UTC (rev 355)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-62 (2019-01-15)
+CHANGES IN CHNOSZ 1.1.3-63 (2019-01-17)
 ---------------------------------------
 
 NEW FEATURES
@@ -191,6 +191,8 @@
 
 - Reduce message clutter for diagrams showing water stability limits.
 
+- In subcrt(), improve error message for invalid property names.
+
 CHANGES IN CHNOSZ 1.1.3 (2017-11-13)
 ------------------------------------
 

Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-subcrt.R	2019-01-15 04:03:19 UTC (rev 354)
+++ pkg/CHNOSZ/tests/testthat/test-subcrt.R	2019-01-16 23:10:35 UTC (rev 355)
@@ -203,6 +203,12 @@
     c("T", "P", "rho", "logK", "G", "H", "S", "V", "Cp", "polymorph")))
 })
 
+test_that("argument checking handles some types of invalid input", {
+  expect_error(subcrt("H2O", -1, "liq", "xxx"), "invalid property name: xxx")
+  # before version 1.1.3-63, having more than one invalid property gave a mangled error message
+  expect_error(subcrt("H2O", -1, "liq", c(1, 2)), "invalid property names: 1 2")
+})
+
 # references
 
 # Amend, J. P. and Shock, E. L. (2001) 



More information about the CHNOSZ-commits mailing list