1
0
Fork 0

Using TypeError instead of Error for property type inconsistiencies

closure/master
Mike Gerwitz 2010-12-10 00:00:47 -05:00
parent 25dc7e031e
commit 5126c71a2d
3 changed files with 16 additions and 11 deletions

View File

@ -228,7 +228,7 @@ exports.propCopy = function( props, dest, result_data )
}
else
{
throw new Error(
throw new TypeError(
"Cannot override property '" + name + "' with method"
);
}
@ -339,7 +339,7 @@ function method_override(
// that of its supertype
if ( arg_len < super_method.definition.length )
{
throw new Error(
throw new TypeError(
"Declaration of " + name + " must be compatiable " +
"with that of its supertype"
);

View File

@ -172,14 +172,18 @@ assert.throws( function()
});
}, Error, "Concrete methods must implement the proper number of argments" );
assert.throws( function()
{
AbstractFoo.extend(
assert.throws(
function()
{
// incorrect number of arguments
method: abstractMethod(),
});
}, Error, "Abstract methods of subtypes must implement the proper number of argments" );
AbstractFoo.extend(
{
// incorrect number of arguments
method: abstractMethod(),
});
},
TypeError,
"Abstract methods of subtypes must implement the proper number of argments"
);
assert.doesNotThrow(
function()
@ -205,7 +209,8 @@ assert.doesNotThrow(
{
},
});
}, Error,
},
Error,
"Concrete methods needn't implement the proper number of arguments if " +
"no definition was provided"
);

View File

@ -133,5 +133,5 @@ assert.throws( function()
{
foo: function() {},
});
}, Error, "Cannot override property with a method" );
}, TypeError, "Cannot override property with a method" );