Skip to content

Commit

Permalink
Fix test expectations (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutannihilation committed May 3, 2024
1 parent f8e0366 commit 6fc66b5
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions R-package/tests/testthat/test-altrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ test_that("altinteger works", {
expect_equal(as.character(x), c("1", "2", "3")) # coerce method
expect_equal(x, c(1L, 2L, 3L))

# after the first materialization, the values visible to R don't change
# after the first materialization, the values reflect to R's side if invalidate_cache = TRUE
tweak_altint(x)
expect_output(print_altint(x), "MyAltInt([2, 4, 6, 0])", fixed = TRUE)

expect_equal(x[1], 1L) # ELT method
expect_equal(length(x), 3L) # length method
expect_equal(as.character(x), c("1", "2", "3")) # coerce method
expect_equal(x, c(1L, 2L, 3L))
expect_equal(x[1], 2L) # ELT method
expect_equal(length(x), 4L) # length method
expect_equal(as.character(x), c("2", "4", "6", "0")) # coerce method
expect_equal(x, c(2L, 4L, 6L, 0L))

# duplicate method? dataptr method? I'm not sure
x[1] <- 2L
expect_equal(x, c(2L, 2L, 3L))
x[1] <- 10L
expect_equal(x, c(10L, 4L, 6L, 0L))

})

Expand All @@ -29,18 +29,18 @@ test_that("altreal works", {
expect_equal(as.character(x), c("1", "2", "3")) # coerce method
expect_equal(x, c(1, 2, 3))

# after the first materialization, the values visible to R don't change
# after the first materialization, the values reflect to R's side if invalidate_cache = TRUE
tweak_altreal(x)
expect_output(print_altreal(x), "MyAltReal([2.0, 4.0, 6.0, 0.0])", fixed = TRUE)

expect_equal(x[1], 1) # ELT method
expect_equal(length(x), 3L) # length method
expect_equal(as.character(x), c("1", "2", "3")) # coerce method
expect_equal(x, c(1, 2, 3))
expect_equal(x[1], 2) # ELT method
expect_equal(length(x), 4L) # length method
expect_equal(as.character(x), c("2", "4", "6", "0")) # coerce method
expect_equal(x, c(2, 4, 6, 0))

# duplicate method? dataptr method? I'm not sure
x[1] <- 2
expect_equal(x, c(2, 2, 3))
x[1] <- 10
expect_equal(x, c(10, 4, 6, 0))
})

test_that("altlogical works", {
Expand All @@ -51,18 +51,18 @@ test_that("altlogical works", {
expect_equal(as.character(x), c("TRUE", "FALSE", "TRUE")) # coerce method
expect_equal(x, c(TRUE, FALSE, TRUE))

# after the first materialization, the values visible to R don't change
# after the first materialization, the values reflect to R's side if invalidate_cache = TRUE
tweak_altlogical(x)
expect_output(print_altlogical(x), "MyAltLogical([false, true, false, false])", fixed = TRUE)

expect_equal(x[1], TRUE) # ELT method
expect_equal(length(x), 3L) # length method
expect_equal(as.character(x), c("TRUE", "FALSE", "TRUE")) # coerce method
expect_equal(x, c(TRUE, FALSE, TRUE))
expect_equal(x[1], FALSE) # ELT method
expect_equal(length(x), 4L) # length method
expect_equal(as.character(x), c("FALSE", "TRUE", "FALSE", "FALSE")) # coerce method
expect_equal(x, c(FALSE, TRUE, FALSE, FALSE))

# duplicate method? dataptr method? I'm not sure
x[1] <- NA
expect_equal(x, c(NA, FALSE, TRUE))
expect_equal(x, c(NA, TRUE, FALSE, FALSE))
})

test_that("altstring works", {
Expand All @@ -73,16 +73,16 @@ test_that("altstring works", {
expect_equal(as.numeric(x), c(1, 2, 3)) # coerce method
expect_equal(x, c("1", "2", "3"))

# after the first materialization, the values visible to R don't change
# after the first materialization, the values reflect to R's side if invalidate_cache = TRUE
tweak_altstring(x)
expect_output(print_altstring(x), "MyAltString([\"10\", \"20\", \"30\", \"-1\"])", fixed = TRUE)

expect_equal(x[1], "1") # ELT method
expect_equal(length(x), 3L) # length method
expect_equal(as.numeric(x), c(1, 2, 3)) # coerce method
expect_equal(x, c("1", "2", "3"))
expect_equal(x[1], "10") # ELT method
expect_equal(length(x), 4L) # length method
expect_equal(as.numeric(x), c(10, 20, 30, -1)) # coerce method
expect_equal(x, c("10", "20", "30", "-1"))

# duplicate method? dataptr method? I'm not sure
x[1] <- "A"
expect_equal(x, c("A", "2", "3"))
expect_equal(x, c("A", "20", "30", "-1"))
})

0 comments on commit 6fc66b5

Please sign in to comment.