<commit_before>var JSC          = require("jscheck");
var assert       = require("chai").assert;
var _            = require("lodash");
var getTestUtils = require("../TestUtils.js");

module.exports = function(config) {
  var Immutable = config.implementation;
  var TestUtils = getTestUtils(Immutable);
  var check     = TestUtils.check;

  describe("#asMutable", function() {
    it("returns a shallow mutable copy if not provided the deep flag", function() {
      check(100, [ TestUtils.TraversableObjectSpecifier ], function(obj) {
        var immutable = Immutable(obj);
        var mutable = immutable.asMutable();
        assert.isFalse(Immutable.isImmutable(mutable));
        TestUtils.assertIsDeeplyImmutable(mutable.complex);
        TestUtils.assertIsDeeplyImmutable(mutable.deep.complex);
        assert.deepEqual(immutable,mutable);
      })
    })

    it("returns a deep mutable copy if provided the deep flag", function() {
      check(100, [ TestUtils.TraversableObjectSpecifier ], function(obj) {
        var immutable = Immutable(obj);
        var mutable = immutable.asMutable({ deep: true });
        assert.isFalse(Immutable.isImmutable(mutable));
        assert.isFalse(Immutable.isImmutable(mutable['complex']));
        assert.isFalse(Immutable.isImmutable(mutable['deep']['complex']));
        assert.deepEqual(immutable,mutable);
      });
    });
  });
};
<commit_msg>Issue#45 This test shows the bug.<commit_after>var JSC          = require("jscheck");
var assert       = require("chai").assert;
var _            = require("lodash");
var getTestUtils = require("../TestUtils.js");

module.exports = function(config) {
  var Immutable = config.implementation;
  var TestUtils = getTestUtils(Immutable);
  var check     = TestUtils.check;

  describe("#asMutable", function() {
    it("returns a shallow mutable copy if not provided the deep flag", function() {
      check(100, [ TestUtils.TraversableObjectSpecifier ], function(obj) {
        var immutable = Immutable(obj);
        var mutable = immutable.asMutable();
        assert.isFalse(Immutable.isImmutable(mutable));
        TestUtils.assertIsDeeplyImmutable(mutable.complex);
        TestUtils.assertIsDeeplyImmutable(mutable.deep.complex);
        assert.deepEqual(immutable,mutable);
      })
    })

    it("returns a deep mutable copy if provided the deep flag", function() {
      check(100, [ TestUtils.TraversableObjectSpecifier ], function(obj) {
        var immutable = Immutable(obj);
        var mutable = immutable.asMutable({ deep: true });
        assert.isFalse(Immutable.isImmutable(mutable));
        assert.isFalse(Immutable.isImmutable(mutable['complex']));
        assert.isFalse(Immutable.isImmutable(mutable['deep']['complex']));
        assert.deepEqual(immutable,mutable);
      });
    });

      it("does not throw an error when asMutable deep = true is called on an Immutable with a nested date", function() {
          check(100, [ TestUtils.TraversableObjectSpecifier ], function(obj) {
              var test = Immutable({ testDate: new Date()});
              test.asMutable({deep: true});
          });
      });
  });
};

{'fraction_non_alphanumeric': 0.13008905852417302, 'fraction_numerical': 0.005407124681933842, 'mean_word_length': 3.308219178082192, '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': '1871053', 'n_tokens_mistral': 900, 'n_tokens_neox': 892, 'n_words': 185}