diff --git a/lib/util.js b/lib/util.js index 48003a3..74dc99e 100644 --- a/lib/util.js +++ b/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 diff --git a/test/test-class-abstract.js b/test/test-class-abstract.js index 49e9b47..9f9e28f 100644 --- a/test/test-class-abstract.js +++ b/test/test-class-abstract.js @@ -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" ); + diff --git a/test/test-util-prop-parse-keywords.js b/test/test-util-prop-parse-keywords.js index 49ff95d..f98415c 100644 --- a/test/test-util-prop-parse-keywords.js +++ b/test/test-util-prop-parse-keywords.js @@ -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 },