Documentation
¶
Overview ¶
Exercise provides structures and functions for defining and handling results of exercises.
Exercise provides structures and functions for defining and running exercises.
Index ¶
- type Exercise
- type Result
- func AssertionError(expected string, got string, runTests ...string) (res Result)
- func CompilationError(errorMessage string) (res Result)
- func InternalError(errorMessage string) (res Result)
- func InvalidFileError() (res Result)
- func Passed(message string) (res Result)
- func RuntimeError(errorMessage string, runTests ...string) (res Result)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exercise ¶
type Exercise struct {
Name string // Name is the exercise's display name.
CloneDirectory string
TurnInDirectory string // TurnInDirectory is the directory where the exercise's file(s) can be found, relative to the repository's root.
TurnInFiles []string // TurnInFiles is a list of all files allowed to be submitted.
Score int // Score is the score assigned to the exercise if passed.
Executer func(test *Exercise) Result // Executer is a function used for testing the exercise, which should be implemented by the user.
}
Exercise represents an exercise with various metadata fields.
func NewExercise ¶
func NewExercise( name string, turnInDirectory string, turnInFiles []string, score int, executer func(test *Exercise) Result, ) (exercise Exercise)
NewExercise initializes and returns an Exercise struct with all the necessary data for submission grading.
- name: exercise's display name
- repoDirectory: the target directory for cloning repositories, used to construct filepaths
- turnInDirectory: the directory in which the exercise's file can be found, relative to the repository's root (e.g., ex00/)
- turnInFiles: list of all files allowed to be turned in
- score: score assigned to the exercise if passed
- executer: testing function with this signature: "func(test *Exercise) Result", will be run by the module for grading
type Result ¶
type Result struct {
Passed bool // Passed indicates whether the test was successful.
Output string // Output contains the output message or error details.
}
Result represents the result of an exercise execution, including whether it passed and any relevant output or error messages.
func AssertionError ¶
AssertionError returns a Result indicating that the output of the student's code did not match the expected output.
- expected: The expected output as a string.
- got: The actual output produced by the student's code.
Returns a Result with Passed set to false and a message detailing the discrepancy between expected and actual output in the Output.
func CompilationError ¶
CompilationError returns a Result indicating a compilation error occurred with the provided error message.
- errorMessage: The error message describing the compilation error.
Returns a Result with Passed set to false and the error message included in the Output.
func InternalError ¶
InternalError returns a Result indicating an internal error occurred during the execution of the exercise.
- errorMessage: The error message describing the internal error.
Returns a Result with Passed set to false and the error message included in the Output.
func InvalidFileError ¶
func InvalidFileError() (res Result)
InvalidFileError returns a Result indicating that invalid files were found in the submission.
Returns a Result with Passed set to false and a message indicating the presence of invalid files in the Output.
func Passed ¶
Passed returns a Result indicating that the exercise was successfully completed.
- message: A success message to include in the Output.
Returns a Result with Passed set to true and the success message included in the Output.
func RuntimeError ¶
RuntimeError returns a Result indicating a runtime error occurred with the provided error message.
- errorMessage: The error message describing the runtime error.
Returns a Result with Passed set to false and the error message included in the Output.