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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Suggests:
covr,
bit64,
withr
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
License: MIT + file LICENSE
Expand Down
11 changes: 9 additions & 2 deletions R/diffdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ diffdf <- function(
class(COMPARE) <- c("diffdf", "list")


BASE_NAME <- deparse(substitute(base))
COMP_NAME <- deparse(substitute(compare))
BASE_NAME <- deparse(substitute(base), width.cutoff = 30L)
if (length(BASE_NAME) > 1) {
BASE_NAME <- "<BASE>"
}
COMP_NAME <- deparse(substitute(compare), width.cutoff = 30L)
if (length(COMP_NAME) > 1) {
COMP_NAME <- "<COMPARE>"
}

COMPARE[["DataSummary"]] <- construct_issue(
value = describe_dataframe(BASE, COMP, BASE_NAME, COMP_NAME),
message = "Summary of BASE and COMPARE"
Expand Down
148 changes: 148 additions & 0 deletions tests/testthat/_snaps/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,154 @@



# #133 - Nested calls don't throw error with deparse

Code
diffdf(d1, d2, suppress_warnings = TRUE)
Output
Differences found between the objects!

Summary of BASE and COMPARE
==================================================================
PROPERTY BASE COMP
------------------------------------------------------------------
Name d1 d2
Class "tbl_df, tbl, data.frame" "tbl_df, tbl, data.frame"
Rows(#) 4 4
Columns(#) 2 2
------------------------------------------------------------------


Not all Values Compared Equal
=============================
Variable No of Differences
-----------------------------
x 4
-----------------------------


========================================
VARIABLE ..ROWNUMBER.. BASE COMPARE
----------------------------------------
x 1 1 2
x 2 2 3
x 3 3 4
x 4 4 5
----------------------------------------



---

Code
diffdf(d1, dplyr::mutate(d1, x = x + 1), suppress_warnings = TRUE)
Output
Differences found between the objects!

Summary of BASE and COMPARE
=======================================================================
PROPERTY BASE COMP
-----------------------------------------------------------------------
Name d1 "dplyr::mutate(d1, x = x + 1)"
Class "tbl_df, tbl, data.frame" "tbl_df, tbl, data.frame"
Rows(#) 4 4
Columns(#) 2 2
-----------------------------------------------------------------------


Not all Values Compared Equal
=============================
Variable No of Differences
-----------------------------
x 4
-----------------------------


========================================
VARIABLE ..ROWNUMBER.. BASE COMPARE
----------------------------------------
x 1 1 2
x 2 2 3
x 3 3 4
x 4 4 5
----------------------------------------



---

Code
diffdf(d1, dplyr::mutate(d1, x = x + x + x + x), suppress_warnings = TRUE)
Output
Differences found between the objects!

Summary of BASE and COMPARE
==================================================================
PROPERTY BASE COMP
------------------------------------------------------------------
Name d1 <COMPARE>
Class "tbl_df, tbl, data.frame" "tbl_df, tbl, data.frame"
Rows(#) 4 4
Columns(#) 2 2
------------------------------------------------------------------


Not all Values Compared Equal
=============================
Variable No of Differences
-----------------------------
x 4
-----------------------------


========================================
VARIABLE ..ROWNUMBER.. BASE COMPARE
----------------------------------------
x 1 1 4
x 2 2 8
x 3 3 12
x 4 4 16
----------------------------------------



---

Code
diffdf(dplyr::mutate(d1, x = x + x + x + x), d1, suppress_warnings = TRUE)
Output
Differences found between the objects!

Summary of BASE and COMPARE
==================================================================
PROPERTY BASE COMP
------------------------------------------------------------------
Name <BASE> d1
Class "tbl_df, tbl, data.frame" "tbl_df, tbl, data.frame"
Rows(#) 4 4
Columns(#) 2 2
------------------------------------------------------------------


Not all Values Compared Equal
=============================
Variable No of Differences
-----------------------------
x 4
-----------------------------


========================================
VARIABLE ..ROWNUMBER.. BASE COMPARE
----------------------------------------
x 1 4 1
x 2 8 2
x 3 12 3
x 4 16 4
----------------------------------------



# `as_ascii_table() can handle missing datetimes (#132)

Code
Expand Down
39 changes: 39 additions & 0 deletions tests/testthat/test-miscellaneous.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,44 @@ test_that("datetimes compare as expected", {
})


test_that("#133 - Nested calls don't throw error with deparse", {
d1 <- tibble(id = c(1, 2, 3, 4), x = c(1, 2, 3, 4))

expect_no_condition({
tibble(id = c(1, 2, 3, 4), x = c(1, 2, 3, 4)) |>
dplyr::mutate(x = x + 1) |>
diffdf(d1, suppress_warnings = TRUE)
})

d2 <- tibble(id = c(1, 2, 3, 4), x = c(1, 2, 3, 4) + 1)
expect_snapshot(diffdf(d1, d2, suppress_warnings = TRUE))

expect_snapshot(
diffdf(
d1,
d1 |> dplyr::mutate(x = x + 1),
suppress_warnings = TRUE
)
)

expect_snapshot(
diffdf(
d1,
d1 |> dplyr::mutate(x = x + x + x + x),
suppress_warnings = TRUE
)
)

expect_snapshot(
diffdf(
d1 |> dplyr::mutate(x = x + x + x + x),
d1,
suppress_warnings = TRUE
)
)
})


testthat::test_that("#138 - No partial arg matches", {
withr::local_options(
list(
Expand Down Expand Up @@ -287,6 +325,7 @@ testthat::test_that("#138 - No partial arg matches", {
})
})


test_that("`as_ascii_table() can handle missing datetimes (#132)", {
d1 <- tibble(
id = c(1, 2, 3),
Expand Down