Loading static/js/exercises.api.mjs +6 −2 Original line number Diff line number Diff line Loading @@ -246,6 +246,8 @@ class ExerciseExecutionContext { // if no command is provided, directly start with a resolved promise. const commandPromise = command ? runCommand(command) : Promise.resolve() const verifyHandler = this._verifyHandler // TODO This won't work if the user is already retrying the exercise, because then the public clear API is disabled const clear = this.clear.bind(this) return { /** Loading @@ -260,7 +262,7 @@ class ExerciseExecutionContext { */ hasOutput(param) { // Wait until the VM has processed the input and written some output to the terminal commandPromise.then(() => { commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] Loading @@ -278,6 +280,7 @@ class ExerciseExecutionContext { // !! converts any value to a boolean (not a special operator, just two ! (boolean not) operators in series) const result = !!predicate(latestEntry.output) await clear() verifyHandler(result) }) }, Loading @@ -292,7 +295,7 @@ class ExerciseExecutionContext { * @param {Function|String} param String to exactly match, or predicate function */ commandWas(param) { commandPromise.then(() => { commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] Loading @@ -304,6 +307,7 @@ class ExerciseExecutionContext { const result = !!predicate(latestEntry.input) await clear() verifyHandler(result) }) } Loading Loading
static/js/exercises.api.mjs +6 −2 Original line number Diff line number Diff line Loading @@ -246,6 +246,8 @@ class ExerciseExecutionContext { // if no command is provided, directly start with a resolved promise. const commandPromise = command ? runCommand(command) : Promise.resolve() const verifyHandler = this._verifyHandler // TODO This won't work if the user is already retrying the exercise, because then the public clear API is disabled const clear = this.clear.bind(this) return { /** Loading @@ -260,7 +262,7 @@ class ExerciseExecutionContext { */ hasOutput(param) { // Wait until the VM has processed the input and written some output to the terminal commandPromise.then(() => { commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] Loading @@ -278,6 +280,7 @@ class ExerciseExecutionContext { // !! converts any value to a boolean (not a special operator, just two ! (boolean not) operators in series) const result = !!predicate(latestEntry.output) await clear() verifyHandler(result) }) }, Loading @@ -292,7 +295,7 @@ class ExerciseExecutionContext { * @param {Function|String} param String to exactly match, or predicate function */ commandWas(param) { commandPromise.then(() => { commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] Loading @@ -304,6 +307,7 @@ class ExerciseExecutionContext { const result = !!predicate(latestEntry.input) await clear() verifyHandler(result) }) } Loading