inst/tinytest/test_hash.R

## hashing ----


expect_true(is.integer(hash(10)))
expect_equal(length(hash(c("aap","noot"))),2L)
expect_equal(length(hash(c("aap","noot"),recursive=FALSE)),1L)
expect_equal(length(hash(list(1,c("aap","noot")))),2L)
expect_equal(length(hash(list(1,c("aap","noot")),recursive=FALSE)),1L)
m <- lm(Sepal.Width ~ Sepal.Length, data=iris)
expect_true(is.integer(hash(m)))
expect_equal(length(hash(m)),1L)
x <- c("call any vegetable","and the chances are good","that the vegetable will respond to you")
L <- strsplit(x," ",fixed=TRUE)
expect_true(all(sapply(hash(L),is.integer)))


m1 <- lm(Sepal.Width ~ Sepal.Length, data=iris)
expect_identical(hash(m1), hash(m))

Try the hashr package in your browser

Any scripts or data that you put into this service are public.

hashr documentation built on Sept. 5, 2021, 6:03 p.m.