Skip to content

This function is not intended to be used within grading code, but may be helpful for testing grading code.

Usage

with_exercise(exercise, expr)

Arguments

exercise

An exercise, as created by mock_this_exercise()

expr

An unquoted expression

Value

The value of grade_this(<expr>)(exercise)

Examples

exercise <- mock_this_exercise(.user_code = "2", .solution_code = "1 + 1")

with_exercise(exercise, pass_if_equal())
#> <gradethis_graded: [Correct]
#>   That's a first-class answer! Correct!
#> >
with_exercise(exercise, fail_if_code_feedback())
#> <gradethis_graded: [Incorrect]
#>   I expected `+` where you wrote `2`.
#> >