Add arity checks to mjsunit's assertEquals and assertSame

BUG=None
LOG=n
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/309173003

Patch from Erik Arvidsson <arv@chromium.org>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21748 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 81f04448
......@@ -231,8 +231,16 @@ var assertUnoptimized;
return deepObjectEquals(a, b);
}
function checkArity(args, arity, name) {
if (args.length < arity) {
fail(PrettyPrint(arity), args.length,
name + " requires " + arity + " or more arguments");
}
}
assertSame = function assertSame(expected, found, name_opt) {
checkArity(arguments, 2, "assertSame");
// TODO(mstarzinger): We should think about using Harmony's egal operator
// or the function equivalent Object.is() here.
if (found === expected) {
......@@ -245,6 +253,8 @@ var assertUnoptimized;
assertEquals = function assertEquals(expected, found, name_opt) {
checkArity(arguments, 2, "assertEquals");
if (!deepEquals(found, expected)) {
fail(PrettyPrint(expected), found, name_opt);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment