Abstract methods must contain a parameter list as an array
parent
28cf2d0e2b
commit
1364d5967f
12
lib/util.js
12
lib/util.js
|
@ -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
|
||||
|
|
|
@ -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" );
|
||||
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Reference in New Issue