Fix head/tail are arrays

pull/5545/head
Berkeley Martinez 2015-12-28 23:14:42 -08:00
parent e6e6fb9d02
commit 49b9c8c9c8
1 changed files with 8 additions and 4 deletions

View File

@ -55,11 +55,13 @@ function createTest({
title,
tests = [],
solutions = [],
head = '',
tail = ''
head = [],
tail = []
}) {
solutions = solutions.filter(solution => !!solution);
tests = tests.filter(test => !!test);
head = head.join('\n');
tail = tail.join('\n');
const plan = tests.length;
if (!plan) {
return Observable.just({
@ -87,11 +89,13 @@ function createTest({
.doOnNext(assert => {
solutions.forEach(solution => {
tests.forEach(test => {
const code = head + solution + tail;
const code = solution;
const editor = { getValue() { return code; } };
/* eslint-enable no-unused-vars */
try {
(() => { return eval(solution + ';;' + test); })();
(() => {
return eval(head + solution + tail + ';;' + test);
})();
} catch (e) {
t.fail(e);
}