Skip to content

Commit

Permalink
Tests for #86
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Moravec committed Jan 18, 2024
1 parent 43c4365 commit d269675
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_import/module_S3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
1 change: 1 addition & 0 deletions tests/test_import/test_S3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d269675

Please sign in to comment.