Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test expectations #230

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))
})
Loading