зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1083482 part 2 - Fix/remove shell tests that used legacy generators. r=arai
This commit is contained in:
Родитель
b4503bfe8c
Коммит
55162d706b
|
@ -1153,13 +1153,6 @@ function test_syntax(postfixes, check_error, ignore_opts) {
|
|||
test("(function () 1 ");
|
||||
test("(function () 1); ");
|
||||
|
||||
// Legacy generator
|
||||
|
||||
test("function f() { (yield ");
|
||||
test("function f() { (yield 1 ");
|
||||
test("function f() { f(yield ");
|
||||
test("function f() { f(yield 1 ");
|
||||
|
||||
// for each...in
|
||||
|
||||
enableForEach();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if (!this.hasOwnProperty("TypedObject"))
|
||||
quit();
|
||||
|
||||
Array.prototype[Symbol.iterator] = function() {
|
||||
Array.prototype[Symbol.iterator] = function*() {
|
||||
for (var i = 3; --i >= 0;) {
|
||||
yield this[i]
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
if (!this.hasOwnProperty("TypedObject"))
|
||||
throw new RangeError();
|
||||
|
||||
function eval() {
|
||||
function* eval() {
|
||||
yield(undefined)
|
||||
}
|
||||
new TypedObject.StructType();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
for (x in (function() {
|
||||
for (x in (function*() {
|
||||
eval("arguments[0]");
|
||||
yield;
|
||||
})())(function() {})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function a(b=3) {
|
||||
function* a(b=3) {
|
||||
yield
|
||||
}
|
||||
a()
|
||||
|
|
|
@ -27,4 +27,4 @@ assertThrowsInstanceOf(function () {
|
|||
assertThrowsInstanceOf(function () {
|
||||
eval("function f(a=1,b=1,a=1) {}");
|
||||
}, SyntaxError);
|
||||
function silly_but_okay(a=(function () { yield 97; })) {}
|
||||
function silly_but_okay(a=(function* () { yield 97; })) {}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
var args;
|
||||
|
||||
function upToTen()
|
||||
function* upToTen()
|
||||
{
|
||||
"use strict";
|
||||
eval("args = arguments;");
|
||||
|
@ -15,7 +15,7 @@ function upToTen()
|
|||
var gen = upToTen();
|
||||
|
||||
var i = 0;
|
||||
for (var v in gen)
|
||||
for (var v of gen)
|
||||
{
|
||||
assertEq(v, i);
|
||||
i++;
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
// Binary: cache/js-dbg-64-93d2eef52108-linux
|
||||
// Flags:
|
||||
//
|
||||
for(e in((function x(){yield(p=x())})())){}
|
|
@ -2,10 +2,10 @@
|
|||
// Flags:
|
||||
//
|
||||
function f(a) {
|
||||
function g() {
|
||||
function* g() {
|
||||
yield function () { return a; };
|
||||
}
|
||||
return g();
|
||||
}
|
||||
var x;
|
||||
f(7).next()();
|
||||
assertEq(f(7).next().value(), 7);
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// Binary: cache/js-dbg-64-fe4489fb36ab-linux
|
||||
// Flags:
|
||||
//
|
||||
function
|
||||
eval( ) { eval();}
|
||||
try {
|
||||
DoWhile_3();
|
||||
} catch(e) {
|
||||
}
|
||||
function DoWhile_3() {
|
||||
var result2 = "pass";
|
||||
woohooboy: {
|
||||
eval('(function() { x getter= function(){} ; var x5, x = 0x99; })();');
|
||||
}
|
||||
}
|
||||
test();
|
||||
function test()
|
||||
{
|
||||
function foopy()
|
||||
{
|
||||
var f = function(){ r = arguments; test(); yield 170; }
|
||||
try { for (var i in f()) { } } catch (iterError) { }
|
||||
}
|
||||
foopy();
|
||||
gc();
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// |jit-test| error:ReferenceError
|
||||
|
||||
// Binary: cache/js-dbg-64-609f37c36bd7-linux
|
||||
// Flags: -j -m -a
|
||||
//
|
||||
|
||||
function toSource(arr) {
|
||||
for (i=0; i<len; i++) {}
|
||||
}
|
||||
test();
|
||||
function test() {
|
||||
function gen() {
|
||||
var c = test;
|
||||
try {
|
||||
yield c;
|
||||
} finally {
|
||||
this.toSource();
|
||||
}
|
||||
}
|
||||
var iter = gen();
|
||||
for (i in iter) {
|
||||
500();
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// |jit-test| need-for-each
|
||||
|
||||
// Binary: cache/js-dbg-32-ebafee0cea36-linux
|
||||
// Flags: -m -n
|
||||
//
|
||||
function tryItOut(code) {
|
||||
f = eval("(function(){" + code + "})")
|
||||
for (e in f()) {}
|
||||
}
|
||||
tryItOut("\
|
||||
for each(x in[0,0,0,0,0,0,0]) {\
|
||||
function f(b) {\
|
||||
Object.defineProperty(b,\"\",({t:f}))\
|
||||
}\
|
||||
for each(d in[(1),String,String,String,String,(0),String,(1),String]) {\
|
||||
try{\
|
||||
f(d);\
|
||||
yield\
|
||||
}catch(e){}\
|
||||
}\
|
||||
}\
|
||||
")
|
|
@ -11,5 +11,5 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
|
|||
poppedFrames.indexOf(this)
|
||||
}
|
||||
};
|
||||
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
assertEq(g.eval("var t = 0; for (j in g()) t += j; t;"), 45);
|
||||
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
assertEq(g.eval("var t = 0; for (j of g()) t += j; t;"), 45);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function gen() {
|
||||
function* gen() {
|
||||
try {
|
||||
yield 3;
|
||||
} finally {
|
||||
|
@ -6,6 +6,6 @@ function gen() {
|
|||
}
|
||||
}
|
||||
try {
|
||||
for (var i in gen())
|
||||
for (var i of gen())
|
||||
foo();
|
||||
} catch (e) {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// |jit-test| error: ReferenceError
|
||||
var k = 0;
|
||||
function test() {
|
||||
function gen() {
|
||||
function* gen() {
|
||||
try {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -12,8 +12,9 @@ function test() {
|
|||
} finally { }
|
||||
}
|
||||
try {
|
||||
for (var i in gen())
|
||||
test();
|
||||
var g = gen();
|
||||
assertEq(g.next().value, 1);
|
||||
g.next();
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// Don't crash
|
||||
|
||||
function g(foo) {
|
||||
for (a in foo) {
|
||||
}
|
||||
}
|
||||
|
||||
var makegen = eval("\n\
|
||||
(function(b) {\n\
|
||||
var h = \n\
|
||||
eval(\"new function() { yield print(b) }\" ); \n\
|
||||
return h\n\
|
||||
})\n\
|
||||
");
|
||||
|
||||
g(makegen());
|
|
@ -1,5 +1,5 @@
|
|||
function f(a) {
|
||||
function g() {
|
||||
function* g() {
|
||||
yield function () { return a; };
|
||||
}
|
||||
if (a == 8)
|
||||
|
@ -9,4 +9,4 @@ function f(a) {
|
|||
var x;
|
||||
for (var i = 0; i < 9; i++)
|
||||
x = f(i);
|
||||
x.next()(); // ReferenceError: a is not defined.
|
||||
x.next().value(); // ReferenceError: a is not defined.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var t;
|
||||
(function () {
|
||||
t = (function() {
|
||||
t = (function*() {
|
||||
yield k();
|
||||
})();
|
||||
function h() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
f = (function() {
|
||||
f = (function*() {
|
||||
for (x in [arguments, arguments]) yield(gczeal(4, function(){}))
|
||||
})
|
||||
for (i in f()) {}
|
||||
});
|
||||
for (i of f()) {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function() {
|
||||
(function*() {
|
||||
{
|
||||
let d;
|
||||
yield
|
||||
|
@ -6,6 +6,6 @@
|
|||
})()
|
||||
eval("\
|
||||
(function(){\
|
||||
schedulegc(5), 'a'.replace(/a/,function(){yield})\
|
||||
schedulegc(5), 'a'.replace(/a/,function*(){yield})\
|
||||
})\
|
||||
")()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| error: ReferenceError;
|
||||
gczeal(4);
|
||||
function gen() {
|
||||
function* gen() {
|
||||
var c = [1, "x"];
|
||||
try {
|
||||
yield c;
|
||||
|
@ -9,6 +9,6 @@ function gen() {
|
|||
}
|
||||
}
|
||||
var iter = gen();
|
||||
for (i in iter) {
|
||||
for (i of iter) {
|
||||
(SECTION)();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function gen()
|
||||
function* gen()
|
||||
{
|
||||
var local = new Date();
|
||||
yield 1;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
function foo(str) {
|
||||
function* foo(str) {
|
||||
var x = eval(str); yield x[0];
|
||||
}
|
||||
for (var i = 0; i < 5; i++)
|
||||
assertEq(foo("[4,5,6]").next(), 4);
|
||||
assertEq(foo("[4,5,6]").next().value, 4);
|
||||
for (var i = 0; i < 5; i++)
|
||||
assertEq(foo("arguments").next(), "arguments");
|
||||
assertEq(foo("arguments").next().value, "arguments");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
load(libdir + "evalInFrame.js");
|
||||
|
||||
function f() {
|
||||
function* f() {
|
||||
{
|
||||
let x = 1;
|
||||
while (true) {
|
||||
|
@ -16,24 +16,24 @@ function f() {
|
|||
}
|
||||
|
||||
var gen = f();
|
||||
assertEq(gen.next(), 1);
|
||||
assertEq(gen.next(), 2);
|
||||
assertEq(gen.next().value, 1);
|
||||
assertEq(gen.next().value, 2);
|
||||
gc();
|
||||
assertEq(gen.next(), 3);
|
||||
assertEq(gen.next().value, 3);
|
||||
gc();
|
||||
assertEq(gen.next(), 2);
|
||||
assertEq(gen.next(), 2);
|
||||
assertEq(gen.next().value, 2);
|
||||
assertEq(gen.next().value, 2);
|
||||
gc();
|
||||
assertEq(gen.next(), 3);
|
||||
assertEq(gen.next().value, 3);
|
||||
gc();
|
||||
assertEq(gen.next(), 3);
|
||||
assertEq(gen.next(), 2);
|
||||
assertEq(gen.next().value, 3);
|
||||
assertEq(gen.next().value, 2);
|
||||
gc();
|
||||
assertEq(gen.next(), 3);
|
||||
assertEq(gen.next().value, 3);
|
||||
gen = null;
|
||||
gc();
|
||||
|
||||
function g() {
|
||||
function* g() {
|
||||
{
|
||||
let x = 1;
|
||||
while (true) {
|
||||
|
@ -46,8 +46,8 @@ function g() {
|
|||
}
|
||||
|
||||
var gen = g();
|
||||
var g1 = gen.next();
|
||||
var g2 = gen.next();
|
||||
var g1 = gen.next().value;
|
||||
var g2 = gen.next().value;
|
||||
gc();
|
||||
assertEq(g1(1), 2);
|
||||
assertEq(g2(1), 3);
|
||||
|
|
|
@ -32,7 +32,7 @@ function checkCommon(f, makeFn) {
|
|||
};
|
||||
};
|
||||
assertEqArray(makeFn("...arg")(f, itr), [1, 2, 3]);
|
||||
function gen() {
|
||||
function* gen() {
|
||||
for (let i = 1; i < 4; i ++)
|
||||
yield i;
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
const C = function (a, b, c) {
|
||||
return function C() {
|
||||
this.m1 = function () { return a; };
|
||||
this.m2 = function () { return b; };
|
||||
this.m3 = function () { return c; };
|
||||
}
|
||||
}(2,3,4);
|
||||
var c = new C();
|
||||
var d = function (e) {return {m0: function () { return e; }}}(5);
|
||||
for (var i = 0; i < 5; i++)
|
||||
d.m0();
|
||||
C.call(d);
|
||||
d.__iterator__ = function() {yield 55};
|
||||
for (i = 0; i < 5; i++) {
|
||||
for (j in d)
|
||||
print(j);
|
||||
}
|
|
@ -2,14 +2,14 @@ function g(e) {
|
|||
return ("" + e);
|
||||
}
|
||||
|
||||
function blah() {
|
||||
function* blah() {
|
||||
do {
|
||||
yield;
|
||||
} while ({}(p = arguments));
|
||||
}
|
||||
rv = blah();
|
||||
try {
|
||||
for (a in rv) ;
|
||||
for (a of rv) ;
|
||||
} catch (e) {
|
||||
print("" + g(e));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// don't panic
|
||||
|
||||
f = function() {
|
||||
f = function*() {
|
||||
x = yield
|
||||
}
|
||||
rv = f()
|
||||
for (a in rv) (function() {})
|
||||
for (a of rv) (function() {})
|
||||
x = new Proxy({}, (function() {
|
||||
return {
|
||||
defineProperty: gc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var gen = (function () {yield})();
|
||||
var gen = (function* () {yield})();
|
||||
var t = gen.throw;
|
||||
try {
|
||||
new t;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
function g(code) {
|
||||
f = Function(code);
|
||||
for (a in f()) {}
|
||||
}
|
||||
|
||||
/* Get call ic in a state to call CompileFunction for new functions. */
|
||||
g()
|
||||
g("(function(){})")
|
||||
g()
|
||||
|
||||
/* Call generator with frame created by call ic + CompileFunction. */
|
||||
g("yield")
|
|
@ -1,6 +0,0 @@
|
|||
if (this.dis !== undefined) {
|
||||
var generatorPrototype = (function() { yield 3; })().__proto__;
|
||||
try {
|
||||
this.dis(generatorPrototype);
|
||||
} catch(e) {}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
f = eval("\
|
||||
(function() {\
|
||||
with({}) {\
|
||||
yield\
|
||||
}\
|
||||
for(let d in[gc()])\
|
||||
for(b in[0,function(){}]);\
|
||||
})\
|
||||
")
|
||||
for (e in f()) {}
|
|
@ -65,7 +65,7 @@ test("new Number(1)", n => Number.prototype.valueOf.call(n));
|
|||
test("new Number(1)", n => Number.prototype.toFixed.call(n));
|
||||
test("new Number(1)", n => Number.prototype.toExponential.call(n));
|
||||
test("new Number(1)", n => Number.prototype.toPrecision.call(n));
|
||||
test("(function(){yield 1})()", i => (function(){yield})().next.call(i).toString());
|
||||
test("(function*(){yield 1})()", i => (function*(){yield})().next.call(i).toString());
|
||||
test("new String('one')", s => String.prototype.toSource.call(s));
|
||||
test("new String('one')", s => String.prototype.toString.call(s));
|
||||
test("new RegExp('1')", r => RegExp.prototype.exec.call(r, '1').toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
w = (function() { yield })();
|
||||
w = (function*() { yield })();
|
||||
w.next();
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
for (v in w) {}
|
||||
for (v of w) {}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ function foo(arr) {
|
|||
return not_defined;
|
||||
}
|
||||
|
||||
function gen() {
|
||||
function* gen() {
|
||||
try {
|
||||
yield 1;
|
||||
} finally {
|
||||
|
@ -16,8 +16,7 @@ function gen() {
|
|||
|
||||
function test() {
|
||||
var i_have_locals;
|
||||
for (i in gen()) {
|
||||
"this won't work"();
|
||||
for (i of gen()) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
// |jit-test| need-for-each
|
||||
|
||||
function testGeneratorDeepBail() {
|
||||
function g() { yield 2; }
|
||||
function* g() { yield 2; }
|
||||
var iterables = [[1], [], [], [], g()];
|
||||
|
||||
var total = 0;
|
||||
for (let i = 0; i < iterables.length; i++)
|
||||
for each (let j in iterables[i])
|
||||
total += j;
|
||||
for (let j of iterables[i])
|
||||
total += j;
|
||||
return total;
|
||||
}
|
||||
assertEq(testGeneratorDeepBail(), 3);
|
||||
|
|
|
@ -13,7 +13,7 @@ const N = 10;
|
|||
for (var i = 0; i < N; ++i) {
|
||||
g.escaped = undefined;
|
||||
g.eval("function h() { debugger }");
|
||||
g.eval("(function () { var y = {p:42}; h(); yield })().next();");
|
||||
g.eval("(function* () { var y = {p:42}; h(); yield })().next();");
|
||||
assertEq(g.eval("escaped().p"), 42);
|
||||
arr.push(g.escaped);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function testInterpreterReentry3() {
|
||||
for (let i=0;i<5;++i) this["y" + i] = function(){};
|
||||
this.__defineGetter__('e', function (x2) { yield; });
|
||||
this.__defineGetter__('e', function* (x2) { yield; });
|
||||
return 1;
|
||||
}
|
||||
assertEq(testInterpreterReentry3(), 1);
|
||||
|
|
|
@ -3,6 +3,6 @@ y = {}
|
|||
y.v = "";
|
||||
[0, 0].forEach(function() {
|
||||
for (p in y) {
|
||||
x.eval("function f(){yield e}")
|
||||
x.eval("function* f(){yield e}")
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
for (a in (eval("\
|
||||
for (a of (eval("\
|
||||
(function() {\
|
||||
return function() {\
|
||||
return function*() {\
|
||||
yield ((function() {\
|
||||
return d\
|
||||
})())\
|
||||
|
|
|
@ -3,7 +3,7 @@ function m() {
|
|||
|
||||
return (eval("\n\
|
||||
(function() {\n\
|
||||
return function() {\n\
|
||||
return function*() {\n\
|
||||
yield ((function() {\n\
|
||||
print(d);\n\
|
||||
return d\n\
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// The argument to Map can be a generator.
|
||||
|
||||
var done = false;
|
||||
function data(n) {
|
||||
function* data(n) {
|
||||
var s = '';
|
||||
for (var i = 0; i < n; i++) {
|
||||
yield [s, i];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// The argument to Map may be a generator-iterator that produces no values.
|
||||
|
||||
function none() {
|
||||
function* none() {
|
||||
if (0) yield 0;
|
||||
}
|
||||
var m = new Map(none());
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
function data2() {
|
||||
function* data2() {
|
||||
yield [{}, "XR22/Z"];
|
||||
yield [{}, "23D-BN"];
|
||||
throw "oops";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// The argument to Set can be a generator.
|
||||
|
||||
function hexData(n) {
|
||||
function* hexData(n) {
|
||||
for (var i = 0; i < n; i++)
|
||||
yield i.toString(16);
|
||||
}
|
||||
|
|
|
@ -8,31 +8,13 @@ var k3 = {};
|
|||
|
||||
var done = false;
|
||||
|
||||
function data() {
|
||||
function* data() {
|
||||
yield [k1, v1];
|
||||
yield [k2, v2];
|
||||
done = true;
|
||||
};
|
||||
|
||||
var m = new WeakMap(data());
|
||||
|
||||
assertEq(done, true); // the constructor consumes the argument
|
||||
assertEq(m.has(k1), true);
|
||||
assertEq(m.has(k2), true);
|
||||
assertEq(m.has(k3), false);
|
||||
assertEq(m.get(k1), v1);
|
||||
assertEq(m.get(k2), v2);
|
||||
assertEq(m.get(k3), undefined);
|
||||
|
||||
done = false;
|
||||
|
||||
function* data2() {
|
||||
yield [k1, v1];
|
||||
yield [k2, v2];
|
||||
done = true;
|
||||
};
|
||||
|
||||
m = new WeakMap(data2());
|
||||
m = new WeakMap(data());
|
||||
|
||||
assertEq(done, true); // the constructor consumes the argument
|
||||
assertEq(m.has(k1), true);
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
// The argument to WeakMap may be a generator-iterator that produces no values.
|
||||
|
||||
function none() {
|
||||
function* none() {
|
||||
if (0) yield 0;
|
||||
}
|
||||
new WeakMap(none());
|
||||
|
||||
function* none2() {
|
||||
if (0) yield 0;
|
||||
}
|
||||
new WeakMap(none2());
|
||||
|
|
|
@ -3,20 +3,11 @@
|
|||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
function data() {
|
||||
function* data() {
|
||||
yield [{}, "XR22/Z"];
|
||||
yield [{}, "23D-BN"];
|
||||
throw "oops";
|
||||
}
|
||||
|
||||
var it = data();
|
||||
assertThrowsValue(() => new WeakMap(it), "oops");
|
||||
|
||||
function* data2() {
|
||||
yield [{}, "XR22/Z"];
|
||||
yield [{}, "23D-BN"];
|
||||
throw "oops";
|
||||
}
|
||||
|
||||
var it2 = data2();
|
||||
var it2 = data();
|
||||
assertThrowsValue(() => new WeakMap(it2), "oops");
|
||||
|
|
|
@ -38,7 +38,7 @@ check('j()', 'declarative', null);
|
|||
// All evals get a lexical scope.
|
||||
check('eval("debugger");', 'declarative', null);
|
||||
|
||||
g.eval('function m() { debugger; yield true; }');
|
||||
g.eval('function* m() { debugger; yield true; }');
|
||||
check('m().next();', 'declarative', gw.makeDebuggeeValue(g.m));
|
||||
|
||||
g.eval('function n() { { let x = 1; debugger; } }');
|
||||
|
|
|
@ -18,12 +18,6 @@ function check(gen, label) {
|
|||
assertEq(hits, 1);
|
||||
}
|
||||
|
||||
g.eval('function f(x) { debugger; yield x; }');
|
||||
g.eval('var g = f(2);');
|
||||
g.eval('var h = f(3);');
|
||||
check(g.g, 'g.g');
|
||||
check(g.h, 'g.h');
|
||||
|
||||
g.eval('function* f(x) { debugger; yield x; }');
|
||||
g.eval('var g = f(2);');
|
||||
g.eval('var h = f(3);');
|
||||
|
|
|
@ -89,7 +89,7 @@ function DeepStaticShallowDynamic(i, n) {
|
|||
}
|
||||
g.eval(DeepStaticShallowDynamic(1, N));
|
||||
|
||||
function range(start, stop) {
|
||||
function* range(start, stop) {
|
||||
for (var i = start; i < stop; i++)
|
||||
yield i;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ test("eval('debugger;');", {type: "eval", generator: false, constructing: false}
|
|||
test("this.eval('debugger;'); // indirect eval", {type: "eval", generator: false, constructing: false});
|
||||
test("(function () { eval('debugger;'); })();", {type: "eval", generator: false, constructing: false});
|
||||
test("new function () { eval('debugger'); }", {type: "eval", generator: false, constructing: false});
|
||||
test("function gen() { debugger; yield 1; debugger; }\n" +
|
||||
"for (var x in gen()) {}\n",
|
||||
test("function* gen() { debugger; yield 1; debugger; }\n" +
|
||||
"for (var x of gen()) {}\n",
|
||||
{type: "call", generator: true, constructing: false}, 2);
|
||||
test("var iter = (function* stargen() { debugger; yield 1; debugger; })();\n" +
|
||||
"iter.next(); iter.next();",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
load(libdir + "asserts.js");
|
||||
|
||||
var g = newGlobal();
|
||||
g.eval("function gen(a) { debugger; yield a; }");
|
||||
g.eval("function* gen(a) { debugger; yield a; }");
|
||||
g.eval("function test() { debugger; }");
|
||||
var dbg = new Debugger(g);
|
||||
var genframe;
|
||||
|
@ -15,5 +15,5 @@ dbg.onDebuggerStatement = function (frame) {
|
|||
assertThrowsInstanceOf(function () { genframe.eval("a"); }, Error);
|
||||
hits++;
|
||||
};
|
||||
g.eval("var it = gen(42); assertEq(it.next(), 42); test();");
|
||||
g.eval("var it = gen(42); assertEq(it.next().value, 42); test();");
|
||||
assertEq(hits, 2);
|
||||
|
|
|
@ -18,7 +18,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
|
|||
|
||||
if (frame.eval('i').return % 3 == 0) {
|
||||
frame.onPop = function handlePop(c) {
|
||||
log += ')' + c.return;
|
||||
log += ')' + c.return.unsafeDereference().value;
|
||||
assertEq(debuggerFrames.indexOf(this) != -1, true);
|
||||
assertEq(poppedFrames.indexOf(this), -1);
|
||||
poppedFrames.push(this);
|
||||
|
@ -26,7 +26,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
|
|||
}
|
||||
};
|
||||
|
||||
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
log ='';
|
||||
assertEq(g.eval("var t = 0; for (j in g()) t += j; t;"), 45);
|
||||
assertEq(g.eval("var t = 0; for (j of g()) t += j; t;"), 45);
|
||||
assertEq(log, "d)0ddd)3ddd)6ddd)9");
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// |jit-test| error: StopIteration
|
||||
// Returning {throw:} from an onPop handler when yielding works and
|
||||
// does closes the generator-iterator.
|
||||
|
||||
|
@ -12,10 +11,10 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
|
|||
return {throw: "fit"};
|
||||
};
|
||||
};
|
||||
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
g.eval("var it = g();");
|
||||
var rv = gw.executeInGlobal("it.next();");
|
||||
assertEq(rv.throw, "fit");
|
||||
|
||||
dbg.enabled = false;
|
||||
g.it.next();
|
||||
assertEq(g.it.next().value, undefined);
|
||||
|
|
|
@ -11,9 +11,9 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
|
|||
throw "fit";
|
||||
};
|
||||
};
|
||||
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
|
||||
g.eval("var it = g();");
|
||||
assertEq(gw.executeInGlobal("it.next();"), null);
|
||||
|
||||
dbg.enabled = false;
|
||||
assertEq(g.it.next(), 1);
|
||||
assertEq(g.it.next().value, 1);
|
||||
|
|
|
@ -36,7 +36,5 @@ test("Function('return 2+2;')(); debugger;",
|
|||
"S");
|
||||
test("var obj = {get x() { return 0; }, set x(v) {}}; debugger;",
|
||||
"S[SS]");
|
||||
test("function r(n) { for (var i = 0; i < n; i++) yield i; } debugger;",
|
||||
"S[S]");
|
||||
test("function* qux(n) { for (var i = 0; i < n; i++) yield i; } debugger;",
|
||||
"S[S]");
|
||||
|
|
|
@ -7,7 +7,7 @@ var evalInFrame = (function (global) {
|
|||
var completion = frame.eval(code);
|
||||
};
|
||||
})(this);
|
||||
function f() {
|
||||
function* f() {
|
||||
{
|
||||
let {} = "xxx";
|
||||
yield evalInFrame(0, "x");
|
||||
|
|
|
@ -8,7 +8,7 @@ var hits = 0;
|
|||
dbg.onEnterFrame = function (f) { hits++; };
|
||||
|
||||
try {
|
||||
g.eval("for (c in (function() { yield })()) h");
|
||||
g.eval("for (c in (function*() { yield })()) h");
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
// Closing legacy generators should not invoke the onExceptionUnwind hook.
|
||||
|
||||
var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
dbg.onExceptionUnwind = function (frame, exc) {
|
||||
log += "ERROR";
|
||||
assertEq(0, 1);
|
||||
};
|
||||
g.eval(`
|
||||
var log = "";
|
||||
function f() {
|
||||
function gen() {
|
||||
try {
|
||||
log += "yield";
|
||||
yield 3;
|
||||
yield 4;
|
||||
} catch(e) {
|
||||
log += "catch";
|
||||
} finally {
|
||||
log += "finally";
|
||||
}
|
||||
};
|
||||
var it = gen();
|
||||
assertEq(it.next(), 3);
|
||||
it.close();
|
||||
};
|
||||
f();
|
||||
`);
|
||||
assertEq(g.log, "yieldfinally");
|
|
@ -4,7 +4,7 @@
|
|||
g = newGlobal();
|
||||
g.parent = this;
|
||||
g.eval("Debugger(parent).onExceptionUnwind=(function() {})");
|
||||
function throwInNext() {
|
||||
function* throwInNext() {
|
||||
yield 1;
|
||||
yield 2;
|
||||
yield 3;
|
||||
|
@ -12,7 +12,7 @@ function throwInNext() {
|
|||
}
|
||||
|
||||
function f() {
|
||||
for (var o of new throwInNext);
|
||||
for (var o of throwInNext());
|
||||
}
|
||||
|
||||
var log = "";
|
||||
|
|
|
@ -46,9 +46,6 @@ test(function () { return g.Function("a", "b", "return b - a;"); });
|
|||
// cloning a function with nested functions
|
||||
test(function () { g.clone(evaluate("(function(x) { return x + 1; })")); });
|
||||
|
||||
// eval declaring a generator
|
||||
test(function () { g.eval("function r(n) { for (var i=0;i<n;i++) yield i; }"); });
|
||||
|
||||
// eval declaring a star generator
|
||||
test(function () { g.eval("function* sg(n) { for (var i=0;i<n;i++) yield i; }"); });
|
||||
|
||||
|
|
|
@ -2,18 +2,21 @@
|
|||
// Forced return from a generator frame.
|
||||
|
||||
var g = newGlobal();
|
||||
var val = {value: '!', done: false};
|
||||
g.debuggeeGlobal = this;
|
||||
g.eval("var dbg = new Debugger(debuggeeGlobal);" +
|
||||
"dbg.onDebuggerStatement = function () { return {return: '!'}; };");
|
||||
g.eval("var dbg = new Debugger();" +
|
||||
"var gw = dbg.addDebuggee(debuggeeGlobal);" +
|
||||
"var val = gw.makeDebuggeeValue(debuggeeGlobal.val);" +
|
||||
"dbg.onDebuggerStatement = function () { return {return: val}; };");
|
||||
|
||||
function gen() {
|
||||
function* gen() {
|
||||
yield '1';
|
||||
debugger; // Force return here. The value is ignored.
|
||||
yield '2';
|
||||
}
|
||||
|
||||
var iter = gen();
|
||||
assertEq(iter.next(), "1");
|
||||
assertEq(iter.next(), "!");
|
||||
assertEq(iter.next().value, "1");
|
||||
assertEq(iter.next().value, "!");
|
||||
iter.next();
|
||||
assertEq(0, 1);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// for-of works with generators.
|
||||
|
||||
function range(n) {
|
||||
function* range(n) {
|
||||
for (var i = 0; i < n; i++)
|
||||
yield i;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Generator-iterators are consumed the first time they are iterated.
|
||||
|
||||
function range(n) {
|
||||
function* range(n) {
|
||||
for (var i = 0; i < n; i++)
|
||||
yield i;
|
||||
}
|
||||
|
||||
var r = range(10);
|
||||
var i = 0;
|
||||
for (var x in r)
|
||||
for (var x of r)
|
||||
assertEq(x, i++);
|
||||
assertEq(i, 10);
|
||||
for (var y in r)
|
||||
for (var y of r)
|
||||
throw "FAIL";
|
||||
assertEq(y, undefined);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Nested for-of loops can use the same generator-iterator.
|
||||
|
||||
function range(n) {
|
||||
function* range(n) {
|
||||
for (var i = 0; i < n; i++)
|
||||
yield i;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Breaking out of a for-of loop over a generator-iterator does not close the iterator.
|
||||
// Breaking out of a for-of loop over a generator-iterator closes the generator.
|
||||
|
||||
load(libdir + "iteration.js");
|
||||
|
||||
function range(n) {
|
||||
function* range(n) {
|
||||
for (var i = 0; i < n; i++)
|
||||
yield i;
|
||||
}
|
||||
|
@ -17,4 +17,4 @@ for (var x of r) {
|
|||
s += '/';
|
||||
for (var y of r)
|
||||
s += y;
|
||||
assertEq(s, '01234/56789');
|
||||
assertEq(s, '01234/');
|
||||
|
|
|
@ -13,7 +13,7 @@ for (f().x of [])
|
|||
assertEq(s, '');
|
||||
|
||||
// Test 2: check proper interleaving of f calls, iterator.next() calls, and the loop body.
|
||||
function g() {
|
||||
function* g() {
|
||||
s += 'g';
|
||||
yield 0;
|
||||
s += 'g';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var obj = {};
|
||||
|
||||
// Test 1
|
||||
function g() {
|
||||
function* g() {
|
||||
obj.x = 0;
|
||||
yield 1;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ assertEq(obj.x, 1);
|
|||
assertEq(n, 1);
|
||||
|
||||
// Test 2
|
||||
function h() {
|
||||
function* h() {
|
||||
delete obj.x;
|
||||
yield 3;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function f() {
|
||||
function* f() {
|
||||
try {
|
||||
let foo = 3;
|
||||
for (var i=0; i<50; i++)
|
||||
|
@ -8,4 +8,4 @@ function f() {
|
|||
var it = f();
|
||||
for (var i=0; i<40; i++)
|
||||
it.next();
|
||||
it.close();
|
||||
it.return();
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// |jit-test| error: closing generator
|
||||
var finally3;
|
||||
function gen() {
|
||||
try {
|
||||
try {
|
||||
yield 1;
|
||||
} finally {
|
||||
finally3();
|
||||
}
|
||||
} catch (e) {
|
||||
yield finally3 === parseInt;
|
||||
}
|
||||
}
|
||||
iter = gen();
|
||||
iter.next();
|
||||
iter.close();
|
|
@ -1,6 +1,6 @@
|
|||
if (typeof schedulegc != 'undefined') {
|
||||
Function("\
|
||||
x = (function() { yield })();\
|
||||
x = (function*() { yield })();\
|
||||
new Set(x);\
|
||||
schedulegc(1);\
|
||||
print( /x/ );\
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// OSR into a |finally| block while closing a legacy generator should work.
|
||||
var log = "";
|
||||
function f() {
|
||||
function* f() {
|
||||
try {
|
||||
try {
|
||||
log += "a";
|
||||
|
@ -19,6 +19,6 @@ function f() {
|
|||
}
|
||||
|
||||
var it = f();
|
||||
assertEq(it.next(), 2);
|
||||
it.close();
|
||||
assertEq(it.next().value, 2);
|
||||
it.return();
|
||||
assertEq(log, "acd");
|
||||
|
|
|
@ -40,24 +40,3 @@ var i = h2();
|
|||
assertIteratorNext(i, 1);
|
||||
assertThrowsValue(() => i.return(4), 6);
|
||||
assertIteratorDone(i);
|
||||
|
||||
// Legacy generator, throw() throws.
|
||||
function l1() {
|
||||
yield 1;
|
||||
yield 2;
|
||||
}
|
||||
var i = l1();
|
||||
assertEq(i.next(), 1);
|
||||
assertThrowsValue(() => i.throw(5), 5);
|
||||
assertThrowsInstanceOf(() => i.next(), StopIteration);
|
||||
|
||||
// Legacy generator, next() throws.
|
||||
function l2() {
|
||||
yield 1;
|
||||
throw 6;
|
||||
yield 2;
|
||||
}
|
||||
var i = l2();
|
||||
assertEq(i.next(), 1);
|
||||
assertThrowsValue(() => i.next(), 6);
|
||||
assertThrowsInstanceOf(() => i.next(), StopIteration);
|
||||
|
|
|
@ -3,17 +3,7 @@
|
|||
load(libdir + "asserts.js");
|
||||
load(libdir + "iteration.js");
|
||||
|
||||
function gen() { yield 1; yield 2; }
|
||||
var it = gen();
|
||||
|
||||
var g = newGlobal();
|
||||
g.eval("function gen2() { yield 3; yield 4; }; var it2 = gen2();");
|
||||
|
||||
// LegacyGenerator.next
|
||||
assertEq(it.next.call(g.it2), 3);
|
||||
|
||||
// LegacyGenerator.throw
|
||||
assertThrowsValue(() => it.throw.call(g.it2, 7), 7);
|
||||
|
||||
function *gen3() { yield 1; yield 2; }
|
||||
it = gen3();
|
||||
|
|
|
@ -140,19 +140,6 @@ v = o.next();
|
|||
assertEq(v.done, true);
|
||||
assertEq(v.value, undefined);
|
||||
|
||||
// legacy iterator have no return value
|
||||
function g8() {
|
||||
try {
|
||||
return;
|
||||
} finally {
|
||||
yield 43;
|
||||
}
|
||||
}
|
||||
o = g8();
|
||||
v = o.next();
|
||||
assertEq(v, 43);
|
||||
assertThrowsInstanceOf(() => o.next(), StopIteration);
|
||||
|
||||
// in "with" statement
|
||||
options("strict");
|
||||
eval(`
|
||||
|
|
|
@ -17,16 +17,14 @@ load(libdir + "asserts.js");
|
|||
// This test will need changes if we change our JS >= 1.7 parsing to be
|
||||
// ES6-compatible.
|
||||
|
||||
function f1() {
|
||||
yield /abc/g;
|
||||
// TODO: fix yield in non-generator functions.
|
||||
var ex;
|
||||
try {
|
||||
eval(`function f1() { yield /abc/g; }`);
|
||||
} catch(e) {
|
||||
ex = e;
|
||||
}
|
||||
|
||||
var g = f1();
|
||||
var v;
|
||||
v = g.next();
|
||||
assertEq(v instanceof RegExp, true);
|
||||
assertEq(v.toString(), "/abc/g");
|
||||
assertThrowsValue(() => g.next(), StopIteration);
|
||||
assertEq(ex.message.includes("reserved identifier"), true);
|
||||
|
||||
function* f2() {
|
||||
yield /abc/g;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
function f() {
|
||||
function* f() {
|
||||
yield yield 1;
|
||||
}
|
||||
|
||||
var g = f();
|
||||
assertEq(g.next(), 1);
|
||||
assertEq(g.send("hello"), "hello");
|
||||
assertThrowsValue(() => g.next(), StopIteration);
|
||||
assertEq(g.next().value, 1);
|
||||
assertEq(g.return("hello").value, "hello");
|
||||
assertEq(g.next().value, undefined);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// |jit-test| error:98; need-for-each
|
||||
function foo() {
|
||||
function gen() {
|
||||
function* gen() {
|
||||
try {
|
||||
yield 1;
|
||||
} finally {
|
||||
throw 98;
|
||||
}
|
||||
}
|
||||
for (i in gen()) {
|
||||
for (i of gen()) {
|
||||
for each (var i in this)
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
eval('(function () {\
|
||||
function range(n) {\
|
||||
function* range(n) {\
|
||||
for (var i = 0; i < 5000; i++)\
|
||||
yield i;\
|
||||
}\
|
||||
var r = range(10);\
|
||||
var i = 0;\
|
||||
for (var x in r)\
|
||||
for (var x of r)\
|
||||
assertEq(x,i++);\
|
||||
' + '})();');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
function g() {
|
||||
function* g() {
|
||||
yield
|
||||
}
|
||||
g()
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
(function() {
|
||||
for (e in ((function() {
|
||||
yield
|
||||
})())) return
|
||||
})()
|
||||
/* Don't assert. */
|
|
@ -1,5 +1,5 @@
|
|||
for (a = 0; a < 13; a++) {
|
||||
(function e() {
|
||||
(function* e() {
|
||||
yield eval()
|
||||
}())
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
for (a = 0; a < 13; a++) {
|
||||
(function n() {
|
||||
(function* n() {
|
||||
with({}) {
|
||||
yield
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
for (a = 0; a < 13; a++) {
|
||||
(function n() { {
|
||||
(function* n() { {
|
||||
function s() {}
|
||||
}
|
||||
yield[];
|
||||
|
|
|
@ -8,7 +8,7 @@ function test() {
|
|||
return;
|
||||
|
||||
var catch1, catch2, catch3, finally1, finally2, finally3;
|
||||
function gen() {
|
||||
function* gen() {
|
||||
yield 1;
|
||||
try {
|
||||
try {
|
||||
|
@ -25,6 +25,6 @@ function test() {
|
|||
iter = gen();
|
||||
iter.next();
|
||||
iter.next();
|
||||
iter.close();
|
||||
iter.return();
|
||||
gc();
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
gczeal(2);
|
||||
try {
|
||||
DoWhile_3();
|
||||
} catch (e) {}
|
||||
function f() {
|
||||
test();
|
||||
yield 170;
|
||||
}
|
||||
function test() {
|
||||
function foopy() {
|
||||
try {
|
||||
for (var i in f());
|
||||
} catch (e) {}
|
||||
}
|
||||
foopy();
|
||||
gc();
|
||||
}
|
||||
test();
|
|
@ -1,21 +0,0 @@
|
|||
expected = '';
|
||||
|
||||
function g(code) {
|
||||
f = Function(code);
|
||||
gen = f();
|
||||
gen.next();
|
||||
try { gen.next(); } catch (ex) { expected = ex.toString() }
|
||||
}
|
||||
|
||||
g("\
|
||||
yield this.__defineGetter__('x', function(){ return z }); \
|
||||
let z = new String('hi'); \
|
||||
");
|
||||
|
||||
eval();
|
||||
gc();
|
||||
|
||||
str = x;
|
||||
|
||||
assertEq(expected, "[object StopIteration]");
|
||||
assertEq(str.toString(), "hi");
|
|
@ -1,22 +0,0 @@
|
|||
// |jit-test| error: TypeError
|
||||
|
||||
var lfLogBuffer = `
|
||||
function testcase( [] = (function() { return x++; }), get, target, ... f1) {
|
||||
return function () {
|
||||
} ( ... 2 || (this) ? (yield) : (yield)) ;
|
||||
}
|
||||
`;
|
||||
lfLogBuffer = lfLogBuffer.split('\n');
|
||||
var lfCodeBuffer = "";
|
||||
while (true) {
|
||||
var line = lfLogBuffer.shift();
|
||||
if (line == null) {
|
||||
break;
|
||||
} else {
|
||||
lfCodeBuffer += line + "\n";
|
||||
}
|
||||
}
|
||||
if (lfCodeBuffer) loadFile(lfCodeBuffer);
|
||||
function loadFile(lfVarx) {
|
||||
eval(lfVarx);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
// Legacy generators should be warned once and only once.
|
||||
|
||||
version(170);
|
||||
|
||||
function testWarn(code) {
|
||||
enableLastWarning();
|
||||
var g = newGlobal();
|
||||
g.code = code;
|
||||
g.eval('eval(code)');
|
||||
var warning = getLastWarning();
|
||||
assertEq(warning !== null, true, "warning should be caught for " + code);
|
||||
assertEq(warning.name, "Warning");
|
||||
|
||||
clearLastWarning();
|
||||
g.eval('eval(code)');
|
||||
warning = getLastWarning();
|
||||
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
|
||||
|
||||
clearLastWarning();
|
||||
g = newGlobal();
|
||||
g.code = code;
|
||||
g.eval('Reflect.parse(code);');
|
||||
warning = getLastWarning();
|
||||
assertEq(warning !== null, true, "warning should be caught for " + code);
|
||||
assertEq(warning.name, "Warning");
|
||||
|
||||
clearLastWarning();
|
||||
g.eval('Reflect.parse(code);');
|
||||
warning = getLastWarning();
|
||||
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
|
||||
disableLastWarning();
|
||||
}
|
||||
|
||||
function testPass(code) {
|
||||
enableLastWarning();
|
||||
var g = newGlobal();
|
||||
g.code = code;
|
||||
g.eval('eval(code)');
|
||||
var warning = getLastWarning();
|
||||
assertEq(warning, null, "warning should not be caught for " + code);
|
||||
|
||||
clearLastWarning();
|
||||
g = newGlobal();
|
||||
g.code = code;
|
||||
g.eval('Reflect.parse(code);');
|
||||
warning = getLastWarning();
|
||||
assertEq(warning, null, "warning should not be caught for " + code);
|
||||
disableLastWarning();
|
||||
}
|
||||
|
||||
testWarn("(function() { yield; })");
|
||||
testWarn("function a() { yield; }");
|
||||
|
||||
testPass("(function*() { yield; })");
|
||||
testPass("function* a() { yield; }");
|
|
@ -1,35 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 341675;
|
||||
var summary = 'Iterators: still infinite loop during GC';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
var globalToPokeGC = {};
|
||||
|
||||
function generator()
|
||||
{
|
||||
try {
|
||||
yield [];
|
||||
} finally {
|
||||
make_iterator();
|
||||
}
|
||||
}
|
||||
|
||||
function make_iterator()
|
||||
{
|
||||
var iter = generator();
|
||||
iter.next();
|
||||
}
|
||||
|
||||
make_iterator();
|
||||
gc();
|
||||
|
||||
reportCompare(expect, actual, summary);
|
|
@ -20,7 +20,7 @@ function test()
|
|||
printStatus (summary);
|
||||
|
||||
var iter;
|
||||
function gen()
|
||||
function* gen()
|
||||
{
|
||||
try {
|
||||
yield iter;
|
||||
|
@ -35,14 +35,14 @@ function test()
|
|||
|
||||
expect = 'FINALLY';
|
||||
actual = '';
|
||||
(iter = gen()).next().close();
|
||||
(iter = gen()).next().value.return();
|
||||
reportCompare(expect, actual, summary);
|
||||
|
||||
expect = 'FINALLY';
|
||||
actual = '';
|
||||
try
|
||||
{
|
||||
(iter = gen()).next().throw(1);
|
||||
(iter = gen()).next().value.throw(1);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
|
@ -53,25 +53,12 @@ function test()
|
|||
actual = '';
|
||||
try
|
||||
{
|
||||
(iter = gen()).next().throw(null);
|
||||
(iter = gen()).next().value.throw(null);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
}
|
||||
reportCompare(expect, actual, summary);
|
||||
|
||||
expect = 'FINALLY';
|
||||
actual = '';
|
||||
var expectexcp = '[object StopIteration]';
|
||||
var actualexcp = '';
|
||||
try
|
||||
{
|
||||
(iter = gen()).next().next();
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
actualexcp = ex + '';
|
||||
}
|
||||
reportCompare(expect, actual, summary);
|
||||
reportCompare(expectexcp, actualexcp, summary);
|
||||
reportCompare((iter = gen()).next().value.next().value, undefined, summary);
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 352885;
|
||||
var summary = 'Do not crash iterating over gen.__proto__';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
for (j in ((function() { yield 3; })().__proto__))
|
||||
print(j);
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 352885;
|
||||
var summary = 'Do not crash iterating over gen.__proto__';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
function dotest()
|
||||
{
|
||||
var proto = (function() { yield 3; })().__proto__;
|
||||
|
||||
try {
|
||||
proto.next();
|
||||
throw "generatorProto.next() does not throw TypeError";
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError))
|
||||
throw "generatorProto.next() throws unexpected exception: "+uneval(e);
|
||||
}
|
||||
|
||||
try {
|
||||
proto.send();
|
||||
throw "generatorProto.send() does not throw TypeError";
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError))
|
||||
throw "generatorProto.send() throws unexpected exception: "+uneval(e);
|
||||
}
|
||||
|
||||
var obj = {};
|
||||
try {
|
||||
proto.throw(obj);
|
||||
throw "generatorProto.throw(obj) does not throw TypeError";
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError))
|
||||
throw "generatorProto.throw() throws unexpected exception: "+uneval(e);
|
||||
}
|
||||
|
||||
try {
|
||||
proto.close();
|
||||
throw "generatorProto.close() does not throw TypeError";
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError))
|
||||
throw "generatorProto.close() throws unexpected exception: "+uneval(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dotest();
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 355512;
|
||||
var summary = 'Do not crash with generator arguments';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
function foopy()
|
||||
{
|
||||
var f = function(){ r = arguments; d.d.d; yield 170; }
|
||||
try { for (var i in f()) { } } catch (iterError) { }
|
||||
}
|
||||
|
||||
typeof uneval;
|
||||
foopy();
|
||||
gc();
|
||||
uneval(r);
|
||||
gc();
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 372364;
|
||||
var summary = 'Do not recurse to death on (function() { yield ([15].some([].watch)); })().next()';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
print('FIXME: Fix this test to check the proper error when bug 366669 is fixed');
|
||||
try
|
||||
{
|
||||
(function() { yield ([15].some([].watch)); })().next();
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 387955;
|
||||
var summary = 'Do not Crash [@ TraceEdge]';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
var fal = false;
|
||||
|
||||
function gen() {
|
||||
let x;
|
||||
function y(){}
|
||||
this.__defineGetter__('', function(){});
|
||||
if (fal)
|
||||
yield;
|
||||
}
|
||||
|
||||
for (var i in gen()) { }
|
||||
|
||||
gc();
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 387955;
|
||||
var summary = 'Do not Crash [@ TraceEdge]';
|
||||
var actual = 'No Crash';
|
||||
var expect = 'No Crash';
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
var f;
|
||||
|
||||
function gen(yield_at_least_once) {
|
||||
let x = 11;
|
||||
function y(){}
|
||||
f = function(){ return x; };
|
||||
if (yield_at_least_once)
|
||||
yield;
|
||||
}
|
||||
|
||||
for (var i in gen()) { }
|
||||
|
||||
if (f() !== 11)
|
||||
throw "unexpected value of local x";
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 392308;
|
||||
var summary = 'StopIteration should be catchable';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
function testStop() {
|
||||
function yielder() {
|
||||
actual += 'before, ';
|
||||
yield;
|
||||
actual += 'after, ';
|
||||
}
|
||||
|
||||
expect = 'before, after, iteration terminated normally';
|
||||
|
||||
try {
|
||||
var gen = yielder();
|
||||
result = gen.next();
|
||||
gen.send(result);
|
||||
} catch (x if x instanceof StopIteration) {
|
||||
actual += 'iteration terminated normally';
|
||||
} catch (x2) {
|
||||
actual += 'unexpected throw: ' + x2;
|
||||
}
|
||||
}
|
||||
testStop();
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
|
@ -12,7 +12,7 @@ var expect;
|
|||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
function fib()
|
||||
function* fib()
|
||||
{
|
||||
var a = 0, b = 1;
|
||||
|
||||
|
@ -33,13 +33,13 @@ reportCompare(expect, actual, summary);
|
|||
|
||||
var actual = [];
|
||||
var expect = [0, 1, 1, 2, 3, 5, 8, 13];
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next());
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
actual.push(g.next().value);
|
||||
reportCompare(expect.join(), actual.join(), summary);
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче