From 15b9759e4964bfda9ebca84f0e7ff650b2481ec4 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Mon, 25 Nov 2024 16:01:49 -0300 Subject: [PATCH] Fix tests random crashes --- crates/ark/src/variables/variable.rs | 30 +++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/ark/src/variables/variable.rs b/crates/ark/src/variables/variable.rs index ab701a034..6f06501d7 100644 --- a/crates/ark/src/variables/variable.rs +++ b/crates/ark/src/variables/variable.rs @@ -1864,7 +1864,8 @@ mod tests { fn inspect_from_expr(code: &str) -> Vec { let env = Environment::new(harp::parse_eval_base("new.env(parent = emptyenv())").unwrap()); - env.bind("x".into(), harp::parse_eval_base(code).unwrap()); + let value = harp::parse_eval_base(code).unwrap(); + env.bind("x".into(), value.sexp); // Inspect the S4 object let path = vec![String::from("x")]; PositronVariable::inspect(env.into(), &path).unwrap() @@ -1971,10 +1972,8 @@ mod tests { fn test_truncation_on_matrices() { r_task(|| { let env = Environment::new_empty().unwrap(); - env.bind( - "x".into(), - harp::parse_eval_base("matrix(0, nrow = 10000, ncol = 10000)").unwrap(), - ); + let value = harp::parse_eval_base("matrix(0, nrow = 10000, ncol = 10000)").unwrap(); + env.bind("x".into(), value.sexp); // Inspect the matrix, we should see the list of columns truncated let path = vec![String::from("x")]; @@ -1993,10 +1992,8 @@ mod tests { fn test_string_truncation() { r_task(|| { let env = Environment::new_empty().unwrap(); - env.bind( - "x".into(), - harp::parse_eval_base("paste(1:5e6, collapse = ' - ')").unwrap(), - ); + let value = harp::parse_eval_base("paste(1:5e6, collapse = ' - ')").unwrap(); + env.bind("x".into(), value.sexp); let path = vec![]; let vars = PositronVariable::inspect(env.into(), &path).unwrap(); @@ -2006,7 +2003,8 @@ mod tests { // Test for the empty string let env = Environment::new_empty().unwrap(); - env.bind("x".into(), harp::parse_eval_base("''").unwrap()); + let value = harp::parse_eval_base("''").unwrap(); + env.bind("x".into(), value.sexp); let path = vec![]; let vars = PositronVariable::inspect(env.into(), &path).unwrap(); @@ -2015,10 +2013,8 @@ mod tests { // Test for the single elment matrix, but with a large character let env = Environment::new_empty().unwrap(); - env.bind( - "x".into(), - harp::parse_eval_base("matrix(paste(1:5e6, collapse = ' - '))").unwrap(), - ); + let value = harp::parse_eval_base("matrix(paste(1:5e6, collapse = ' - '))").unwrap(); + env.bind("x".into(), value.sexp); let path = vec![]; let vars = PositronVariable::inspect(env.into(), &path).unwrap(); assert_eq!(vars.len(), 1); @@ -2027,10 +2023,8 @@ mod tests { // Test for the empty matrix let env = Environment::new_empty().unwrap(); - env.bind( - "x".into(), - harp::parse_eval_base("matrix(NA, ncol = 0, nrow = 0)").unwrap(), - ); + let value = harp::parse_eval_base("matrix(NA, ncol = 0, nrow = 0)").unwrap(); + env.bind("x".into(), value.sexp); let path = vec![]; let vars = PositronVariable::inspect(env.into(), &path).unwrap(); assert_eq!(vars.len(), 1);