var test = require('../../src/assertion/ttr')
var clone = require('../../src/lang/clone')

test('should not return source object', function(t) {
  var src = {};
  var result = clone(src);
  t.ne(result, src);
});

test('should copy source properties', function(t) {
  var src = { test: true };
  var result = clone(src);
  t.eq(result.test, true);
});

test('should copy deep properties', function(t) {
  var src = { test: { me: true} };
  var result = clone(src);
  t.eq(result.test.me, true);
  t.ne(result, src)
});

test('should not clone child objects', function(t) {
  var src = { test: {} };
  var result = clone(src);
  t.eq(result.test, src.test);
});

test('should clone arrays', function(t) {
  var src = [1, 2, 3];
  var result = clone(src);
  t.ne(result, src);
  t.same(result, src);
});

test('should clone functions', function(t) {
  var src = function foo () {return 'foo'};
  var result = clone(src);
  t.eq(result, src);
  t.same(result, src);
});

test('should clone RegExps', function(t) {
  var src = /test/gim;
  var result = clone(src);
  t.ne(result, src);
  t.same(result, src);
  t.is(result.ignoreCase, true);
  t.is(result.multiline, true);
  t.is(result.global, true);
});

test('should clone Dates', function(t) {
  var src = new Date();
  var result = clone(src);
  t.ne(result, src);
  t.same(result, src);
});

test('should not clone objects created with custom constructor', function(t) {
  function TestType() { }
  var src = new TestType();
  var result = clone(src);
  t.is(result, src);
});

test.result()

@@ -1,16 +1,20 @@
 var 
-test
+painless
  = requi
@@ -41,13 +41,92 @@
 ion/
-ttr')
+painless')%0Avar test = painless.createGroup('Test lang/kind')%0Avar t = painless.assert
 %0Avar
@@ -208,33 +208,32 @@
 ject', function(
-t
 ) %7B%0A  var src = 
@@ -328,33 +328,32 @@
 ties', function(
-t
 ) %7B%0A  var src = 
@@ -464,33 +464,32 @@
 ties', function(
-t
 ) %7B%0A  var src = 
@@ -633,33 +633,32 @@
 ects', function(
-t
 ) %7B%0A  var src = 
@@ -763,33 +763,32 @@
 rays', function(
-t
 ) %7B%0A  var src = 
@@ -906,33 +906,32 @@
 ions', function(
-t
 ) %7B%0A  var src = 
@@ -1068,33 +1068,32 @@
 Exps', function(
-t
 ) %7B%0A  var src = 
@@ -1305,25 +1305,24 @@
 ', function(
-t
 ) %7B%0A  var sr
@@ -1487,17 +1487,16 @@
 unction(
-t
 ) %7B%0A  fu
@@ -1601,19 +1601,4 @@
 %7D);%0A
-%0Atest.result()%0A

update test lang/clone -- convert to painless