1
0
Fork 0

Altered property keyword parser tests to be more easily recognizable

closure/master
Mike Gerwitz 2011-01-17 20:41:04 -05:00
parent afc5d4668d
commit 1f661bebcd
1 changed files with 87 additions and 78 deletions

View File

@ -26,15 +26,19 @@ var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
util = common.require( 'util' ); util = common.require( 'util' );
var data = {
( function testAbstractKeywordDesignatesMethodAsAbstract()
{
var data = {
'abstract foo': [], 'abstract foo': [],
} },
var abstract_methods = [], abstract_methods = [],
parse_data = {}; parse_data = {}
;
util.propParse( data, { util.propParse( data, {
method: function ( name, func, is_abstract ) method: function ( name, func, is_abstract )
{ {
if ( is_abstract ) if ( is_abstract )
@ -43,30 +47,33 @@ util.propParse( data, {
parse_data[ name ] = func; parse_data[ name ] = func;
} }
}, },
} ); } );
assert.ok( assert.ok(
( ( abstract_methods.length === 1 ) ( ( abstract_methods.length === 1 )
&& ( abstract_methods[ 0 ] === 'foo' ) && ( abstract_methods[ 0 ] === 'foo' )
), ),
"Methods with 'abstract' keyword recognized as abstract" "Methods with 'abstract' keyword recognized as abstract"
); );
} )();
// ( function testCustomPropertyKeywordParsersAreSupported()
// custom parser {
var data2 = { var data2 = {
foo: [], foo: [],
}, },
map = { map = {
foo: { 'abstract': true }, foo: { 'abstract': true },
}, },
suffix = 'poo', suffix = 'poo',
abstract_methods_2 = []; abstract_methods_2 = []
;
util.propParse( data2, { util.propParse( data2, {
keywordParser: function ( prop ) keywordParser: function ( prop )
{ {
return { return {
@ -83,18 +90,19 @@ util.propParse( data2, {
abstract_methods_2.push( name ); abstract_methods_2.push( name );
} }
}, },
} ); } );
assert.ok( assert.ok(
( abstract_methods_2[ 0 ] === ( 'foo' + suffix ) ), ( abstract_methods_2[ 0 ] === ( 'foo' + suffix ) ),
"Can provide custom property keyword parser" "Can provide custom property keyword parser"
); );
} )();
// ( function testKeywordParserToleratesBogusResponses()
// integrity test
assert.doesNotThrow( function()
{ {
assert.doesNotThrow( function()
{
var junk = { foo: 'bar' }; var junk = { foo: 'bar' };
util.propParse( junk, { util.propParse( junk, {
@ -111,5 +119,6 @@ assert.doesNotThrow( function()
return { name: [], keywords: 'slefwef' }; return { name: [], keywords: 'slefwef' };
} }
} ); } );
}, Error, "Custom keyword parser tolerates bogus response" ); }, Error, "Custom keyword parser tolerates bogus response" );
} )();