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 <- "summary" 19> source(file.path('_helper', 'init.R')) 20> 21> # Note, atomic prints happen in different test file 22> 23> # - Any ------------------------------------------------------------------------ 24> 25> identical(any(diffPrint(iris.s, iris.s)), FALSE) 26[1] TRUE 27> res <- any(diffPrint(iris.s, iris.c)) # warn: "objects are NOT" 28Warning message: 29No visible differences, but objects are NOT `all.equal`. 30> identical(res, FALSE) 31[1] TRUE 32> isTRUE(any(diffPrint(iris.s, iris.4))) 33[1] TRUE 34> 35> 36> # - Small Summary -------------------------------------------------------------- 37> 38> all.equal( 39+ as.character(summary(diffPrint(iris.s, iris.4))), rdsf(100) 40+ ) 41[1] TRUE 42> all.equal( 43+ as.character(summary(diffPrint(iris.s, iris.2))), rdsf(200) 44+ ) 45[1] TRUE 46> all.equal( 47+ as.character(summary(diffPrint(iris.s, iris.3))), rdsf(300) 48+ ) 49[1] TRUE 50> all.equal( 51+ as.character(summary(diffPrint(iris.s, iris.c))), rdsf(400) 52+ ) 53[1] TRUE 54> # All equal 55> 56> all.equal( 57+ as.character(summary(diffChr(letters, letters))), rdsf(450) 58+ ) 59[1] TRUE 60> 61> # - Big Summary ---------------------------------------------------------------- 62> 63> # Make sure we test summary reduction, wrapping 64> 65> all.equal( 66+ as.character(summary(diffChr(chr.7, chr.8))), rdsf(500) 67+ ) 68[1] TRUE 69> all.equal( 70+ as.character(summary(diffChr(chr.7, chr.8), scale.threshold=1)), rdsf(600) 71+ ) 72[1] TRUE 73> all.equal( 74+ as.character(summary(diffChr(chr.7, chr.8), scale.threshold=0)), rdsf(700) 75+ ) 76[1] TRUE 77> # Force truncation of summary 78> all.equal( 79+ as.character( 80+ summary(diffChr(chr.7, chr.8), scale.threshold=0, max.lines=2) 81+ ), 82+ rdsf(800) 83+ ) 84[1] TRUE 85> 86> # - Show ----------------------------------------------------------------------- 87> 88> isTRUE( 89+ paste0(capture.output(summary(diffChr(chr.7, chr.8))), collapse="\n") == 90+ as.character(summary(diffChr(chr.7, chr.8))) 91+ ) 92[1] TRUE 93> 94> # - HTML summary --------------------------------------------------------------- 95> 96> all.equal( 97+ as.character( 98+ summary( 99+ diffPrint( 100+ iris.s, iris.4, format="html", style=list(html.output="page") 101+ ) ) ), 102+ rdsf(900) 103+ ) 104[1] TRUE 105> 106> # - errors --------------------------------------------------------------------- 107> 108> diff <- diffChr("hello green world", "hello red world") 109> try(summary(diff, max.lines=0)) # "strictly positive" 110Error in .local(object, ...) : 111 Argument `max.lines` must be integer(1L) and strictly positive 112> try(summary(diff, width=1:3)) # "integer\\(1L\\)" 113Error in .local(object, ...) : 114 Argument `width` must be integer(1L) and positive 115> try(summary(diff, scale.threshold=5)) # "between 0 and 1" 116Error in .local(object, ...) : 117 Argument `scale.threshold` must be numeric(1L) between 0 and 1 118> 119> # - width wrap ----------------------------------------------------------------- 120> 121> diff <- diffChr("hello green world", "hello red world", format='raw') 122> all.equal(capture.output(show(summary(diff, width=5))), txtf(100)) 123[1] TRUE 124> 125> 126> proc.time() 127 user system elapsed 128 3.413 0.271 3.813 129