R Under development (unstable) (2025-04-19 r88162 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > NAME <- "diffObj" > source(file.path('_helper', 'init.R')) > > # - simple diffobj ------------------------------------------------------------- > > # no diff for print > all.equal(as.character(diffObj(iris.s, iris.c)), rdsf(100)) [1] TRUE > # no diff for str > all.equal( + as.character(diffObj(1:100, c(1:99, 200L))), rdsf(200) + ) [1] TRUE > # diffs for both and must pick one, first one is str, second is print > all.equal( + as.character(diffObj(mdl1[7], mdl2[7])), rdsf(300) + ) [1] TRUE > all.equal(as.character(diffObj(mdl1, mdl2)), rdsf(400)) [1] TRUE > > # - fits or doesn't ------------------------------------------------------------ > > # Note, the first test used to favor str until we handicapped print > all.equal( + diffObj(matrix(1:20, ncol=2), matrix(2:21, ncol=2), line.limit=5)@capt.mode, + "str" + ) [1] TRUE > # test kinda slow, would be better to have one with smaller objects with print > # methods > > all.equal( + diffObj(mdl1, mdl2, line.limit=15, mode='unified')@capt.mode, "print" + ) [1] TRUE > all.equal(diffObj(1:1000, 1000:1, line.limit=5)@capt.mode, "str") [1] TRUE > > # - misc ----------------------------------------------------------------------- > > try(diffObj(1, 2, extra=list(TRUE))) # "extra" Error in .local(target, current, ...) : Argument `extra` must be empty in `diffObj`. > > # - print error ---------------------------------------------------------------- > > x <- structure("hello", class="diffobj_ogewlhgiadfl") > y <- structure("goodbye", class="diffobj_ogewlhgiadfl") > try(diffObj(x, y)) # "Error in calling .diffPrint." Error in print.diffobj_ogewlhgiadfl(structure("goodbye", class = "diffobj_ogewlhgiadfl")) : failure Error in diffObj(target = x, current = y) : Error in calling `diffPrint`: Failed attempting to get text representation of object: failure > > # Random exmaples to think through `diffObj` output > > diffObj( + pairlist("`logical(2L)` should be length 2 (is 3)"), + pairlist("be length 2 (is 3)") + ) < pairlist("`logical(2L)` should be l.. > pairlist("be length 2 (is 3)") @@ 1,3 @@  @@ 1,3 @@  [[1]] [[1]] < [1] "`logical(2L)` should be length 2 > [1] "be length 2 (is 3)" :  (is 3)" ~ > > diffObj( + pairlist("`matrix(integer(), nrow = 3)` should be matrix (is list)", "`list(character(1L), 1L)[[2]]` should be type \"integer-like\" (is \"character\")"), + pairlist("be class \"matrix\" (is \"list\")", "be type \"integer-like\" (is \"character\") at index [[2]]") + ) < pairlist("`matrix(integer(), nrow =.. > pairlist("be class \"matrix\" (is \.. @@ 1,6 @@  @@ 1,6 @@  [[1]] [[1]] < [1] "`matrix(integer(), nrow = 3)` sh > [1] "be class \"matrix\" (is \"list\" : ould be matrix (is list)" : )" [[2]] [[2]] < [1] "`list(character(1L), 1L)[[2]]` s > [1] "be type \"integer-like\" (is \"c : hould be type \"integer-like\" (is \" : haracter\") at index [[2]]" : character\")" ~ > > proc.time() user system elapsed 2.71 0.18 3.71