Skip to content

Commit

Permalink
Fix #65: strings returned from vet tokens are incorporated
Browse files Browse the repository at this point in the history
  • Loading branch information
brodieG committed Sep 3, 2017
2 parents 12cf53c + ed21103 commit 09e69f6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Title: Trust, but Verify
Description: Declarative template-based framework for verifying that objects
meet structural requirements, and auto-composing error messages when they do
not.
Version: 0.1.0.9005
Version: 0.1.0.9006
Authors@R: c(
person("Brodie", "Gaslam", email="brodie.gaslam@yahoo.com",
role=c("aut", "cre")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use the symbol of the object being vetted are no longer valid. This avoid
confusion caused by intended standard tokens being treated as template tokens
because they use the object symbol instead of `.` to refer to the object.
* [#65](https://github.com/brodieG/validate/issues/65): Vetting tokens that
return strings instead of logicals now have that string embedded in the return
value of `vet`/`vetr`.
* [#64](https://github.com/brodieG/validate/issues/64): Rewrite result handling
for multi token expressions to avoid unnecessary slow downs
* [#77](https://github.com/brodieG/validate/issues/77): Replace `SIZE_T_MAX`
Expand Down
3 changes: 2 additions & 1 deletion src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,10 @@ SEXP VALC_error_standard(
switch(eval_res_c) {
case -6: {
R_xlen_t eval_res_len = xlength(eval_tmp);
// This could be slow, ideally we would avoid running CSR_smprintf
err_tok = CSR_smprintf4(
set.nchar_max,
"chr%s \"%s\"%s%s",
"is chr%s: \"%s\"%s%s",
eval_res_len > 1 ?
CSR_smprintf2(
set.nchar_max, " [1:%s]%s", CSR_len_as_chr(eval_res_len),
Expand Down
4 changes: 4 additions & 0 deletions tests/unitizer/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ unitizer_sect("Multi-line Stuff", {
val.exp <- quote(!anyNA(.))
vet(val.exp, c(234234131431, 123413413413, NA))
})
unitizer_sect("Embedded String Errors", {
vet(all_bw(., 0, 1), 0:5)
vet(all.equal(., 1:5), 1:6)
})

unitizer_sect("Language", {
# Note issue #18; not 100% sure this is correct, actually it should be, the
Expand Down
Binary file modified tests/unitizer/validate.unitizer/data.rds
Binary file not shown.

0 comments on commit 09e69f6

Please sign in to comment.