1
0
Fork 0

[#25] Added visibility [de-]escalation tests for properties

closure/master
Mike Gerwitz 2011-10-28 20:22:53 -04:00
parent 31a7980e37
commit 8433511f56
1 changed files with 56 additions and 0 deletions

View File

@ -37,6 +37,37 @@ require( 'common' ).testCase(
'validateProperty', keywords, identifier, prev
);
};
this.quickVisChangeTest = function( start, override, failtest )
{
var _self = this,
name = 'foo',
startobj = {},
overrideobj = {}
;
startobj[ start ] = true;
overrideobj[ override ] = true;
var testfun = function()
{
_self.sut.validateProperty(
name, 'bar', overrideobj,
{ member: 'foo' },
startobj
);
};
if ( failtest )
{
this.quickFailureTest( name, 'de-escalate', testfun );
}
else
{
_self.assertDoesNotThrow( testfun, Error );
}
};
},
@ -128,5 +159,30 @@ require( 'common' ).testCase(
);
} );
},
/**
* De-escalating the visibility of a property would alter the interface of a
* subtype, which would not be polymorphic.
*/
'Properties do not support visibility de-escalation': function()
{
this.quickVisChangeTest( 'public', 'protected', true );
this.quickVisChangeTest( 'protected', 'private', true );
},
/**
* Contrary to the above test, we have no such problem with visibility
* escalation.
*/
'Properties do support visibility escalation and equality': function()
{
var _self = this;
shared.visEscalationTest( function( cur )
{
_self.quickVisChangeTest( cur[ 0 ], cur[ 1 ], false );
} );
},
} );