From 712a210837b31d0c7bb75e881a459d01d47a4417 Mon Sep 17 00:00:00 2001 From: mossa Date: Thu, 5 Oct 2023 22:41:09 +0200 Subject: [PATCH 1/2] Remove unnecessary `tasks.json` file! --- .vscode/tasks.json | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 62016596..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "cargo", - "subcommand": "test", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file From beb59fa0b2b6ce907c531e0df0191160b0f03fd6 Mon Sep 17 00:00:00 2001 From: mossa Date: Thu, 5 Oct 2023 22:42:07 +0200 Subject: [PATCH 2/2] Since all supported versions have `R_ParseEvalString`, then we should use it! --- src/lib.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index eea9dff9..cd882a0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); } } }