Added test to ensure same visibility de-escalation rules apply to concrete implementations of Interface methods
parent
10ef0b2139
commit
7070e55254
|
@ -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" );
|
||||||
|
} )();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue