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

View File

@ -197,3 +197,13 @@ assert.doesNotThrow(
"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' );
var data = {
'abstract foo': null,
'abstract foo': [],
}
var abstract_methods = [],
@ -56,7 +56,7 @@ assert.ok(
//
// custom parser
var data2 = {
foo: 'bar',
foo: [],
},
map = {
foo: { 'abstract': true },