From d269675ca0e9aef3150787553e35ff92cec1a141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Moravec?= Date: Fri, 19 Jan 2024 11:31:22 +1300 Subject: [PATCH] Tests for #86 --- tests/test_import/module_S3.R | 5 +++++ tests/test_import/test_S3.R | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/test_import/module_S3.R b/tests/test_import/module_S3.R index 3258003..0d55b44 100644 --- a/tests/test_import/module_S3.R +++ b/tests/test_import/module_S3.R @@ -16,3 +16,8 @@ test_fun.numeric <- function(x){ print.test_class <- function(x){ print(as.character(x)) } + +# a method for class with dot in name +test_fun.data.frame = function(x){ + structure("data.frame", class = "test_class") + } diff --git a/tests/test_import/test_S3.R b/tests/test_import/test_S3.R index 7e4c5f1..10da865 100644 --- a/tests/test_import/test_S3.R +++ b/tests/test_import/test_S3.R @@ -29,6 +29,7 @@ test_that("S3 methods are registered", { expect_silent( import::from("module_S3.R", "test_fun", .S3=TRUE) ) expect_identical( test_fun(1), structure("numeric", class="test_class") ) expect_identical( test_fun("1"), structure("character", class="test_class") ) + expect_identical( test_fun(data.frame()), structure("data.frame", class="test_class")) expect_output( print(test_fun(1)), "numeric" ) expect_output( print(test_fun("OK")), "character" ) cleanup_environment()