-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pass multiple arguments to solutions? #32
Comments
yeah, not so easy with the current API given that it's focused on a single exec. If you can make your solution about making a "module" rather than a "program" then it's easier to call it to verify in different ways. Check out levelmeup for lots of examples of this kind; once you have the module you can do what you want with it and call it as many times as you like and verification can involve printing out your test output to stdout. |
Interesting. So you're using const
// ...
, file = process.argv[3]
, solution = require(path.resolve(process.cwd(), file)) |
This seems to work: setup.js module.exports = function() {
var file = process.argv[3],
solution = require('./solution'),
submission = require(path.resolve(process.cwd(), file)),
args = [1, 4, 6],
streamA = new readable(),
streamB = new readable();
streamA.push(JSON.stringify(solution(args)));
streamA.push(null);
streamB.push(JSON.stringify(submission(args)));
streamB.push(null);
return {
a: streamA,
b: streamB
};
} It's a little clunkier than I was hoping - am I doing something wrong? Would you accept a PR to make this cleaner? I think ideally it would look something like: module.exports = function(run, callback, solution, submission) {
var args = [1, 4, 6];
return {
a: solution(args),
b: submission(args)
};
}; |
I see the from the examples that you can pass a single array of arguments to the solutions to verify them:
setup.js
Is it possible to pass multiple sets of arguments, so you can have multiple test cases? I looked around in the code and other examples but didn't find anything conclusive.
The text was updated successfully, but these errors were encountered: