For use inside D functions called from R.
Calls into the R API function Rf_error to throw an error if a test condition is not met. Used to stop the R program from running when there is an error in the D code. Without using assertR, there will normally be a segmentation fault and little information about the error. Those are nasty, so you want to add calls to assertR all over your code.
A test for code correctness.
The error message to return from R if test is false.
1 // Obviously have mixed up the high and low temperatures 2 int low = 75; 3 int high = 42; 4 assertR(high >= low, "Cannot have the day's high temperature 5 be less than the day's low temperature");
double x = [3.1, 4.7, 1.8]; int ii = 3; double z = x[ii]; // out of bounds error, will cause a segmentation fault assertR(ii < x.length, "Index greater than the number of elements");