var object;

require('./_prepare');

object = mod('object');

test('isBareObject', function() {
  object.isBareObject('a').should.equal(false);
  return object.isBareObject({
    'a': 'a'
  }).should.equal(true);
});

test('typeOf', function() {
  object.typeOf('s').should.equal('string');
  object.typeOf(0).should.equal('number');
  object.typeOf(false).should.equal('boolean');
  object.typeOf({}).should.equal('object');
  object.typeOf(arguments).should.equal('arguments');
  return object.typeOf([]).should.equal('array');
});

test('empty', function() {
  var o;
  o = {
    a: 1,
    b: 2
  };
  object.empty(o);
  o.should.not.have.property('a');
  return o.should.not.have.property('b');
});

test('fastEmpty', function() {
  var o;
  o = {
    a: 1,
    b: 2
  };
  object.fastEmpty(o);
  o.should.not.have.property('a');
  return o.should.not.have.property('b');
});

test('clone', function() {
  var o;
  object.clone([1])[0].should.equal(1);
  object.clone({
    a: 1
  }).a.should.equal(1);
  o = {
    a: 1
  };
  return object.clone(o).should.not.equal(o);
});

test('clone [include prototype]', function() {
  var C, a, b;
  C = (function() {
    function C(a) {
      this.a = a;
    }

    C.prototype.sayA = function() {
      return this.a + 'a';
    };

    return C;

  })();
  a = new C('a');
  a.sayA().should.equal('aa');
  b = object.clone(a, true);
  b.should.not.equal(a);
  b.constructor.should.equal(C);
  b.a.should.equal('a');
  b.a = 'a2';
  return b.sayA().should.equal('a2a');
});

test('clone [without prototype]', function() {
  var C, a, b;
  C = (function() {
    function C(a) {
      this.a = a;
    }

    C.prototype.sayA = function() {
      return this.a + 'a';
    };

    return C;

  })();
  a = new C('a');
  a.sayA().should.equal('aa');
  b = object.clone(a, false);
  return b.should.equal(a);
});

test('overrideOnto [basic]', function() {
  var onto, what;
  onto = {
    a: 'a',
    b: {
      c: 'c',
      d: {
        e: 'e'
      }
    }
  };
  what = {
    a: 'a2',
    b: {
      c: 'c2',
      d: {
        f: 'f2'
      }
    }
  };
  object.overrideOnto(onto, what);
  onto.a.should.equal('a2');
  onto.b.should.have.property('c');
  onto.b.c.should.equal('c2');
  onto.b.d.should.not.have.property('f');
  return onto.b.d.e.should.equal('e');
});

test('override', function() {
  var onto, onto2, what;
  onto = {
    a: 'a',
    b: {
      c: 'c',
      d: {
        e: 'e'
      }
    }
  };
  what = {
    a: 'a2',
    b: {
      c: 'c2',
      d: {
        f: 'f2'
      }
    }
  };
  onto2 = object.override(onto, what);
  onto2.a.should.equal('a2');
  onto2.b.should.have.property('c');
  onto2.b.c.should.equal('c2');
  onto2.b.d.should.not.have.property('f');
  onto2.b.d.e.should.equal('e');
  return onto.should.not.equal(onto2);
});

(function() {
  var onto, what;
  what = {
    a: 'a2',
    c: function() {},
    z: 'z',
    y: {
      a: 'a'
    }
  };
  onto = {
    a: 'a',
    b: 'b'
  };
  test('appendOnto [basic]', function() {
    object.appendOnto(onto, what);
    onto.a.should.equal('a2');
    onto.b.should.equal('b');
    return onto.z.should.equal('z');
  });
  test("appendOnto [shallow copies instances]", function() {
    onto.c.should.be["instanceof"](Function);
    return onto.c.should.equal(what.c);
  });
  return test("appendOnto [clones objects]", function() {
    onto.should.have.property('y');
    onto.y.a.should.equal('a');
    return onto.y.should.not.equal(what.y);
  });
})();

test('groupProps', function() {
  var groups, obj;
  obj = {
    a1: '1',
    a2: '2',
    b1: '1',
    b2: '2',
    c1: '1',
    c2: '2',
    rest1: '1',
    rest2: '2'
  };
  groups = object.groupProps(obj, {
    a: ['a1', 'a2'],
    b: [/^b[0-9]+$/],
    c: function(key) {
      return key[0] === 'c';
    }
  });
  groups.a.should.have.property('a1');
  groups.a.a1.should.equal('1');
  groups.a.should.have.property('a2');
  groups.b.should.have.property('b1');
  groups.b.should.have.property('b2');
  groups.c.should.have.property('c1');
  groups.c.should.have.property('c2');
  groups.rest.should.have.property('rest1');
  groups.rest.should.have.property('rest1');
  return groups.rest.should.not.have.property('c1');
});

//# sourceMappingURL=data:application/json;base64,[encoded data, 35240 characters]