1
0
Fork 0

Added constructor property to reserved members list

perfodd
Mike Gerwitz 2012-01-17 23:36:01 -05:00
parent 958521f673
commit 9dbd0d1fb3
2 changed files with 34 additions and 1 deletions

View File

@ -55,7 +55,10 @@ var util = require( __dirname + '/util' ),
* *
* @type {Object.<string,boolean>} * @type {Object.<string,boolean>}
*/ */
reserved_members = { '__initProps': true }, reserved_members = {
'__initProps': true,
'constructor': true,
},
/** /**
* Hash of methods that must be public * Hash of methods that must be public

View File

@ -75,6 +75,36 @@ var common = require( './common' ),
} )(); } )();
/**
* This test is to ensure that nobody (a) removes reserved members without
* understanding the consequences or (b) adds reserved members without properly
* documenting them.
*/
( function testProperMembersAreReserved()
{
var chk = [ '__initProps', 'constructor' ],
i = chk.length,
reserved = ClassBuilder.getReservedMembers();
while ( i-- )
{
var cur = chk[ i ];
assert.ok( reserved.hasOwnProperty( cur ),
"Member '" + cur + "' should be reserved"
);
delete reserved[ cur ];
}
// ensure there are no others that we didn't expect
for ( var name in reserved )
{
assert.fail( "Untested reserved member found: " + name );
}
} )();
/** /**
* Ensure that each of the reserved members will throw an exception if they are * Ensure that each of the reserved members will throw an exception if they are
* used. * used.