ufuzz: workaround for Function.toString() v2 (#1700)
authorAlex Lam S.L <alexlamsl@gmail.com>
Mon, 27 Mar 2017 13:49:08 +0000 (21:49 +0800)
committerGitHub <noreply@github.com>
Mon, 27 Mar 2017 13:49:08 +0000 (21:49 +0800)
test/ufuzz.js

index 491526d..c1ac8f4 100644 (file)
@@ -121,7 +121,20 @@ var TYPEOF_OUTCOMES = [
   'symbol',
   'crap' ];
 
-var FUNC_TOSTRING = 'Function.prototype.toString=function(){return"function(){}"};';
+var FUNC_TOSTRING = [
+    "Function.prototype.toString = function() {",
+    "    var ids = [];",
+    "    return function() {",
+    "        var i = ids.indexOf(this);",
+    "        if (i < 0) {",
+    "            i = ids.length;",
+    "            ids.push(this);",
+    "        }",
+    '        return "[Function: __func_" + i + "__]";',
+    "    }",
+    "}();",
+    ""
+].join("\n");
 
 function run_code(code) {
     var stdout = "";