1
0
Fork 0

Abstract methods must contain a parameter list as an array

closure/master
Mike Gerwitz 2010-12-27 22:30:28 -05:00
parent 28cf2d0e2b
commit 1364d5967f
3 changed files with 18 additions and 8 deletions

View File

@ -187,15 +187,15 @@ exports.propParse = function( data, options )
if ( keywords['abstract'] ) if ( keywords['abstract'] )
{ {
if ( value instanceof Array ) if ( !( value instanceof Array ) )
{ {
throw TypeError(
"Missing parameter list for abstract method: " + name
);
}
value = exports.createAbstractMethod.apply( this, value ); value = exports.createAbstractMethod.apply( this, value );
} }
else
{
value = exports.createAbstractMethod();
}
}
// if an 'each' callback was provided, pass the data before parsing it // if an 'each' callback was provided, pass the data before parsing it
if ( callback_each ) if ( callback_each )

View File

@ -197,3 +197,13 @@ assert.doesNotThrow(
"no definition was provided" "no definition was provided"
); );
assert.throws( function()
{
Class.extend(
{
// not an array (invalid)
'abstract foo': 'scalar',
} );
}, TypeError, "Abstract methods must be declared as arrays" );

View File

@ -27,7 +27,7 @@ var common = require( './common' ),
util = common.require( 'util' ); util = common.require( 'util' );
var data = { var data = {
'abstract foo': null, 'abstract foo': [],
} }
var abstract_methods = [], var abstract_methods = [],
@ -56,7 +56,7 @@ assert.ok(
// //
// custom parser // custom parser
var data2 = { var data2 = {
foo: 'bar', foo: [],
}, },
map = { map = {
foo: { 'abstract': true }, foo: { 'abstract': true },