Now throwing expection if more than two arguments are passed to extend() when implementing
parent
14cac6b461
commit
36ae6bcd81
|
@ -361,6 +361,15 @@ function createImplement( base, ifaces, cname )
|
||||||
ext_base = args.pop()
|
ext_base = args.pop()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// if any arguments remain, then they likely misunderstood what this
|
||||||
|
// method does
|
||||||
|
if ( args.length > 0 )
|
||||||
|
{
|
||||||
|
throw Error(
|
||||||
|
"Expecting no more than two arguments for extend()"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// if a base was already provided for extending, don't allow them to
|
// if a base was already provided for extending, don't allow them to
|
||||||
// give us yet another one (doesn't make sense)
|
// give us yet another one (doesn't make sense)
|
||||||
if ( base && ext_base )
|
if ( base && ext_base )
|
||||||
|
|
|
@ -232,3 +232,16 @@ var Type = Interface.extend( {
|
||||||
);
|
);
|
||||||
} )();
|
} )();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If more than two arguments are given to extend(), then the developer likely
|
||||||
|
* does not understand the API. Throw an error to prevent some bugs/confusion.
|
||||||
|
*/
|
||||||
|
( function testThrowsExceptionIfExtendContainsTooManyArguments()
|
||||||
|
{
|
||||||
|
assert.throws( function()
|
||||||
|
{
|
||||||
|
Class.implement( Type ).extend( PlainFoo, {}, 'extra' );
|
||||||
|
}, Error, "extend() after implementing accepts no more than two args" );
|
||||||
|
} )();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue