-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: why is enumerate breaking things
- Loading branch information
1 parent
e449f99
commit e13aa17
Showing
10 changed files
with
325 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Mac", | ||
"includePath": [ | ||
"${workspaceFolder}/**", | ||
"/Library/Frameworks/R.framework/Resources/include" | ||
], | ||
"defines": [], | ||
"macFrameworkPath": [ | ||
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" | ||
], | ||
"compilerPath": "/usr/bin/clang", | ||
"cStandard": "c17", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "macos-clang-arm64", | ||
"compilerArgs": [ | ||
"-I/Library/Frameworks/R.framework/Resources/include" | ||
] | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"files.associations": { | ||
"CMake*.txt": "cmake", | ||
"r.h": "c", | ||
"rdynload.h": "c", | ||
"rinternals.h": "c", | ||
"__node_handle": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
|
||
`__ffi__enumerate` <- function(x, f, ..., FUN.VALUE = NULL) { | ||
|
||
f <- match.fun(f) | ||
|
||
.Call( | ||
"renv_ffi__enumerate", | ||
x, | ||
FUN.VALUE, | ||
environment(), | ||
PACKAGE = "renv" | ||
) | ||
|
||
} | ||
|
||
`__ffi__renv_call_expect` <- function(node, package, methods) { | ||
|
||
.Call( | ||
"renv_ffi__renv_call_expect", | ||
node, | ||
as.character(package), | ||
as.character(methods), | ||
PACKAGE = "renv" | ||
) | ||
|
||
} | ||
|
||
`__ffi__renv_dependencies_recurse` <- function(object, callback) { | ||
|
||
symbol <- as.symbol(names(formals(args(callback)))[[1L]]) | ||
envir <- new.env(parent = environment(callback)) | ||
expr <- body(callback) | ||
envir <- new.env(parent = environment(callback)) | ||
|
||
.Call( | ||
"renv_ffi_recurse", | ||
"renv_ffi__renv_dependencies_recurse", | ||
object, | ||
symbol, | ||
expr, | ||
envir, | ||
PACKAGE = .packageName | ||
PACKAGE = "renv" | ||
) | ||
|
||
} | ||
|
||
`__ffi__renv_call_expect` <- function(node, package, methods) { | ||
.Call( | ||
"renv_ffi_call_expect", | ||
node, | ||
as.character(package), | ||
as.character(methods), | ||
PACKAGE = .packageName | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
test_that("enumerate() works as expected", { | ||
|
||
zip <- function(key, value) list(key, value) | ||
|
||
data <- list(a = 1, b = 2, c = 3) | ||
actual <- enumerate(data, zip) | ||
expected <- list(a = list("a", 1), b = list("b", 2), c = list("c", 3)) | ||
expect_identical(actual, expected) | ||
|
||
data <- list(a = "1", b = "2", c = "3") | ||
actual <- enumerate(data, zip) | ||
expected <- list(a = list("a", "1"), b = list("b", "2"), c = list("c", "3")) | ||
expect_identical(actual, expected) | ||
|
||
}) | ||
|
||
test_that("enumerate() handles dots", { | ||
|
||
values <- list() | ||
data <- list(a = 1, b = 2, c = 3) | ||
enumerate(data, function(key, value, extra) { | ||
values[[length(values) + 1L]] <<- list(key, value, extra) | ||
}, extra = TRUE) | ||
|
||
expect_identical(values, list( | ||
list("a", 1, TRUE), | ||
list("b", 2, TRUE), | ||
list("c", 3, TRUE) | ||
)) | ||
|
||
}) | ||
|
||
test_that("enum_chr() does what it should", { | ||
|
||
actual <- enum_chr( | ||
list(a = "1", b = "2", c = "3"), | ||
function(key, value) value | ||
) | ||
|
||
expected <- c(a = "1", b = "2", c = "3") | ||
expect_identical(actual, expected) | ||
|
||
actual <- enum_chr( | ||
list(1, 2, 3), | ||
function(key, value) value | ||
) | ||
|
||
expected <- c("1", "2", "3") | ||
expect_identical(actual, expected) | ||
|
||
}) |
Oops, something went wrong.