Attachment #8767831: Part 1.1: Fix existing tests to follow the behavior change in IteratorNext. for bug #1016936

View | Details | Raw Unified | Return to bug 1016936
Collapse All | Expand All

(-)a/js/src/jit-test/tests/generators/bug931414.js (-1 / +1 lines)
Line     Link Here 
 Lines 1-9    Link Here 
1
// |jit-test| error: is undefined
1
// |jit-test| error: TypeError
2
2
3
load(libdir + "iteration.js");
3
load(libdir + "iteration.js");
4
4
5
function iterable() {
5
function iterable() {
6
  var iterable = {};
6
  var iterable = {};
7
  iterable[Symbol.iterator] = () => ({next: () => void 0});
7
  iterable[Symbol.iterator] = () => ({next: () => void 0});
8
  return iterable;
8
  return iterable;
9
}
9
}
(-)a/js/src/tests/ecma_6/Generators/delegating-yield-1.js (-1 / +1 lines)
Line     Link Here 
 Lines 27-42   function collect_results(iterable) { Link Here 
27
    do {
27
    do {
28
        result = iter.next();
28
        result = iter.next();
29
        ret.push(result);
29
        ret.push(result);
30
    } while (!result.done);
30
    } while (!result.done);
31
    return ret;
31
    return ret;
32
}
32
}
33
33
34
// We have to put a full result for the end, because the return will re-box.
34
// We have to put a full result for the end, because the return will re-box.
35
var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
35
var expected = [{value: 1}, {value: 34, done: true}];
36
36
37
// Sanity check.
37
// Sanity check.
38
assertDeepEq(expected, collect_results(results(expected)));
38
assertDeepEq(expected, collect_results(results(expected)));
39
assertDeepEq(expected, collect_results(yield_results(expected)));
39
assertDeepEq(expected, collect_results(yield_results(expected)));
40
40
41
if (typeof reportCompare == "function")
41
if (typeof reportCompare == "function")
42
    reportCompare(true, true);
42
    reportCompare(true, true);
(-)a/js/src/tests/ecma_6/Generators/delegating-yield-3.js (-6 / +6 lines)
Line     Link Here 
 Lines 5-40   function* delegate(iter) { return yield* Link Here 
5
var GeneratorObjectPrototype = Object.getPrototypeOf(g).prototype;
5
var GeneratorObjectPrototype = Object.getPrototypeOf(g).prototype;
6
var GeneratorObjectPrototype_next = GeneratorObjectPrototype.next;
6
var GeneratorObjectPrototype_next = GeneratorObjectPrototype.next;
7
7
8
// Monkeypatch next on an iterator.
8
// Monkeypatch next on an iterator.
9
var inner = g(20);
9
var inner = g(20);
10
var outer = delegate(inner);
10
var outer = delegate(inner);
11
assertIteratorNext(outer, 0);
11
assertIteratorNext(outer, 0);
12
assertIteratorNext(outer, 1);
12
assertIteratorNext(outer, 1);
13
inner.next = function() { return 0; };
13
inner.next = function() { return { patched: true }; };
14
// 42 yielded directly without re-boxing.
14
// 42 yielded directly without re-boxing.
15
assertEq(0, outer.next());
15
assertEq(true, outer.next().patched);
16
// Outer generator not terminated.
16
// Outer generator not terminated.
17
assertEq(0, outer.next());
17
assertEq(true, outer.next().patched);
18
// Restore.
18
// Restore.
19
inner.next = GeneratorObjectPrototype_next;
19
inner.next = GeneratorObjectPrototype_next;
20
assertIteratorNext(outer, 2);
20
assertIteratorNext(outer, 2);
21
// Repatch.
21
// Repatch.
22
inner.next = function() { return { value: 42, done: true }; };
22
inner.next = function() { return { value: 42, done: true }; };
23
assertIteratorDone(outer, 42);
23
assertIteratorDone(outer, 42);
24
24
25
// Monkeypunch next on the prototype.
25
// Monkeypunch next on the prototype.
26
var inner = g(20);
26
var inner = g(20);
27
var outer = delegate(inner);
27
var outer = delegate(inner);
28
assertIteratorNext(outer, 0);
28
assertIteratorNext(outer, 0);
29
assertIteratorNext(outer, 1);
29
assertIteratorNext(outer, 1);
30
GeneratorObjectPrototype.next = function() { return 0; };
30
GeneratorObjectPrototype.next = function() { return { patched: true }; };
31
// 42 yielded directly without re-boxing.
31
// 42 yielded directly without re-boxing.
32
assertEq(0, GeneratorObjectPrototype_next.call(outer));
32
assertEq(true, GeneratorObjectPrototype_next.call(outer).patched);
33
// Outer generator not terminated.
33
// Outer generator not terminated.
34
assertEq(0, GeneratorObjectPrototype_next.call(outer));
34
assertEq(true, GeneratorObjectPrototype_next.call(outer).patched);
35
// Restore.
35
// Restore.
36
GeneratorObjectPrototype.next = GeneratorObjectPrototype_next;
36
GeneratorObjectPrototype.next = GeneratorObjectPrototype_next;
37
assertIteratorNext(outer, 2);
37
assertIteratorNext(outer, 2);
38
38
39
if (typeof reportCompare == "function")
39
if (typeof reportCompare == "function")
40
    reportCompare(true, true);
40
    reportCompare(true, true);
(-)a/js/src/tests/ecma_6/Generators/delegating-yield-5.js (-1 / +1 lines)
Line     Link Here 
 Lines 23-37   function collect_results(iterable) { Link Here 
23
    do {
23
    do {
24
        result = iter.next();
24
        result = iter.next();
25
        ret.push(result);
25
        ret.push(result);
26
    } while (!result.done);
26
    } while (!result.done);
27
    return ret;
27
    return ret;
28
}
28
}
29
29
30
// We have to put a full result for the end, because the return will re-box.
30
// We have to put a full result for the end, because the return will re-box.
31
var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
31
var expected = [{value: 1}, {value: 34, done: true}];
32
32
33
assertDeepEq(expected, collect_results(results(expected)));
33
assertDeepEq(expected, collect_results(results(expected)));
34
assertDeepEq(expected, collect_results(yield_results(expected, 20)));
34
assertDeepEq(expected, collect_results(yield_results(expected, 20)));
35
35
36
if (typeof reportCompare == "function")
36
if (typeof reportCompare == "function")
37
    reportCompare(true, true);
37
    reportCompare(true, true);
(-)a/js/src/tests/ecma_6/Generators/delegating-yield-7.js (-1 / +1 lines)
Line     Link Here 
 Lines 23-38   function collect_results(iter) { Link Here 
23
    do {
23
    do {
24
        result = iter.next();
24
        result = iter.next();
25
        ret.push(result);
25
        ret.push(result);
26
    } while (!result.done);
26
    } while (!result.done);
27
    return ret;
27
    return ret;
28
}
28
}
29
29
30
// We have to put a full result for the end, because the return will re-box.
30
// We have to put a full result for the end, because the return will re-box.
31
var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
31
var expected = [{value: 1}, {value: 34, done: true}];
32
32
33
// Sanity check.
33
// Sanity check.
34
assertDeepEq(expected, collect_results(results(expected)));
34
assertDeepEq(expected, collect_results(results(expected)));
35
assertDeepEq(expected, collect_results(yield_results(expected)));
35
assertDeepEq(expected, collect_results(yield_results(expected)));
36
36
37
if (typeof reportCompare == "function")
37
if (typeof reportCompare == "function")
38
    reportCompare(true, true);
38
    reportCompare(true, true);

Return to bug 1016936