const assert = require('assert');

const Parser = require('../src/parser');
const Evaluator = require('../src/evaluator');

function interpret(input) {
  const parser = new Parser(input);
  const ast = parser.parse();
  const evaluator = new Evaluator(ast);
  const output = evaluator.evaluate();
  return output.value;
}

describe('interpret()', function () {
  const tests = [
    {input: '1', expected: 1},
    {input: '-1', expected: -1},
    {input: '0.1', expected: 0.1},
    {input: '-0.1', expected: -0.1},
    {input: '(add 1 2)', expected: 3},
    {input: '(sub 3 2)', expected: 1},
    {input: '(mul 2 3)', expected: 6},
    {input: '(div 6 3)', expected: 2},
    {input: '(mod 9 6)', expected: 3},
    {input: '(pow 2 3)', expected: 8},
    {input: '(add (add 1 2) 3)', expected: 6},
    {input: 'foo', expected: 'foo'},
    {input: 'foo-bar', expected: 'foo-bar'},
    {input: 'fooBar', expected: 'fooBar'},
  ];

  tests.forEach(function (test) {
    it(`correctly evaluates ${test.input}`, function () {
      const actual = interpret(test.input);
      assert.equal(actual, test.expected);
    });
  });
});

@@ -362,17 +362,25 @@
   const 
-t
+positiveT
 ests = %5B
@@ -930,17 +930,25 @@
   %5D;%0A%0A  
-t
+positiveT
 ests.for
@@ -1115,16 +1115,16 @@
 ected);%0A
-
     %7D);%0A
@@ -1128,13 +1128,1001 @@
 );%0A  %7D);
+%0A%0A  const negativeTests = %5B%0A    %7Binput: '(', reason: 'unmatched parenthesis'%7D,%0A    %7Binput: ')', reason: 'unmatched parenthesis'%7D,%0A    %7Binput: '()', reason: 'empty symbolic expression'%7D,%0A    %7Binput: '(1)', reason: 'symbolic expression must begin with a symbol'%7D,%0A    %7Binput: '(foo)', reason: 'undefined symbol'%7D,%0A    %7Binput: 'foo bar', reason: 'must be single expression'%7D,%0A    %7Binput: '(add 1 2) foo', reason: 'must be single expression'%7D,%0A    %7Binput: 'foo (add 1 2)', reason: 'must be single expression'%7D,%0A    %7Binput: '-foo', reason: 'symbol cannot begin with a hyphen'%7D,%0A    %7Binput: 'foo-', reason: 'symbol cannot end with a hyphen'%7D,%0A    %7Binput: '.1', reason: 'number cannot begin with a decimal point'%7D,%0A    %7Binput: '1.', reason: 'number cannot end with a decimal point'%7D,%0A  %5D;%0A%0A  negativeTests.forEach(function (test) %7B%0A    it(%60throws an error evaluating $%7Btest.input%7D ($%7Btest.reason%7D)%60, function () %7B%0A      assert.throws(() =%3E %7B%0A        interpret(test.input);%0A      %7D);%0A    %7D)%0A  %7D);
 %0A%7D);%0A

Add negative tests for evaluator