Added test to ensure same visibility de-escalation rules apply to concrete implementations of Interface methods
parent
10ef0b2139
commit
7070e55254
|
@ -22,10 +22,11 @@
|
|||
* @package test
|
||||
*/
|
||||
|
||||
var common = require( './common' ),
|
||||
assert = require( 'assert' ),
|
||||
Class = common.require( 'class' ),
|
||||
propobj = common.require( 'propobj' ),
|
||||
var common = require( './common' ),
|
||||
assert = require( 'assert' ),
|
||||
Class = common.require( 'class' ),
|
||||
Interface = common.require( 'interface' ),
|
||||
propobj = common.require( 'propobj' ),
|
||||
|
||||
pub = 'foo',
|
||||
prot = 'bar',
|
||||
|
@ -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" );
|
||||
} )();
|
||||
|
||||
|
|
Loading…
Reference in New Issue