test-r-interop.R 768 B

12345678910111213141516171819202122232425262728293031
  1. test_that("r/ prefix #1", {
  2. res <- llr_test("(r/rnorm 10)")
  3. expect_equal(length(res), 10)
  4. expect_true(is.numeric(res))
  5. })
  6. test_that("r/ package call", {
  7. res <- llr_test("(r/base::abs -10)")
  8. expect_equal(res, 10)
  9. })
  10. test_that("r/ named parameters", {
  11. res <- llr_test("(r/round :x 10.1234 :digits 2)")
  12. expect_equal(res, round(x = 10.1234, digits = 2L), ignore_attr = TRUE)
  13. })
  14. test_that("r/built in stuff", {
  15. expect_equal(llr_test("r/mtcars"), mtcars)
  16. })
  17. test_that("r dplyr works", {
  18. res <- llr_test("
  19. (r/suppressPackageStartupMessages (r/library dplyr :quietly true))
  20. (->
  21. r/datasets::mtcars
  22. (r/dplyr::filter (> hp 100)) ; filter is in std.lib
  23. (r/summarise :count (n) :mean_mpg (mean mpg)))
  24. ")
  25. expect_true(is.data.frame(res))
  26. })