1
0
Fork 0

Getters/setters are not supported within interface definitions

closure/master
Mike Gerwitz 2011-01-24 23:56:54 -05:00
parent c7b262b271
commit 188ad2f4eb
2 changed files with 45 additions and 6 deletions

View File

@ -77,6 +77,20 @@ var extend = ( function( extending )
);
},
getter: function()
{
throw TypeError(
"Getters are not permitted within Interface definitions"
);
},
setter: function()
{
throw TypeError(
"Setters are not permitted within Interface definitions"
);
},
method: function( name, value, is_abstract, keywords )
{
if ( !is_abstract )

View File

@ -27,14 +27,39 @@ var common = require( './common' ),
Interface = common.require( 'interface' );
assert.throws( function()
( function testPropertiesNotPermittedWithinInterfaces()
{
Interface.extend(
assert.throws( function()
{
// properties (non-methods) are not permitted
prop: 'not permitted',
});
}, TypeError, "Properties are not permitted within Interface definitions" );
Interface.extend(
{
// properties (non-methods) are not permitted
prop: 'not permitted',
});
}, TypeError, "Properties are not permitted within Interface definitions" );
} )();
( function testGettersAndSettersNotPermittedWithinInterfaces()
{
// don't perform this test if unsupported by environment
if ( Object.prototype.__defineGetter__ === undefined )
{
return;
}
// so we don't break browsers that do not support getters/setters in object
// notation
var data = {};
data.__defineGetter__( 'foo', function() {} );
data.__defineSetter__( 'foo', function() {} );
assert.throws( function()
{
Interface.extend( data );
}, TypeError, "Getters/setters not permitted within Interfaces" );
} )();
assert.throws( function()
{