Bug 1386026 - Put Debugger tests in simpler form. r=tromey
authorJim Blandy <jimb@mozilla.com>
Mon, 31 Jul 2017 21:12:44 -0700
changeset 420944 b78fd576bdc8d08b630ee3b831352966b90000f2
parent 420943 2e349fb7c36b7b091ae1786b0acf6a4f35d14923
child 420945 3232054e0a930e0eceaa41155ce534f92d717f11
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1386026
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1386026 - Put Debugger tests in simpler form. r=tromey This prepares the tests to have some cases that are nightly-only. There should be no significant effect on what is tested.
js/src/jit-test/tests/debug/Object-environment-02.js
js/src/jit-test/tests/debug/Object-parameterNames.js
js/src/jit-test/tests/debug/Object-script.js
--- a/js/src/jit-test/tests/debug/Object-environment-02.js
+++ b/js/src/jit-test/tests/debug/Object-environment-02.js
@@ -1,29 +1,20 @@
 // The .environment of a function Debugger.Object is an Environment object.
 
 var g = newGlobal()
-var dbg = Debugger(g);
-var hits = 0;
-g.h = function () {
-    var frame = dbg.getNewestFrame();
-    var fn = frame.eval("j").return;
-    assertEq(fn.environment instanceof Debugger.Environment, true);
-    var closure = frame.eval("f").return;
-    assertEq(closure.environment instanceof Debugger.Environment, true);
-    var async_fun = frame.eval("m").return;
-    assertEq(async_fun.environment instanceof Debugger.Environment, true);
-    var async_iter = frame.eval("n").return;
-    assertEq(async_iter.environment instanceof Debugger.Environment, true);
-    hits++;
-};
-g.eval(`
-   function j(a) {
-       var f = function () { return a; };
-       function* g() { }
-       async function m() { }
-       async function* n() { }
-       h();
-       return f;
-   }
-   j(0);
-`);
-assertEq(hits, 1);
+var dbg = new Debugger;
+var gDO = dbg.addDebuggee(g);
+
+function check(expr) {
+  print("checking " + uneval(expr));
+  let val = gDO.executeInGlobal(expr).return;
+  assertEq(val.environment instanceof Debugger.Environment, true);
+}
+
+g.eval('function j(a) { }');
+
+check('j');
+check('(() => { })');
+check('(function f() { })');
+check('(function* g() { })');
+check('(async function m() { })');
+check('(async function* n() { })');
--- a/js/src/jit-test/tests/debug/Object-parameterNames.js
+++ b/js/src/jit-test/tests/debug/Object-parameterNames.js
@@ -1,37 +1,27 @@
 load(libdir + 'array-compare.js');
 
 var g = newGlobal();
-var dbg = new Debugger(g);
+var dbg = new Debugger;
+var gDO = dbg.addDebuggee(g);
 var hits = 0;
-dbg.onDebuggerStatement = function (frame) {
-    var arr = frame.arguments;
-    assertEq(arraysEqual(arr[0].parameterNames, []), true);
-    assertEq(arraysEqual(arr[1].parameterNames, ["x"]), true);
-    assertEq(arraysEqual(arr[2].parameterNames,
-                         ["a","b","c","d","e","f","g","h","i","j","k","l","m",
-                          "n","o","p","q","r","s","t","u","v","w","x","y","z"]),
-             true);
-    assertEq(arraysEqual(arr[3].parameterNames, ["a", (void 0), (void 0)]), true);
-    assertEq(arr[4].parameterNames, (void 0));
-    assertEq(arraysEqual(arr[5].parameterNames, [(void 0), (void 0)]), true);
-    assertEq(arraysEqual(arr[6].parameterNames, ["a", "b", "c"]), true);
-    assertEq(arraysEqual(arr[7].parameterNames, ["d", "e", "f"]), true);
-    assertEq(arr.length, 8);
-    hits++;
-};
+
+function check(expr, expected) {
+  print("checking " + uneval(expr));
+  let fn = gDO.executeInGlobal(expr).return;
+  if (expected === undefined)
+    assertEq(fn.parameterNames, undefined);
+  else
+    assertEq(arraysEqual(fn.parameterNames, expected), true);
+}
 
-g.eval("("
-       + function () {
-           (function () { debugger; }
-            (function () {},
-             function (x) {},
-             function (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) {},
-             function (a, [b, c], {d, e:f}) { },
-             {a:1},
-             Math.atan2,
-             async function (a, b, c) {},
-             async function* (d, e, f) {}
-            ));
-       }
-       +")()");
-assertEq(hits, 1);
+check('(function () {})', []);
+check('(function (x) {})', ["x"]);
+check('(function (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) {})',
+      ["a","b","c","d","e","f","g","h","i","j","k","l","m",
+       "n","o","p","q","r","s","t","u","v","w","x","y","z"]);
+check('(function (a, [b, c], {d, e:f}) { })',
+      ["a", undefined, undefined]);
+check('({a:1})', undefined);
+check('Math.atan2', [undefined, undefined]);
+check('(async function (a, b, c) {})', ["a", "b", "c"]);
+check('(async function* (d, e, f) {})', ["d", "e", "f"]);
--- a/js/src/jit-test/tests/debug/Object-script.js
+++ b/js/src/jit-test/tests/debug/Object-script.js
@@ -1,25 +1,20 @@
 var g = newGlobal();
-var dbg = new Debugger(g);
-var hits = 0;
-dbg.onDebuggerStatement = function (frame) {
-    var arr = frame.arguments;
-    assertEq(arr[0].script instanceof Debugger.Script, true);
-    assertEq(arr[1].script instanceof Debugger.Script, true);
-    assertEq(arr[2].script instanceof Debugger.Script, true);
-    assertEq(arr[3].script instanceof Debugger.Script, true);
-    assertEq(arr[4].script, undefined);
-    assertEq(arr[5].script, undefined);
-    assertEq(arr.length, 6);
-    hits++;
-};
+var dbg = new Debugger;
+var gDO = dbg.addDebuggee(g);
 
-g.eval(`
-    function f() { debugger; }
-    f(function g(){},
-      function* h() {},
-      async function j() {},
-      async function* k() {},
-      {},
-      Math.atan2);
-`);
-assertEq(hits, 1);
+function check(expr, expected) {
+  print("checking " + uneval(expr) + ", expecting " +
+        (expected ? "script" : "no script"));
+  let val = gDO.executeInGlobal(expr).return;
+  if (expected)
+    assertEq(val.script instanceof Debugger.Script, true);
+  else
+    assertEq(val.script, undefined);
+}
+
+check('(function g(){})', true);
+check('(function* h() {})', true);
+check('(async function j() {})', true);
+check('(async function* k() {})', true);
+check('({})', false);
+check('Math.atan2', false);