nealrichardson commented on a change in pull request #8579:
URL: https://github.com/apache/arrow/pull/8579#discussion_r520072414



##########
File path: r/tests/testthat/test-Table.R
##########
@@ -179,10 +183,34 @@ test_that("[[<- assignment", {
   # can use $
   tab$new <- NULL
   expect_null(as.vector(tab$new))
-  expect_identical(dim(tab), c(10L, 5L))
+  expect_identical(dim(tab), c(10L, 4L))
 
   tab$int <- 1:10
   expect_vector(tab$int, 1:10)
+
+  # recycling
+  tab[["atom"]] <- 1L
+  expect_vector(tab[["atom"]], rep(1L, 10))
+
+  expect_error(
+    tab[["atom"]] <- 1:6,
+    paste0(
+      "Invalid: Added column's length must match table's length. ",
+      "Expected length 10 but got length 6"
+    )
+  )
+
+  # assign Arrow array and chunked_array
+  array <- Array$create(c(10:1))
+  tab$array <- array
+  expect_vector(tab$array, 10:1)
+
+  tab$chunked <- chunked_array(1:10)
+  expect_vector(tab$chunked, 1:10)
+
+  # nonsense indexes
+  expect_error(tab[[NA]] <- letters[10:1], "missing value where TRUE/FALSE 
needed")
+  expect_error(tab[[NULL]] <- letters[10:1], "argument is of length zero")

Review comment:
       Oh nice, I've been bitten by that before, so I guess either I was using 
`int` instead of `R_xlen_t` or `Rcpp` wasn't as helpful. TIL :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to