1
0
Fork 0

Can initialize member object with existing objects for each level of visibility

closure/master
Mike Gerwitz 2011-01-20 23:56:39 -05:00
parent 96cee9660b
commit 2205af8c07
2 changed files with 33 additions and 4 deletions

View File

@ -31,12 +31,12 @@
* *
* @return {{public: Object, protected: Object, private: Object}} * @return {{public: Object, protected: Object, private: Object}}
*/ */
exports.initMembers = function() exports.initMembers = function( mpublic, mprotected, mprivate )
{ {
return { return {
'public': {}, 'public': mpublic || {},
'protected': {}, 'protected': mprotected || {},
'private': {}, 'private': mprivate || {},
}; };
}; };

View File

@ -37,3 +37,32 @@ var common = require( './common' ),
); );
} )(); } )();
( function testCanInitMembersWithExistingObjects()
{
var pub = { foo: 'bar' },
pro = { bar: 'baz' },
priv = { baz: 'foo' },
members = builder.initMembers( pub, pro, priv )
;
assert.deepEqual(
members[ 'public' ],
pub,
"Can specify object to use for public members"
);
assert.deepEqual(
members[ 'protected' ],
pro,
"Can specify object to use for protected members"
);
assert.deepEqual(
members[ 'private' ],
priv,
"Can specify object to use for private members"
);
} )();