/**
 * Created by Tony on 2019/3/10.
 */

var test = require('tape');
// var stringUtil = require('../../../public/stringUtil');

// test('测试引用于拷贝', function(t){
//     let orgObj = {k1: "abc", items: [1, 2, 3]};
//     let refObj = orgObj.items;
//     console.log("before delete property: ");
//     console.log(orgObj);
//     delete orgObj.items;
//     console.log("after delete property: ");
//     console.log(orgObj);
//     orgObj.items = refObj;
//     console.log("then recover deleted property: ");
//     console.log(orgObj);
//     t.end();
// });

// test('测试assign', function(t){
//     let orgObj = {k1: "abc", items: [6, 2, 3, 4, 5]};
//     let refObj = [];
//     Object.assign(refObj, orgObj.items);
//     console.log(orgObj);
//     orgObj.items.sort();
//     console.log(orgObj);
//     // orgObj.items = refObj;
//     console.log(refObj);
//     t.end();
// })

test('测试assign more', function(t){
    let orgObj = {k1: "abc", items: [{a: 1}, {a: 2, items: [1, 2, 3]}, {a: 3, items: [6, 4, 5]}]};
    let refObj = [];
    Object.assign(refObj, orgObj.items);
    // console.log(orgObj);
    // orgObj.items.sort();
    console.log(orgObj);
    // orgObj.items = refObj;
    console.log(refObj);
    t.end();
})