Loading static/js/exercises.api.mjs +23 −13 Original line number Diff line number Diff line Loading @@ -283,9 +283,13 @@ class ExerciseExecutionContext { // Wait until the VM has processed the input and written some output to the terminal commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] if (command && latestEntry.input !== command) { // We start by assuming the result was a failure... let result = false // ... then, check every entry in the terminal (starting from the last) to see if we can be convinced otherwise for(const entry of terminalContents.toReversed()) { if (command && entry.input !== command) { throw new Error("Could not find expected input in terminal") } Loading @@ -297,8 +301,14 @@ class ExerciseExecutionContext { }[typeof param] // !! converts any value to a boolean (not a special operator, just two ! (boolean not) operators in series) const result = !!predicate(latestEntry.output || []) result = !!predicate(entry.output || []) if(result) { break } } // After that is done, return the result await clear() verifyHandler(result) }) Loading Loading
static/js/exercises.api.mjs +23 −13 Original line number Diff line number Diff line Loading @@ -283,9 +283,13 @@ class ExerciseExecutionContext { // Wait until the VM has processed the input and written some output to the terminal commandPromise.then(async () => { const terminalContents = getTerminalContents() const latestEntry = terminalContents[terminalContents.length - 1] if (command && latestEntry.input !== command) { // We start by assuming the result was a failure... let result = false // ... then, check every entry in the terminal (starting from the last) to see if we can be convinced otherwise for(const entry of terminalContents.toReversed()) { if (command && entry.input !== command) { throw new Error("Could not find expected input in terminal") } Loading @@ -297,8 +301,14 @@ class ExerciseExecutionContext { }[typeof param] // !! converts any value to a boolean (not a special operator, just two ! (boolean not) operators in series) const result = !!predicate(latestEntry.output || []) result = !!predicate(entry.output || []) if(result) { break } } // After that is done, return the result await clear() verifyHandler(result) }) Loading