Can no longer set values of undeclared static properties
parent
7e53df0e84
commit
462671cfba
|
@ -114,8 +114,15 @@ exports.ClassBase = function Class() {};
|
||||||
*
|
*
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
exports.ClassBase.$ = function( prop )
|
exports.ClassBase.$ = function( prop, val )
|
||||||
{
|
{
|
||||||
|
if ( val !== undefined )
|
||||||
|
{
|
||||||
|
throw ReferenceError(
|
||||||
|
"Cannot set value of undeclared static property '" + prop + "'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -396,3 +396,23 @@ var common = require( './common' ),
|
||||||
);
|
);
|
||||||
} )();
|
} )();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users should not be permitted to set values of static properties that have
|
||||||
|
* not been declared.
|
||||||
|
*/
|
||||||
|
( function testAttemptingToSetUndeclaredStaticPropertyResultsInException()
|
||||||
|
{
|
||||||
|
assert.throws(
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
// should throw an exception since property 'foo' has not been
|
||||||
|
// declared
|
||||||
|
builder.build( {} ).$( 'foo', 'val' );
|
||||||
|
},
|
||||||
|
ReferenceError,
|
||||||
|
"Attempting to set an undeclaraed static property results in an " +
|
||||||
|
"exception"
|
||||||
|
);
|
||||||
|
} )();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue