Skip to content

Commit

Permalink
Add test for missing exports
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Aug 21, 2014
1 parent 73783b1 commit 697b03c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/test-namespace.r
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ test_that("Exported objects are visible from global environment", {
unload("testNamespace")
})


test_that("Missing exports don't result in error", {
load_all("testMissingNsObject")
nsenv <- ns_env("testMissingNsObject")
expect_equal(nsenv$a, 1)
unload("testMissingNsObject")
})


test_that("All objects are loaded into namespace environment", {
load_all("testNamespace")
nsenv <- ns_env("testNamespace")
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/testMissingNsObject/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: testMissingNsObject
Title: Tools to make developing R code easier. This package lists 'b' as an
export in NAMESPACE, but the 'b' object doesn't exist.
License: GPL-2
Description:
Version: 0.1
2 changes: 2 additions & 0 deletions tests/testthat/testMissingNsObject/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export(a)
export(b)
1 change: 1 addition & 0 deletions tests/testthat/testMissingNsObject/R/a.r
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a <- 1

0 comments on commit 697b03c

Please sign in to comment.