Revision: 21748
Author:   [email protected]
Date:     Tue Jun 10 15:19:27 2014 UTC
Log:      Add arity checks to mjsunit's assertEquals and assertSame

BUG=None
LOG=n
[email protected]

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

Patch from Erik Arvidsson <[email protected]>.
http://code.google.com/p/v8/source/detail?r=21748

Modified:
 /branches/bleeding_edge/test/mjsunit/mjsunit.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/mjsunit.js Tue May 27 12:52:15 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/mjsunit.js Tue Jun 10 15:19:27 2014 UTC
@@ -231,8 +231,16 @@
     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 @@


   assertEquals = function assertEquals(expected, found, name_opt) {
+    checkArity(arguments, 2, "assertEquals");
+
     if (!deepEquals(found, expected)) {
       fail(PrettyPrint(expected), found, name_opt);
     }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to