Skip to content

Commit

Permalink
Moved tests location
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwargo committed Feb 19, 2016
1 parent 4e1314b commit 0888686
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.Rproj.user
.Rhistory
.RData
playground
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: lrequire
Type: Package
Title: Sources an R File with Caching, Exporting Specified Variables
Version: 0.1
Date: 2016-02-14
Title: Sources and Encapsulates an R "Module" with Caching, Exposing Only Specified Variables
Version: 0.1.1
Date: 2016-02-19
Author: Rick Wargo <lrequire@rickwargo.com>
Maintainer: Rick Wargo <lrequire@rickwargo.com>
Description: In the fashion of 'node.js' <https://nodejs.org/>, requires a file,
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(append.module.paths)
export(find.first.R)
export(get.module.cache)
export(get.module.paths)
export(lrequire)
export(remove.from.module.cache)
export(remove.module.paths)
export(reset.module.cache)
export(show.module.cache)
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Version 0.1.0
Version 0.1.1
- CRAN release (Initial)
2 changes: 1 addition & 1 deletion R/lrequire.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#' @author Rick Wargo, \email{lrequire@rickwargo.com}
#'
#' @examples
#' say.hello.to <- lrequire('../lrequire/R/tests/example-hello')
#' say.hello.to <- lrequire('../lrequire/tests/example-hello')
#' say.hello.to('Rick')
#'
#' @export
Expand Down
5 changes: 2 additions & 3 deletions R/showcache.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#'
#' @examples
#' show.module.cache()
#' show.module.cache(all.names = TRUE)
show.module.cache <- function(all.names = FALSE) {
for (v in ls(module.cache, all.names = all.names)) {
print(paste('Env:', v, '<-', module.cache[[v]]))
}
ls.str(module.cache, all.names = all.names)
}
16 changes: 1 addition & 15 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
* RStudio 0.99.491

## R CMD check results
There were no ERRORs or WARNINGs.

There was 1 NOTE:

* checking R code for possible problems ... NOTE
lrequire : <anonymous>: no visible binding for global variable
‘module.exports’
lrequire : <anonymous>: no visible binding for global variable
‘exports’

### Explanation
Both module.exports and exports are defined as global variables, but really local to the
source file being lrequire'd. The function of lrequire is to take the variables specified
by the module.exports (or exports) list and make them, and only them, visible to the caller.
This behavior operates as intended.
There were no ERRORs, WARNINGs, or NOTEs.

## Downstream dependencies

Expand Down
2 changes: 1 addition & 1 deletion man/lrequire.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/show.module.cache.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions tests/runtests.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# No testing harness so as to not require additional packages
# These tests may test more than a single piece of functionality

library(lrequire)

# actual tests are located in tests sub directory
append.module.paths('tests', 0)

tst1 <- lrequire(test1)
tst2.sum <- lrequire(test2)
tst3 <- lrequire(test3)
Expand Down Expand Up @@ -57,10 +62,10 @@ if (tst3$sum(1, 2) != 3) {
}

# test4 -- tests module.change_code, caching, and simplifying lrequire arguments to ensure they point to the same file
source('test4.R')
source('tests/test4.R')

# test5 -- tests module.cache and associated functions
source('test5.R')
source('tests/test5.R')

# test6 -- tests modules.path and associated functions
source('test6.R')
source('tests/test6.R')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 22 additions & 22 deletions tests/test6.R → tests/tests/test6.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@ orig.path <- get.module.paths()

# test getting of modules.path
path <- get.module.paths()
len5 <- length(path)
if (len5 != 5) {
print('test6.1: failed -- length(path) != 5')
len <- length(path)
if (len != length(orig.path)) {
print('test6.1: failed -- length(path) != orig.length')
} else {
print('test6.1: succeeded')
}

# test append to end
append.module.paths("/")
path <- get.module.paths()
len6 <- length(path)
if (len6 != 6) {
print('test6.2.1: failed -- length(path) != 6')
len <- length(path)
if (len != length(orig.path)+1) {
print('test6.2.1: failed -- length(path) != orig.length+1')
} else {
print('test6.2.1: succeeded')
}
if (path[6] != "/") {
print('test6.2.2: failed -- path[6] != "/"')
if (path[length(orig.path)+1] != "/") {
print('test6.2.2: failed -- path[orig.length+1] != "/"')
} else {
print('test6.2.2: succeeded')
}

# test remove (of recently appended path)
remove.module.paths(6)
remove.module.paths(length(orig.path)+1)
path <- get.module.paths()
len5 <- length(path)
if (len5 != 5) {
print('test6.3.1: failed -- length(path) != 5')
len <- length(path)
if (len != length(orig.path)) {
print('test6.3.1: failed -- length(path) != orig.length')
} else {
print('test6.3.1: succeeded')
}
Expand All @@ -42,24 +42,24 @@ if (!all.equal(orig.path, path)) {
# test append to front
append.module.paths("/", 0)
path <- get.module.paths()
len6 <- length(path)
if (len6 != 6) {
print('test6.4.1: failed -- length(path) != 6')
len <- length(path)
if (len != length(orig.path)+1) {
print('test6.4.1: failed -- length(path) != orig.length+1')
} else {
print('test6.4.1: succeeded')
}
if (path[1] != "/") {
print('test6.4.2: failed -- path[6] != "/"')
print('test6.4.2: failed -- path[orig.length+1] != "/"')
} else {
print('test6.4.2: succeeded')
}

# test append to middle
append.module.paths("/", 3)
path <- get.module.paths()
len7 <- length(path)
if (len7 != 7) {
print('test6.5.1: failed -- length(path) != 7')
len <- length(path)
if (len != length(orig.path)+2) {
print('test6.5.1: failed -- length(path) != orig.length+2')
} else {
print('test6.5.1: succeeded')
}
Expand All @@ -72,9 +72,9 @@ if (path[4] != "/") {
# test remove (of multiple paths)
remove.module.paths(1, 4)
path <- get.module.paths()
len5 <- length(path)
if (len5 != 5) {
print('test6.6.1: failed -- length(path) != 5')
len <- length(path)
if (len != length(orig.path)) {
print('test6.6.1: failed -- length(path) != orig.length')
} else {
print('test6.6.1: succeeded')
}
Expand Down

0 comments on commit 0888686

Please sign in to comment.