Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
^docs$
^LICENSE\.md$
^LICENSES_THIRD_PARTY$
^AGENTS\.md$
^codecov\.yml$
^\.github$
^cran-comments\.md$
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/independent-testing-tlf-ae-listing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# rtf output: ae listing

Code
tbl
print_str(tbl)
Output
List of 12
$ meta :List of 7
$ meta : List of 7
$ population : chr "apat"
$ observation : chr "wk12"
$ parameter : chr "rel"
Expand All @@ -13,7 +13,7 @@
$ group : NULL
$ reference_group: NULL
$ col_name : Named chr [1:11] "Unique Subject Identifier" "Analysis Start Relative Day" "Adverse Event" "Duration" ...
$ tbl :'data.frame': 704 obs. of 11 variables:
$ tbl : 'data.frame': 704 obs. of 11 variables:
$ prepare_call : language prepare_ae_listing(meta = x, analysis = "ae_listing", population = "apat", observation = "wk12", parameter = "rel")
$ rtf :Classes 'rtf_text', 'rtf_border' and 'data.frame': 704 obs. of 11 variables:
$ rtf : Classes 'rtf_text', 'rtf_border' and 'data.frame': 704 obs. of 11 variables:

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rtf output: n, and prop w/o total

Code
tbl
print_str(tbl)
Output
$components
[1] "soc" "par"
Expand Down Expand Up @@ -68,53 +68,53 @@
$out_all
$out_all$F
List of 15
$ meta :List of 7
$ meta : List of 7
$ population : chr "apat"
$ observation : chr "wk12"
$ parameter : chr "rel"
$ n :'data.frame': 138 obs. of 4 variables:
$ n : 'data.frame': 138 obs. of 4 variables:
$ order : num [1:138] 1 100 200 900 1000 ...
$ group : chr [1:4] "Placebo" "Low Dose" "High Dose" "Total"
$ reference_group: num 1
$ prop :'data.frame': 138 obs. of 4 variables:
$ diff :'data.frame': 138 obs. of 2 variables:
$ n_pop :'data.frame': 1 obs. of 4 variables:
$ prop : 'data.frame': 138 obs. of 4 variables:
$ diff : 'data.frame': 138 obs. of 2 variables:
$ n_pop : 'data.frame': 1 obs. of 4 variables:
$ name : chr [1:138] "Participants in population" "with one or more drug-related adverse events" "with no drug-related adverse events" "" ...
$ soc_name : chr [1:138] NA NA NA NA ...
$ components : chr [1:2] "soc" "par"
$ prepare_call : language FUN(meta = X[[i]], population = ..1, observation = ..2, parameter = ..3, components = ..4)

$out_all$M
List of 15
$ meta :List of 7
$ meta : List of 7
$ population : chr "apat"
$ observation : chr "wk12"
$ parameter : chr "rel"
$ n :'data.frame': 138 obs. of 4 variables:
$ n : 'data.frame': 138 obs. of 4 variables:
$ order : num [1:138] 1 100 200 900 1000 ...
$ group : chr [1:4] "Placebo" "Low Dose" "High Dose" "Total"
$ reference_group: num 1
$ prop :'data.frame': 138 obs. of 4 variables:
$ diff :'data.frame': 138 obs. of 2 variables:
$ n_pop :'data.frame': 1 obs. of 4 variables:
$ prop : 'data.frame': 138 obs. of 4 variables:
$ diff : 'data.frame': 138 obs. of 2 variables:
$ n_pop : 'data.frame': 1 obs. of 4 variables:
$ name : chr [1:138] "Participants in population" "with one or more drug-related adverse events" "with no drug-related adverse events" "" ...
$ soc_name : chr [1:138] NA NA NA NA ...
$ components : chr [1:2] "soc" "par"
$ prepare_call : language FUN(meta = X[[i]], population = ..1, observation = ..2, parameter = ..3, components = ..4)

