1
0
Fork 0

Added test to ensure same visibility de-escalation rules apply to concrete implementations of Interface methods

closure/master
Mike Gerwitz 2011-03-18 23:55:56 -04:00
parent 10ef0b2139
commit 7070e55254
1 changed files with 23 additions and 4 deletions

View File

@ -25,6 +25,7 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
Class = common.require( 'class' ), Class = common.require( 'class' ),
Interface = common.require( 'interface' ),
propobj = common.require( 'propobj' ), propobj = common.require( 'propobj' ),
pub = 'foo', pub = 'foo',
@ -638,3 +639,21 @@ var common = require( './common' ),
); );
} )(); } )();
/**
* Concrete implementations of interfaces should have to follow the same
* visibility de-escalation rules as defined in the above tests (otherwise, that
* defeats the purpose of an interface). In other words, they must be public.
*/
( function testVisibilityDeescalationRulesApplyToInterfaces()
{
assert.throws( function()
{
Class.implement( Interface( { 'abstract public foo': [] } ) ).extend(
{
// should throw an exception; visibility de-escalation
'protected foo': function() {},
} );
}, Error, "Cannot de-escalate visibility for interface members" );
} )();