<commit_before>var test = require('tape');
var truncate = require('./');
var fs = require('fs');
var path = require('path');
var load = require('load-json-file');
var write = require('write-json-file');

var directories = {
    in: path.join(__dirname, 'test', 'in'),
    out: path.join(__dirname, 'test', 'out')
};

// function save(directory, filename, features) {
//     return fs.writeFileSync(path.join(directory, filename), JSON.stringify(features, null, 2));
// }

// function read(directory, filename) {
//     return JSON.parse(fs.readFileSync(path.join(directory, filename), 'utf8'));
// }

test('truncate', (t) => {
    var point = load.sync(path.join(directories.in, 'point.json'));
    var points = load.sync(path.join(directories.in, 'points.json'));
    var pointElevation = load.sync(path.join(directories.in, 'pointElevation.json'));
    var polygon = load.sync(path.join(directories.in, 'polygon.json'));
    var polygons = load.sync(path.join(directories.in, 'polygons.json'));

    var pointTruncate = truncate(point);
    var pointsTruncate = truncate(points);
    var pointElevationTruncate = truncate(pointElevation, 6, true);
    var polygonTruncate = truncate(polygon);
    var polygonsTruncate = truncate(polygons);
    var polygonsTruncateDecimal3 = truncate(polygons, 3);

    if (process.env.REGEN) {
        write.sync(path.join(directories.out, 'pointTruncate.json'), pointTruncate);
        write.sync(path.join(directories.out, 'pointsTruncate.json'), pointsTruncate);
        write.sync(path.join(directories.out, 'pointElevationTruncate.json'), pointElevationTruncate);
        write.sync(path.join(directories.out, 'polygonTruncate.json'), polygonTruncate);
        write.sync(path.join(directories.out, 'polygonsTruncate.json'), polygonsTruncate);
        write.sync(path.join(directories.out, 'polygonsTruncateDecimal3.json'), polygonsTruncateDecimal3);
    }

    t.deepEqual(pointTruncate, load.sync(path.join(directories.out, 'pointTruncate.json')), 'pointTruncate');
    t.deepEqual(pointsTruncate, load.sync(path.join(directories.out, 'pointsTruncate.json')), 'pointsTruncate');
    t.deepEqual(pointElevationTruncate, load.sync(path.join(directories.out, 'pointElevationTruncate.json')), 'pointElevationTruncate');
    t.deepEqual(polygonTruncate, load.sync(path.join(directories.out, 'polygonTruncate.json')), 'polygonTruncate');
    t.deepEqual(polygonsTruncate, load.sync(path.join(directories.out, 'polygonsTruncate.json')), 'polygonsTruncate');<commit_msg>Remove previous save & read test functions<commit_after>var test = require('tape');
var truncate = require('./');
var path = require('path');
var load = require('load-json-file');
var write = require('write-json-file');

var directories = {
    in: path.join(__dirname, 'test', 'in'),
    out: path.join(__dirname, 'test', 'out')
};

test('truncate', (t) => {
    var point = load.sync(path.join(directories.in, 'point.json'));
    var points = load.sync(path.join(directories.in, 'points.json'));
    var pointElevation = load.sync(path.join(directories.in, 'pointElevation.json'));
    var polygon = load.sync(path.join(directories.in, 'polygon.json'));
    var polygons = load.sync(path.join(directories.in, 'polygons.json'));

    var pointTruncate = truncate(point);
    var pointsTruncate = truncate(points);
    var pointElevationTruncate = truncate(pointElevation, 6, true);
    var polygonTruncate = truncate(polygon);
    var polygonsTruncate = truncate(polygons);
    var polygonsTruncateDecimal3 = truncate(polygons, 3);

    if (process.env.REGEN) {
        write.sync(path.join(directories.out, 'pointTruncate.json'), pointTruncate);
        write.sync(path.join(directories.out, 'pointsTruncate.json'), pointsTruncate);
        write.sync(path.join(directories.out, 'pointElevationTruncate.json'), pointElevationTruncate);
        write.sync(path.join(directories.out, 'polygonTruncate.json'), polygonTruncate);
        write.sync(path.join(directories.out, 'polygonsTruncate.json'), polygonsTruncate);
        write.sync(path.join(directories.out, 'polygonsTruncateDecimal3.json'), polygonsTruncateDecimal3);
    }

    t.deepEqual(pointTruncate, load.sync(path.join(directories.out, 'pointTruncate.json')), 'pointTruncate');
    t.deepEqual(pointsTruncate, load.sync(path.join(directories.out, 'pointsTruncate.json')), 'pointsTruncate');
    t.deepEqual(pointElevationTruncate, load.sync(path.join(directories.out, 'pointElevationTruncate.json')), 'pointElevationTruncate');
    t.deepEqual(polygonTruncate, load.sync(path.join(directories.out, 'polygonTruncate.json')), 'polygonTruncate');
    t.deepEqual(polygonsTruncate, load.sync(path.join(directories.out, 'polygonsTruncate.json')), 'polygonsTruncate');
{'fraction_non_alphanumeric': 0.1576833650391038, 'fraction_numerical': 0.0025364616360177552, 'mean_word_length': 5.309333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6515255', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1580, 'n_words': 240}