diff --git a/tests/testthat/test-add_command.R b/tests/testthat/test-add_command.R new file mode 100644 index 0000000..d3ff145 --- /dev/null +++ b/tests/testthat/test-add_command.R @@ -0,0 +1,15 @@ +context("User-defined commands") + +test_that("Adding user commands works", { + nsenv <- getNamespace('ado') + pkgenv <- as.environment('package:ado') + + cmd <- function(expression) { return(as.character(expression)) } + + expect_false('testprint' %in% ls(envir=nsenv)) + + ado(string='addCommand cmd, newname(testprint)') + + expect_true('ado_cmd_testprint' %in% ls(envir=nsenv && + 'ado_cmd_testprint' %not_in% ls(envir=pkgenv))) +})