Fix head/tail are arrays

This commit is contained in:
Berkeley Martinez
2015-12-28 23:14:42 -08:00
parent e6e6fb9d02
commit 49b9c8c9c8

View File

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