Skip to content

Commit

Permalink
Merge branch 'master' into cs/fid
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored Oct 7, 2019
2 parents a9bb253 + 9c4420d commit d21fb14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ function runTest(argv) {

results[0].your_input = problem.testcase;
results[0].output = results[0].answer;
results[1].expected = results[1].answer;
// LeetCode-CN returns the actual and expected answer into two separate responses
if (results[1]) {
results[0].expected_answer = results[1].answer;
}
results[0].stdout = results[0].stdout.slice(1, -1).replace(/\\n/g, '\n');
printResult(results[0], null, 'your_input');
printResult(results[0], results[0].runtime, 'output');
printResult(results[1], results[1].runtime, 'expected');
printResult(results[0], null, 'expected_answer');
printResult(results[0], null, 'stdout');
});
});
Expand Down
8 changes: 7 additions & 1 deletion lib/plugins/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ function formatResult(result) {
}
x.stdout = util.inspect(output);
x.answer = result.code_answer;
// LeetCode use 'expected_code_answer' to store the expected answer
x.expected_answer = result.expected_code_answer;
} else {
// It's submitting
x.answer = result.code_output;
Expand All @@ -291,8 +293,12 @@ plugin.testProblem = function(problem, cb) {

const tasks = [
{type: 'Actual', id: task.interpret_id},
{type: 'Expected', id: task.interpret_expected_id}
];

// Used by LeetCode-CN
if (task.interpret_expected_id) {
tasks.push({type: 'Expected', id: task.interpret_expected_id});
}
const q = new Queue(tasks, {opts: opts, results: []}, verifyResult);
q.run(null, function(e, ctx) {
return cb(e, ctx.results);
Expand Down

0 comments on commit d21fb14

Please sign in to comment.