
var clojjs = require('..');
var symbols = require('../lib/symbol');
var lists = require('../lib/list');
var parsers = require('../lib/parser');
var path = require('path');
var fs = require('fs');

exports['Compile integer to file'] = function (test) {
    var sourcefile = path.join(__dirname, 'files', 'integer.cljs');
    var targetfile = path.join(__dirname, 'output', 'integer.js');
    clojjs.compileFile(sourcefile, targetfile);
    var result = fs.readFileSync(targetfile).toString();
    test.strictEqual(result, '42\n');
};

exports['Compile string'] = function (test) {
    var sourcefile = path.join(__dirname, 'files', 'string.cljs');
    var targetfile = path.join(__dirname, 'output', 'string.js');
    clojjs.compileFile(sourcefile, targetfile);
    var result = fs.readFileSync(targetfile).toString();
    test.strictEqual(result, '"foo"\n');
};

exports['Compile nil'] = function (test) {
    var sourcefile = path.join(__dirname, 'files', 'nil.cljs');
    var targetfile = path.join(__dirname, 'output', 'nil.js');
    clojjs.compileFile(sourcefile, targetfile);
    var result = fs.readFileSync(targetfile).toString();
    test.strictEqual(result, 'null\n');
};

exports['Compile symbol in default namespace'] = function (test) {
    var sourcefile = path.join(__dirname, 'files', 'symbol.cljs');
    var targetfile = path.join(__dirname, 'output', 'symbol.js');
    clojjs.compileFile(sourcefile, targetfile);
    var result = fs.readFileSync(targetfile).toString();
    test.equal(result, 'cljs.core.first\n');
};

@@ -203,55 +203,41 @@
 %0D%0A%0D%0A
-exports%5B'Compile integer to file'%5D = function (
+function compile(name, expected, 
 test
@@ -292,24 +292,24 @@
 files', 
-'integer
+name + '
 .cljs');
@@ -366,16 +366,16 @@
 t', 
-'integer
+name + '
 .js'
@@ -518,19 +518,28 @@
 lt, 
-'42
+expected + '
 %5Cn');%0D%0A%7D
 ;%0D%0A%0D
@@ -526,33 +526,32 @@
 cted + '%5Cn');%0D%0A%7D
-;
 %0D%0A%0D%0Aexports%5B'Com
@@ -555,22 +555,31 @@
 Compile 
-string
+integer to file
 '%5D = fun
@@ -602,281 +602,122 @@
     
-var sourcefile = path.join(__dirname, 'files', 'string.cljs');%0D%0A    var targetfile = path.join(__dirname, 'output', 'string.js');%0D%0A    clojjs.compileFile(sourcefile, targetfile);%0D%0A    var result = fs.readFileSync(targetfile).toString();%0D%0A    test.strictEqual(result
+compile('integer', '42', test);%0D%0A%7D;%0D%0A%0D%0Aexports%5B'Compile string'%5D = function (test) %7B%0D%0A    compile('string'
 , '%22foo%22
 %5Cn')
@@ -712,19 +712,23 @@
 , '%22foo%22
-%5Cn'
+', test
 );%0D%0A%7D;%0D%0A
@@ -781,639 +781,158 @@
     
-var sourcefile = path.join(__dirname, 'files', 'nil.cljs');%0D%0A    var targetfile = path.join(__dirname, 'output', 'nil.js');%0D%0A    clojjs.compileFile(sourcefile, targetfile);%0D%0A    var result = fs.readFileSync(targetfile).toString();%0D%0A    test.strictEqual(result, 'null%5Cn');%0D%0A%7D;%0D%0A%0D%0Aexports%5B'Compile symbol in default namespace'%5D = function (test) %7B%0D%0A    var sourcefile = path.join(__dirname, 'files', 'symbol.cljs');%0D%0A    var targetfile = path.join(__dirname, 'output', 'symbol.js');%0D%0A    clojjs.compileFile(sourcefile, targetfile);%0D%0A    var result = fs.readFileSync(targetfile).toString();%0D%0A    test.equal(result, 'cljs.core.first%5Cn'
+compile('nil', 'null', test);%0D%0A%7D;%0D%0A%0D%0Aexports%5B'Compile symbol in default namespace'%5D = function (test) %7B%0D%0A    compile('symbol', 'cljs.core.first', test
 );%0D%0A

Refactor compile file tests