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

Arguments are not standardized if passed through ... from a map function to a function defined in setup code or user code #349

Closed
rossellhayes opened this issue May 15, 2023 · 0 comments · Fixed by #350
Assignees
Labels
bug Something isn't working

Comments

@rossellhayes
Copy link
Contributor

rossellhayes commented May 15, 2023

library(gradethis)

# Arguments passed to package functions are standardized
with_exercise(
  mock_this_exercise(
    .user_code = "purrr::map(1:10, rnorm, 1)",
    .solution_code = "purrr::map(1:10, rnorm, mean = 1)"
  ),
  code_feedback()
)
#> NULL

# Arguments passed to functions defined in setup aren't
with_exercise(
  mock_this_exercise(
    .user_code = "purrr::map(1:10, foo, 1)",
    .solution_code = "purrr::map(1:10, foo, baz = 1)",
    setup_exercise = foo <- function(bar, baz) bar + baz
  ),
  code_feedback()
)
#> Your call to `purrr::map()` should include `"baz"` as one of its arguments. You may have misspelled an argument name, or left out an important argument.

# Arguments passed to functions defined in user code aren't
with_exercise(
  mock_this_exercise(
    .user_code = "
          foo <- function(bar, baz) bar + baz
          purrr::map(1:10, foo, 2)
        ",
    .solution_code = "
          foo <- function(bar, baz) bar + baz
          purrr::map(1:10, foo, baz = 2)
        "
  ),
  code_feedback()
)
#> Your call to `purrr::map()` should include `"baz"` as one of its arguments. You may have misspelled an argument name, or left out an important argument.

Created on 2023-05-15 with reprex v2.0.2

@rossellhayes rossellhayes added the bug Something isn't working label May 15, 2023
@rossellhayes rossellhayes self-assigned this May 15, 2023
@rossellhayes rossellhayes changed the title Arguments are not standardized if passed through ... from a map function to a function defined in setup code Arguments are not standardized if passed through ... from a map function to a function defined in setup code or user code May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant