<commit_before>/*jshint node:true, mocha:true */

'use strict';

require('should');

var Decimal = require('linear-arbitrary-precision')(require('floating-adapter'));
var rescale = require('rescale')(Decimal).rescale;
var angle = require('linear-preset-factory')(require('../src/linear-presets-angle'));

function convert(x, preset) {
  return Number(rescale(preset[0], preset[1], x));
}

function invert(preset) {
  return preset.slice(0).reverse();
}

describe('angle presets', function() {
  it('should convert correctly', function() {
    (Math.PI / 4).should.be.exactly(convert(1 / 8, invert(angle.radian_turn)), 'radian_turn')
      .and.exactly(convert(45, invert(angle.radian_degree)), 'radian_degree')
      .and.exactly(convert(50, invert(angle.radian_gradian)), 'radian_gradian');

    (0).should.be.exactly(convert(0, angle.radian_turn), 'radian_turn')
      .and.exactly(convert(0, angle.radian_degree), 'radian_degree')
      .and.exactly(convert(0, angle.radian_gradian), 'radian_gradian');
  });
});<commit_msg>test(presets): add test for identity conversion<commit_after>/*jshint node:true, mocha:true */

'use strict';

require('should');

var Decimal = require('linear-arbitrary-precision')(require('floating-adapter'));
var rescale = require('rescale')(Decimal).rescale;
var angle = require('linear-preset-factory')(require('../src/linear-presets-angle'));

function convert(x, preset) {
  return Number(rescale(preset[0], preset[1], x));
}

function invert(preset) {
  return preset.slice(0).reverse();
}

describe('angle presets', function() {
  it('should convert correctly', function() {
    (Math.PI / 4).should.be.exactly(convert(Math.PI / 4, invert(angle.radian_radian)), 'radian_radian')
      .and.exactly(convert(1 / 8, invert(angle.radian_turn)), 'radian_turn')
      .and.exactly(convert(45, invert(angle.radian_degree)), 'radian_degree')
      .and.exactly(convert(50, invert(angle.radian_gradian)), 'radian_gradian');

    (0).should.be.exactly(convert(0, angle.radian_radian), 'radian_radian')
      .and.exactly(convert(0, angle.radian_turn), 'radian_turn')
      .and.exactly(convert(0, angle.radian_degree), 'radian_degree')
      .and.exactly(convert(0, angle.radian_gradian), 'radian_gradian');
  });
});
{'fraction_non_alphanumeric': 0.1840463458110517, 'fraction_numerical': 0.013368983957219251, 'mean_word_length': 5.6420118343195265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6910981', 'n_tokens_mistral': 808, 'n_tokens_neox': 779, 'n_words': 118}