# NOT RUN {
attach(ChickWeight)
# Passing assertions
assert(is.numeric(weight),
all(weight > 0))
# Failing assertions
if (interactive()) {
assert(all(Diet > 0),
is.numeric(Times))
}
# Validating function arguments
sum <- function(a, b) {
assert(is.numeric(a),
is.numeric(b),
length(a) == length(b))
return(a+b)
}
sum(2, 2)
if (interactive()) {
sum("1", 2)
sum(1, c(1,2))
sum(1, x)
}
# }
Run the code above in your browser using DataLab