Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reproducible code utils functions test #56

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion tests/testthat/test-reproducible_code_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,31 @@ test_that("pair_seq always returns a strictly increasing sequence of integers",

# Expect numeric output
expect_true(is.numeric(result))

expect_type(result, "double")
# Expect output is in strictly ascending order
expect_true(all(diff(result) > 0))

})

test_that("parse_func_expr returns an empty expression when func is NULL", {
expect_equal(parse_func_expr(NULL),
quote({}))
})

test_that("func_to_expr returns an empty expression when func is NULL", {
expect_equal(func_to_expr(NULL,"test"),
quote({}))
})

test_that("func_to_expr returns a language object that includes the specified function name", {
test_fun_one <- function() {
val <- a + 1
val
}
syroBx marked this conversation as resolved.
Show resolved Hide resolved
name <- "simple_func_name"
result <- func_to_expr(test_fun_one, name)

expect_type(result,"language")
expect_equal(as.character(result[2]), name)
})

Loading