var define = require('../../../../lib/object/define');

exports.define = function (test) {
    var F1 = define({});
    test.ok(new F1);
    var F2 = define({
        property: {
            val1: 1111,
            getter1: function () {
                var s = this;
                return s.val1 * 2
            }
        }
    });
    var f2 = new F2;
    test.equal(f2.val1, 1111);
    test.equal(f2.getter1(), 2222);
    var F3 = define({
        init: function (data) {
            var s = this;
            s.data = data * 5;
        }
    });
    test.equal(new F3(11).data, 55);

    var F4 = define({
        prototype: F3
    });
    test.equal(new F4(11).data, 55);

    test.ok(F2.toString());
    test.done();
};

exports.addaccessor = function (test) {
    var F1 = define({
        accessor: 'k'
    });
    var f1 = new F1().k("valueOfK");
    test.equal(f1.k(), "valueOfK");
    test.equal(f1._k, "valueOfK");

    var F2 = define({
        accessor: 'k2,k3',
        properties: {
            _k2: 'valueOfK2'
        }
    });
    var f2 = new F2();
    test.equal(f2._k2, "valueOfK2");
    test.equal(f2.k2(), "valueOfK2");
    test.equal(f2.k2('changed').k2(), "changed");
    test.ok(f2.k3);


    test.done();
};