Open maxheld83 opened 7 years ago
perhaps, a somewhat off-the-cuff suggestion, after all (of the interface):
check_consistency(x, # object 1,
y, # object 2,
# all of the following conditions must be read as: x blah-condition y
length = TRUE, # could also be "smaller", "larger"
# interpreted as, e.g. x smaller y
names = "subset.of",
# interpreted as, e.g. x subset.of y
ncol = TRUE, # could also be "smaller"
nrow = TRUE,
colnames = "identical.to", # etc
rownames = "identical.to", # etc
) {
# here be dragons
return(paste(vname(x), "must be shorter than", vname(y))) # etc.
}
I often find myself in the situation where I do not just want to
assert()
something about an argument, but rather, whether two (or more) arguments are consistent, including, for example:identical.to
,subset.of
,permutation.of
)This shows up especially when validating classes (as suggested in #92).
checkmate()
in its current form can be shoehorned into this service, but there are some issues:assert_
,test_
, andexpect_
as well astestthat()
andassert()
collections/reporters.I have only an anecdotal grasp of the problem, so I don't know what a good interface (let alone implementation) would look like. I mainly just wanted to raise this here to see whether you might consider this in the future.