R Under development (unstable) (2024-03-18 r86148 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(unittest) > > library(gadget3) > > cmp_code <- function(a, b) { + if (rlang::is_formula(a)) a <- rlang::f_rhs(a) + if (rlang::is_formula(b)) b <- rlang::f_rhs(b) + attr(a, "srcref") <- NULL + attr(a, "srcfile") <- NULL + attr(a, "wholeSrcref") <- NULL + attr(b, "srcref") <- NULL + attr(b, "srcfile") <- NULL + attr(b, "wholeSrcref") <- NULL + ut_cmp_identical(a, b) + } > > ok_group("action_reports", { + ok(cmp_code(gadget3:::action_reports(list( + ~{y <- 1}, + ~{y <- 1 ; x <- 2} + ~{}), REPORT = '.'), quote({ + REPORT(x) + REPORT(y) + })), "Don't return duplicates, results are sorted") + + ok(cmp_code(gadget3:::action_reports(list( + ~g3_with(x := 1, z := 2, {y <- 1 ; x <- 2}), + ~{rr <- 1}, + ~{}), REPORT = '.'), quote({ + REPORT(rr) + REPORT(y) + })), "g3_with vars are ignored") + + ok(cmp_code(gadget3:::action_reports(list( + ~{ p_p <- 1 ; p_q <- 1 ; p_r <- 1}, + ~{ q_p <- 1 ; q_q <- 1 ; q_r <- 1}, + ~{}), p_rep = '^p_', q_rep = '^q_', r_rep = 'r', z_rep = 'z'), quote({ + p_rep(p_p) + p_rep(p_q) + p_rep(p_r) + q_rep(q_p) + q_rep(q_q) + q_rep(q_r) + r_rep(p_r) + r_rep(q_r) + })), "Can generate multiple report functions with filters") + }) # action_reports ok - Don't return duplicates, results are sorted ok - g3_with vars are ignored ok - Can generate multiple report functions with filters > > proc.time() user system elapsed 0.26 0.03 0.28 # Looks like you passed all 3 tests.