Skip to content

Commit

Permalink
Use R_ParseEvalString in test (#188)
Browse files Browse the repository at this point in the history
* Remove unnecessary `tasks.json` file!

* Since all supported versions have
`R_ParseEvalString`, then we should use it!
  • Loading branch information
CGMossa authored Oct 7, 2023
1 parent 997d6cd commit a452bff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
18 changes: 0 additions & 18 deletions .vscode/tasks.json

This file was deleted.

12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,11 @@ mod tests {
fn test_eval() {
start_R();
unsafe {
// In an ideal world, we would do the following.
// let res = R_ParseEvalString(cstr!("1"), R_NilValue);
// But R_ParseEvalString is only in recent packages.

let s = Rf_protect(Rf_mkString(cstr!("1")));
let mut status: ParseStatus = 0;
let status_ptr = &mut status as *mut ParseStatus;
let ps = Rf_protect(R_ParseVector(s, -1, status_ptr, R_NilValue));
let val = Rf_eval(VECTOR_ELT(ps, 0), R_GlobalEnv);
let val = Rf_protect(R_ParseEvalString(cstr!("1"), R_NilValue));
Rf_PrintValue(val);
assert_eq!(TYPEOF(val) as u32, REALSXP);
assert_eq!(*REAL(val), 1.);
Rf_unprotect(2);
Rf_unprotect(1);
}
}
}

0 comments on commit a452bff

Please sign in to comment.