1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
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 <- "limit"
> source(file.path('_helper', 'init.R'))
>
> # - Simple limit ---------------------------------------------------------------
>
> A <- B <- letters[1:5]
> B[2] <- "B"
> B[6] <- "F"
> # diffChr(A, B)
> all.equal(as.character(diffChr(A, B, line.limit=2)), rdsf(100))
[1] TRUE
> all.equal(as.character(diffChr(A, B, line.limit=3)), rdsf(200))
[1] TRUE
>
> # - More Extensive Limits ------------------------------------------------------
>
> Puromycin2 <- Puromycin
> set.seed(1)
> Puromycin2$conc[c(8, 15:19, 22)] <- round(runif(7), 2)
> Puromycin2$state[17] <- "treated"
>
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin2, line.limit=15, mode="sidebyside")
+ ),
+ rdsf(300)
+ )
[1] TRUE
>
> # # Not working right
> # diffPrint(Puromycin, Puromycin2, line.limit=15, mode="context")
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin2, line.limit=15, mode="unified")
+ ),
+ rdsf(500)
+ )
[1] TRUE
>
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin2, line.limit=5, mode="sidebyside")
+ ),
+ rdsf(600)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin2, line.limit=5, mode="context")
+ ),
+ rdsf(700)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin2, line.limit=5, mode="unified")
+ ),
+ rdsf(800)
+ )
[1] TRUE
>
> Puromycin3 <- Puromycin2
> names(Puromycin3)[3L] <- "blargh"
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin3, line.limit=7, mode="sidebyside")
+ ),
+ rdsf(900)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(Puromycin, Puromycin3, line.limit=6, mode="context")
+ ),
+ rdsf(1000)
+ )
[1] TRUE
> # - Dual limit values ----------------------------------------------------------
>
> A <- letters[1:10]
> B <- LETTERS[1:10]
> all.equal(
+ as.character(diffChr(A, B, line.limit=c(10, 3))), rdsf(1100)
+ )
[1] TRUE
> all.equal(
+ as.character(diffChr(A, B, line.limit=c(13, 3))), rdsf(1200)
+ )
[1] TRUE
> try(diffChr(A, B, line.limit=c(3, 13))) # "larger than or"
Error in diffChr(target = A, current = B, line.limit = c(3, 13)) :
Argument `line.limit` must be an integer vector of length 1 or 2 and if length 2, with the first value larger than or equal to the second, or "auto" or the result of calling `auto_line_limit`
>
> # - Cause errors ---------------------------------------------------------------
>
> try(diffChr(letters, LETTERS, line.limit=1:3)) # "vector of length"
Error in diffChr(target = letters, current = LETTERS, line.limit = 1:3) :
Argument `line.limit` must be an integer vector of length 1 or 2 and if length 2, with the first value larger than or equal to the second, or "auto" or the result of calling `auto_line_limit`
>
> # - Vanishing header -----------------------------------------------------------
>
> # issue 64
> all.equal(
+ as.character(
+ diffChr(
+ letters, letters[-13], context=auto_context(0, 10), line.limit=1L,
+ pager="off"
+ ) ),
+ rdsf(1300)
+ )
[1] TRUE
>
>
> proc.time()
user system elapsed
2.005 0.211 2.256
|