$out_all$Total
List of 15
$ meta :List of 7
$ meta : List of 7
$ population : chr "apat"
$ observation : chr "wk12"
$ parameter : chr "rel"
$ n :'data.frame': 138 obs. of 4 variables:
$ n : 'data.frame': 138 obs. of 4 variables:
$ order : num [1:138] 1 100 200 900 10000 ...
$ group : chr [1:4] "Placebo" "Low Dose" "High Dose" "Total"
$ reference_group: num 1
$ prop :'data.frame': 138 obs. of 4 variables:
$ diff :'data.frame': 138 obs. of 2 variables:
$ n_pop :'data.frame': 1 obs. of 4 variables:
$ prop : 'data.frame': 138 obs. of 4 variables:
$ diff : 'data.frame': 138 obs. of 2 variables:
$ n_pop : 'data.frame': 1 obs. of 4 variables:
$ name : chr [1:138] "Participants in population" "with one or more drug-related adverse events" "with no drug-related adverse events" "" ...
$ soc_name : chr [1:138] NA NA NA NA ...
$ components : chr [1:2] "soc" "par"
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/_snaps/independent-testing-tlf_ae_summary.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# aesummary.rtf file output

Code
tbl
print_str(tbl)
Output
List of 19
$ meta :List of 7
$ meta : List of 7
$ population : chr "apat"
$ observation : chr "wk12"
$ parameter : chr "any;rel;ser"
$ n :'data.frame': 5 obs. of 4 variables:
$ n : 'data.frame': 5 obs. of 4 variables:
$ order : num [1:5] 1 100 200 300 400
$ group : chr [1:4] "Placebo" "Low Dose" "High Dose" "Total"
$ reference_group: num 1
$ prop :'data.frame': 5 obs. of 4 variables:
$ diff :'data.frame': 5 obs. of 2 variables:
$ n_pop :'data.frame': 1 obs. of 4 variables:
$ prop : 'data.frame': 5 obs. of 4 variables:
$ diff : 'data.frame': 5 obs. of 2 variables:
$ n_pop : 'data.frame': 1 obs. of 4 variables:
$ name : chr [1:5] "Participants in population" "with one or more adverse events" "with no adverse events" "with drug-related{^a} adverse events" ...
$ prepare_call : language prepare_ae_summary(meta = meta, population = "apat", observation = "wk12", parameter = "any;rel;ser")
$ tbl :'data.frame': 5 obs. of 9 variables:
$ tbl : 'data.frame': 5 obs. of 9 variables:
$ display : chr [1:3] "n" "prop" "total"
$ extend_call :List of 1
$ extend_call : List of 1
$ filter_method : chr "percent"
$ filter_criteria: num 0
$ rtf :Classes 'rtf_text', 'rtf_border' and 'data.frame': 5 obs. of 9 variables:
$ rtf : Classes 'rtf_text', 'rtf_border' and 'data.frame': 5 obs. of 9 variables:

16 changes: 16 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,19 @@ expect_snapshot_rtf <- function(path) {
# Now use expect_snapshot_file on the normalized file
testthat::expect_snapshot_file(path, name = basename(path))
}

#' Print an object with stable `str()` spacing across R versions
#'
#' R-devel always puts one space after `$ name:`, `@ slot:` and
#' `attr(*, "x")=` in `str()` output, which older R sometimes omitted (e.g.,
#' `$ n :'data.frame'`), so normalize that separator before taking a snapshot.
#'
#' @param x Object whose `print()` output contains `str()` lines.
#' @noRd
print_str <- function(x) {
out <- utils::capture.output(print(x))
out <- sub(
"^([ .]*([$@] [^:]*:|- attr\\(\\*, \"[^\"]*\"\\)=)) *", "\\1 ", out
)
cat(out, sep = "\n")
}
2 changes: 1 addition & 1 deletion tests/testthat/test-independent-testing-tlf-ae-listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ tbl <- outdata |>
)

test_that("rtf output: ae listing", {
testthat::expect_snapshot(tbl)
testthat::expect_snapshot(print_str(tbl))
})
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ test_that("rtf output: n, and prop w/o total", {
path_outtable = path_rtf
)

testthat::expect_snapshot(tbl)
testthat::expect_snapshot(print_str(tbl))
})
2 changes: 1 addition & 1 deletion tests/testthat/test-independent-testing-tlf_ae_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ tbl <- outdata |>
)

test_that("aesummary.rtf file output", {
expect_snapshot(tbl)
expect_snapshot(print_str(tbl))
})
Loading