2014-01-20 08:37:48 +00:00
|
|
|
/* vim: set ts=2: */
|
2017-03-12 07:34:36 +00:00
|
|
|
/*jshint loopfunc:true, mocha:true, node:true */
|
2014-01-20 08:37:48 +00:00
|
|
|
var SSF = require('../');
|
2017-03-12 07:34:36 +00:00
|
|
|
var fs = require('fs');
|
2014-01-20 08:37:48 +00:00
|
|
|
var data = fs.readFileSync('./test/exp.tsv','utf8').split("\n");
|
|
|
|
function doit(d, headers) {
|
|
|
|
it(d[0], function() {
|
2014-02-11 19:20:34 +00:00
|
|
|
for(var w = 1; w < headers.length; ++w) {
|
2014-01-20 08:37:48 +00:00
|
|
|
var expected = d[w].replace("|", ""), actual;
|
2014-06-13 15:02:06 +00:00
|
|
|
try { actual = SSF.format(headers[w], parseFloat(d[0]), {}); } catch(e) { }
|
2017-03-24 05:06:07 +00:00
|
|
|
if(actual != expected && d[w].charAt(0) !== "|") throw new Error([actual, expected, w, headers[w],d[0],d].join("|"));
|
2014-01-20 08:37:48 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
describe('exponential formats', function() {
|
|
|
|
var headers = data[0].split("\t");
|
2014-02-11 19:20:34 +00:00
|
|
|
for(var j=1;j<data.length;++j) {
|
2014-01-20 08:37:48 +00:00
|
|
|
if(!data[j]) return;
|
|
|
|
doit(data[j].replace(/#{255}/g,"").split("\t"), headers);
|
|
|
|
}
|
|
|
|
});
|