<commit_before>var Promise = require('promise');
var Mappersmith = require('mappersmith');
var Utils = Mappersmith.Utils;

var MappersmithObject = require('../index');
var Instance = MappersmithObject.Instance;
var Exceptions = MappersmithObject.Exceptions;

describe('Instance', function() {
  var instance, attributes;

  beforeEach(function() {
    attributes = {
      name: "Someone",
      age: 27,
      human: true,
      company: {
        name: "SomethingCool.io",
        sectors: ["1A", "2B"],
        floors: {
          first: "A",
          second: "B"
        }
      }
    };

    instance = new Instance(attributes);
  });

  it('can be initialized without arguments', function() {
    expect(new Instance()).to.not.be.null;
  });

  describe('#get', function() {
    it('returns the attribute value', function() {
      expect(instance.get('name')).to.equal(attributes.name);
    });

    it('returns a chain value', function() {
      expect(instance.get('company.floors.first')).to.equal(attributes.company.floors.first);
    });

    it('can return a default value', function() {
      expect(instance.get('company.wrong_key', {default: 'value'})).to.equal('value');
    });

    it('returns null for invalid attribute', function() {
      expect(instance.get('invalid')).to.equal(null);
    });

    it('returns null for invalid chain', function() {
      expect(instance.get('invalid.long.chain.of.attributes')).to.equal(null);
    });

    [
      '',
      0,
      -0,
      NaN,
      null,
      undefined,
      false
    ]

    describe('for javascript "falsy" values', function() {
      it('can return empty strings ("")', function() {
        instance.set('test-key', '');
        expect(instance.get('test-key')).to.equal('');
      });

      it('can return zero number (0)', function() {
        instance.set('test-key', 0);
        expect(instance.get('test-key')).to.equal(0);
      });

      it('can return negative zero number (-0)', function() {
        instance.set('test-key', -0);
        expect(instance.get('test-key')).to.equal(-0);
      });<commit_msg>cleanup<commit_after>var Promise = require('promise');
var Mappersmith = require('mappersmith');
var Utils = Mappersmith.Utils;

var MappersmithObject = require('../index');
var Instance = MappersmithObject.Instance;
var Exceptions = MappersmithObject.Exceptions;

describe('Instance', function() {
  var instance, attributes;

  beforeEach(function() {
    attributes = {
      name: "Someone",
      age: 27,
      human: true,
      company: {
        name: "SomethingCool.io",
        sectors: ["1A", "2B"],
        floors: {
          first: "A",
          second: "B"
        }
      }
    };

    instance = new Instance(attributes);
  });

  it('can be initialized without arguments', function() {
    expect(new Instance()).to.not.be.null;
  });

  describe('#get', function() {
    it('returns the attribute value', function() {
      expect(instance.get('name')).to.equal(attributes.name);
    });

    it('returns a chain value', function() {
      expect(instance.get('company.floors.first')).to.equal(attributes.company.floors.first);
    });

    it('can return a default value', function() {
      expect(instance.get('company.wrong_key', {default: 'value'})).to.equal('value');
    });

    it('returns null for invalid attribute', function() {
      expect(instance.get('invalid')).to.equal(null);
    });

    it('returns null for invalid chain', function() {
      expect(instance.get('invalid.long.chain.of.attributes')).to.equal(null);
    });

    describe('for javascript "falsy" values', function() {
      it('can return empty strings ("")', function() {
        instance.set('test-key', '');
        expect(instance.get('test-key')).to.equal('');
      });

      it('can return zero number (0)', function() {
        instance.set('test-key', 0);
        expect(instance.get('test-key')).to.equal(0);
      });

      it('can return negative zero number (-0)', function() {
        instance.set('test-key', -0);
        expect(instance.get('test-key')).to.equal(-0);
      });
{'fraction_non_alphanumeric': 0.18046760837798345, 'fraction_numerical': 0.00535801266439357, 'mean_word_length': 2.881852551984877, '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': '6399455', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1230, 'n_words': 248}