From cf0c58b32769e7722ed20c69b7d381cb37db39d0 Mon Sep 17 00:00:00 2001 From: brodieG Date: Sun, 31 Jul 2016 21:39:34 -0400 Subject: [PATCH] complete regression fixes from #49 --- R/core.R | 7 ++++--- tests/testthat/testthat.atomic.R | 12 +++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/R/core.R b/R/core.R index 2a55c7fc..1c08270b 100644 --- a/R/core.R +++ b/R/core.R @@ -388,10 +388,11 @@ line_diff <- function( Map(dat.up, cur.dat, diff.word$cur.dat, MoreArgs=list(ind=cur.rh)) # Mark the lines that were wrapped diffed; necessary b/c tar/cur.rh are - # defined even if other conditions to get in this loop are not + # defined even if other conditions to get in this loop are not, and also + # because the addition of the fill lines moves everything around - tar.wrap.diff <- tar.rh - cur.wrap.diff <- cur.rh + tar.wrap.diff <- seq_along(tar.dat$fill)[!tar.dat$fill][tar.rh] + cur.wrap.diff <- seq_along(cur.dat$fill)[!cur.dat$fill][cur.rh] } # Actual line diff diff --git a/tests/testthat/testthat.atomic.R b/tests/testthat/testthat.atomic.R index 145ccea0..18f56009 100644 --- a/tests/testthat/testthat.atomic.R +++ b/tests/testthat/testthat.atomic.R @@ -37,8 +37,12 @@ test_that("Basic Tests", { ) }) test_that("Word wrap in atomic", { - A <- B <- c(letters, LETTERS) + A <- A.1 <- B <- c(letters, LETTERS) B[15] <- "Alabama" + A.1[5] <- "Ee" + C <- A[-15] + D <- C + E <- B[-45] # Test simple changes to vectors; at 80 columns removing 1:8 corresponds to # row deletion @@ -64,21 +68,15 @@ test_that("Word wrap in atomic", { ) # Different wrap frequency and removed words that span lines - A.1 <- A - A.1[5] <- "Ee" expect_equal_to_reference( as.character(diffPrint(A, A.1[-(13:18)])), rdsf(1425) ) # Removing words - C <- A[-15] expect_equal_to_reference(as.character(diffPrint(C, B)), rdsf(1450)) # Two hunks - D <- C - E <- B[-45] - expect_equal_to_reference(as.character(diffPrint(D, E)), rdsf(1500)) expect_equal_to_reference(as.character(diffPrint(E, D)), rdsf(1600))