1 2R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" 3Copyright (C) 2020 The R Foundation for Statistical Computing 4Platform: x86_64-apple-darwin17.0 (64-bit) 5 6R is free software and comes with ABSOLUTELY NO WARRANTY. 7You are welcome to redistribute it under certain conditions. 8Type 'license()' or 'licence()' for distribution details. 9 10R is a collaborative project with many contributors. 11Type 'contributors()' for more information and 12'citation()' on how to cite R or R packages in publications. 13 14Type 'demo()' for some demos, 'help()' for on-line help, or 15'help.start()' for an HTML browser interface to help. 16Type 'q()' to quit R. 17 18> NAME <- "diffObj" 19> source(file.path('_helper', 'init.R')) 20> 21> # - simple diffobj ------------------------------------------------------------- 22> 23> # no diff for print 24> all.equal(as.character(diffObj(iris.s, iris.c)), rdsf(100)) 25[1] TRUE 26> # no diff for str 27> all.equal( 28+ as.character(diffObj(1:100, c(1:99, 200L))), rdsf(200) 29+ ) 30[1] TRUE 31> # diffs for both and must pick one, first one is str, second is print 32> all.equal( 33+ as.character(diffObj(mdl1[7], mdl2[7])), rdsf(300) 34+ ) 35[1] TRUE 36> all.equal(as.character(diffObj(mdl1, mdl2)), rdsf(400)) 37[1] TRUE 38> 39> # - fits or doesn't ------------------------------------------------------------ 40> 41> # Note, the first test used to favor str until we handicapped print 42> all.equal( 43+ diffObj(matrix(1:20, ncol=2), matrix(2:21, ncol=2), line.limit=5)@capt.mode, 44+ "str" 45+ ) 46[1] TRUE 47> # test kinda slow, would be better to have one with smaller objects with print 48> # methods 49> 50> all.equal( 51+ diffObj(mdl1, mdl2, line.limit=15, mode='unified')@capt.mode, "print" 52+ ) 53[1] TRUE 54> all.equal(diffObj(1:1000, 1000:1, line.limit=5)@capt.mode, "str") 55[1] TRUE 56> 57> # - misc ----------------------------------------------------------------------- 58> 59> try(diffObj(1, 2, extra=list(TRUE))) # "extra" 60Error in .local(target, current, ...) : 61 Argument `extra` must be empty in `diffObj`. 62> 63> # - print error ---------------------------------------------------------------- 64> 65> x <- structure("hello", class="diffobj_ogewlhgiadfl") 66> y <- structure("goodbye", class="diffobj_ogewlhgiadfl") 67> try(diffObj(x, y)) # "Error in calling .diffPrint." 68Error in print.diffobj_ogewlhgiadfl(structure("goodbye", class = "diffobj_ogewlhgiadfl")) : 69 failure 70Error in diffObj(target = x, current = y) : 71 Error in calling `diffPrint`: Failed attempting to get text representation of object: failure 72> 73> # Random exmaples to think through `diffObj` output 74> 75> diffObj( 76+ pairlist("`logical(2L)` should be length 2 (is 3)"), 77+ pairlist("be length 2 (is 3)") 78+ ) 79[33m<[39m [33mpairlist("`logical(2L)` should be l..[39m [34m>[39m [34mpairlist("be length 2 (is 3)")[39m 80[36m@@ 1,3 @@ [39m [36m@@ 1,3 @@ [39m 81 [90m[39m[[1]][90m[39m [90m[39m[[1]][90m[39m 82[33m<[39m [90m[1] [39m[33m"`logical(2L)` should be length 2[39m[90m[39m [34m>[39m [90m[1] [39m[34m"be length 2 (is 3)"[39m[90m[39m 83[33m:[39m [90m[39m[33m (is 3)"[39m[90m[39m [90m~[39m 84 85> 86> diffObj( 87+ pairlist("`matrix(integer(), nrow = 3)` should be matrix (is list)", "`list(character(1L), 1L)[[2]]` should be type \"integer-like\" (is \"character\")"), 88+ pairlist("be class \"matrix\" (is \"list\")", "be type \"integer-like\" (is \"character\") at index [[2]]") 89+ ) 90[33m<[39m [33mpairlist("`matrix(integer(), nrow =..[39m [34m>[39m [34mpairlist("be class \"matrix\" (is \..[39m 91[36m@@ 1,6 @@ [39m [36m@@ 1,6 @@ [39m 92 [90m[39m[[1]][90m[39m [90m[39m[[1]][90m[39m 93[33m<[39m [90m[1] [39m[33m"`matrix(integer(), nrow = 3)` sh[39m[90m[39m [34m>[39m [90m[1] [39m[34m"be class \"matrix\"[39m [34m(is[39m [34m\[39m[34m"[39m[34mlist[39m[34m\[39m[34m"[39m[34m[39m[34m[39m[90m[39m 94[33m:[39m [90m[39m[33mould be matrix (is list)"[39m[90m[39m [34m:[39m [90m[39m[34m[39m[34m[39m[34m[39m[34m[39m[34m[39m[34m[39m[34m[39m[34m)[39m[34m"[39m[90m[39m 95 96 [90m[39m[[2]][90m[39m [90m[39m[[2]][90m[39m 97[33m<[39m [90m[1] [39m[33m"`list(character(1L), 1L)[[2]]` s[39m[90m[39m [34m>[39m [90m[1] [39m[34m"be type \"integer-like\"[39m (is \"c[34m[39m[34m[39m[34m[39m[90m[39m 98[33m:[39m [90m[39m[33mhould be type \"integer-like\"[39m (is \"[90m[39m [34m:[39m [90m[39m[34m[39mharacter\") [34mat[39m [34mindex[39m [34m[[2]][39m"[90m[39m 99[33m:[39m [90m[39m[33m[39mcharacter\")"[90m[39m [90m~[39m 100 101> 102> proc.time() 103 user system elapsed 104 3.252 0.326 3.687 105