Loading static/js/exercises.api.mjs +10 −5 Original line number Diff line number Diff line Loading @@ -182,9 +182,9 @@ class ExerciseExecutionContext { } /** * Verify the completion of the exercise by executing a command and checking * if the output is as expected. If yes, the exercise is treated as completed, * if no, the exercise is treated as failed. * Verify the completion of the exercise by optionally executing a command and checking * if the output is as expected. If yes, the exercise is treated as solved, if no, * the user has to try again. * * Used like this: * Loading @@ -192,6 +192,9 @@ class ExerciseExecutionContext { * this.verify("cat botschaft").hasOutput("Der Junge sieht den Mann mit dem Fernglas.") * ``` * * verify() can also be called without a command, in which case no command is executed – instead * the last command entered by the user (if any) is used. * * When the parameter passed to `hasOutput` is a string, the verification succeeds iff * this string is the first and only line of output of the command. * When the parameter passed to `hasOutput` is a list, the verification succeeds iff Loading @@ -201,7 +204,9 @@ class ExerciseExecutionContext { * @returns An object that has the method "hasOutput" */ verify(command) { if(command) { runCommand(command) } const verifyHandler = this._verifyHandler return { Loading @@ -222,7 +227,7 @@ class ExerciseExecutionContext { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] if (latestEntry.input !== command) { if (command && latestEntry.input !== command) { throw new Error("Could not find expected input in terminal") } Loading Loading
static/js/exercises.api.mjs +10 −5 Original line number Diff line number Diff line Loading @@ -182,9 +182,9 @@ class ExerciseExecutionContext { } /** * Verify the completion of the exercise by executing a command and checking * if the output is as expected. If yes, the exercise is treated as completed, * if no, the exercise is treated as failed. * Verify the completion of the exercise by optionally executing a command and checking * if the output is as expected. If yes, the exercise is treated as solved, if no, * the user has to try again. * * Used like this: * Loading @@ -192,6 +192,9 @@ class ExerciseExecutionContext { * this.verify("cat botschaft").hasOutput("Der Junge sieht den Mann mit dem Fernglas.") * ``` * * verify() can also be called without a command, in which case no command is executed – instead * the last command entered by the user (if any) is used. * * When the parameter passed to `hasOutput` is a string, the verification succeeds iff * this string is the first and only line of output of the command. * When the parameter passed to `hasOutput` is a list, the verification succeeds iff Loading @@ -201,7 +204,9 @@ class ExerciseExecutionContext { * @returns An object that has the method "hasOutput" */ verify(command) { if(command) { runCommand(command) } const verifyHandler = this._verifyHandler return { Loading @@ -222,7 +227,7 @@ class ExerciseExecutionContext { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] if (latestEntry.input !== command) { if (command && latestEntry.input !== command) { throw new Error("Could not find expected input in terminal") } Loading