mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1386026 - Make SpiderMonkey Debugger tests pass even though async generators are Nightly-only. r=tromey
This commit is contained in:
parent
bd614d3abf
commit
046aad9039
20
js/src/jit-test/lib/nightly-only.js
Normal file
20
js/src/jit-test/lib/nightly-only.js
Normal file
@ -0,0 +1,20 @@
|
||||
// Some experimental features are enabled only on nightly builds, and disabled
|
||||
// on beta and release. Tests for these features should not simply disable
|
||||
// themselves on all but nightly builds, because if we neglect to update such
|
||||
// tests once the features cease to be experimental, we'll silently skip the
|
||||
// tests on beta and release, even though they should run.
|
||||
|
||||
// Call the function f. On beta and release, expect it to throw an error that is
|
||||
// an instance of error.
|
||||
function nightlyOnly(error, f) {
|
||||
if (getBuildConfiguration().release_or_beta) {
|
||||
try {
|
||||
f();
|
||||
throw new Error("use of feature expected to fail on release and beta, but succeeded; please update test");
|
||||
} catch (e if e instanceof error) {
|
||||
// All is well.
|
||||
}
|
||||
} else {
|
||||
f();
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
// Debugger.Object.prototype.displayName
|
||||
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
var name;
|
||||
@ -17,5 +19,7 @@ g.eval("var a = {}; a.f = function() { debugger; }; a.f()");
|
||||
assertEq(name, "a.f");
|
||||
g.eval("(async function grondo() { debugger; })();");
|
||||
assertEq(name, "grondo");
|
||||
g.eval("(async function* estux() { debugger; })().next();");
|
||||
assertEq(name, "estux");
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
g.eval("(async function* estux() { debugger; })().next();");
|
||||
assertEq(name, "estux");
|
||||
})
|
||||
|
@ -1,13 +1,17 @@
|
||||
// The .environment of a function Debugger.Object is an Environment object.
|
||||
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal()
|
||||
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);
|
||||
let completion = gDO.executeInGlobal(expr);
|
||||
if (completion.throw)
|
||||
throw completion.throw.unsafeDereference();
|
||||
assertEq(completion.return.environment instanceof Debugger.Environment, true);
|
||||
}
|
||||
|
||||
g.eval('function j(a) { }');
|
||||
@ -17,4 +21,6 @@ check('(() => { })');
|
||||
check('(function f() { })');
|
||||
check('(function* g() { })');
|
||||
check('(async function m() { })');
|
||||
check('(async function* n() { })');
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
check('(async function* n() { })');
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Debugger.Object.prototype.name
|
||||
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
var name;
|
||||
@ -13,5 +15,7 @@ g.eval("Function('debugger;')();");
|
||||
assertEq(name, "anonymous");
|
||||
g.eval("(async function grondo() { debugger; })();");
|
||||
assertEq(name, "grondo");
|
||||
g.eval("(async function* estux() { debugger; })().next();");
|
||||
assertEq(name, "estux");
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
g.eval("(async function* estux() { debugger; })().next();");
|
||||
assertEq(name, "estux");
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
load(libdir + 'array-compare.js');
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = new Debugger;
|
||||
@ -7,7 +8,12 @@ var hits = 0;
|
||||
|
||||
function check(expr, expected) {
|
||||
print("checking " + uneval(expr));
|
||||
let fn = gDO.executeInGlobal(expr).return;
|
||||
|
||||
let completion = gDO.executeInGlobal(expr);
|
||||
if (completion.throw)
|
||||
throw completion.throw.unsafeDereference();
|
||||
|
||||
let fn = completion.return;
|
||||
if (expected === undefined)
|
||||
assertEq(fn.parameterNames, undefined);
|
||||
else
|
||||
@ -24,4 +30,6 @@ check('(function (a, [b, c], {d, e:f}) { })',
|
||||
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"]);
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
check('(async function* (d, e, f) {})', ["d", "e", "f"]);
|
||||
});
|
||||
|
@ -1,3 +1,5 @@
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = new Debugger;
|
||||
var gDO = dbg.addDebuggee(g);
|
||||
@ -5,7 +7,12 @@ var gDO = dbg.addDebuggee(g);
|
||||
function check(expr, expected) {
|
||||
print("checking " + uneval(expr) + ", expecting " +
|
||||
(expected ? "script" : "no script"));
|
||||
let val = gDO.executeInGlobal(expr).return;
|
||||
|
||||
let completion = gDO.executeInGlobal(expr);
|
||||
if (completion.throw)
|
||||
throw completion.throw.unsafeDereference();
|
||||
|
||||
let val = completion.return;
|
||||
if (expected)
|
||||
assertEq(val.script instanceof Debugger.Script, true);
|
||||
else
|
||||
@ -15,6 +22,8 @@ function check(expr, expected) {
|
||||
check('(function g(){})', true);
|
||||
check('(function* h() {})', true);
|
||||
check('(async function j() {})', true);
|
||||
check('(async function* k() {})', true);
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
check('(async function* k() {})', true);
|
||||
});
|
||||
check('({})', false);
|
||||
check('Math.atan2', false);
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Debugger.Script.prototype.isAsyncFunction, Debugger.Object.prototype.isAsyncFunction,
|
||||
// Debugger.Script.prototype.isGeneratorFunction, Debugger.Object.prototype.isGeneratorFunction
|
||||
|
||||
load(libdir + 'nightly-only.js');
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = new Debugger();
|
||||
var gDO = dbg.addDebuggee(g);
|
||||
@ -9,8 +11,11 @@ g.non_debuggee = function non_debuggee () {}
|
||||
function checkExpr(expr, { isAsync, isGenerator })
|
||||
{
|
||||
print("Evaluating: " + uneval(expr));
|
||||
let fn = gDO.executeInGlobal(expr).return;
|
||||
let completion = gDO.executeInGlobal(expr);
|
||||
if (completion.throw)
|
||||
throw completion.throw.unsafeDereference();
|
||||
|
||||
let fn = completion.return;
|
||||
assertEq(fn.isAsyncFunction, isAsync);
|
||||
assertEq(fn.isGeneratorFunction, isGenerator);
|
||||
|
||||
@ -26,15 +31,19 @@ checkExpr('non_debuggee', { isAsync: undefined, isGenerator: undefined });
|
||||
checkExpr('(function(){})', { isAsync: false, isGenerator: false });
|
||||
checkExpr('(function*(){})', { isAsync: false, isGenerator: true });
|
||||
checkExpr('(async function snerf(){})', { isAsync: true, isGenerator: false });
|
||||
checkExpr('(async function* omlu(){})', { isAsync: true, isGenerator: true });
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
checkExpr('(async function* omlu(){})', { isAsync: true, isGenerator: true });
|
||||
});
|
||||
|
||||
checkExpr('new Function("1+2")', { isAsync: false, isGenerator: false });
|
||||
checkExpr('Object.getPrototypeOf(function*(){}).constructor("1+2")',
|
||||
{ isAsync: false, isGenerator: true });
|
||||
checkExpr('Object.getPrototypeOf(async function(){}).constructor("1+2")',
|
||||
{ isAsync: true, isGenerator: false });
|
||||
checkExpr('Object.getPrototypeOf(async function*(){}).constructor("1+2")',
|
||||
{ isAsync: true, isGenerator: true });
|
||||
nightlyOnly(g.SyntaxError, () => {
|
||||
checkExpr('Object.getPrototypeOf(async function*(){}).constructor("1+2")',
|
||||
{ isAsync: true, isGenerator: true });
|
||||
});
|
||||
|
||||
// Check eval scripts.
|
||||
function checkFrame(expr, type)
|
||||
|
Loading…
Reference in New Issue
Block a user