Skip to content

Commit 54ccd77

Browse files
review feedback
1 parent 84bf66f commit 54ccd77

File tree

6 files changed

+60
-97
lines changed

6 files changed

+60
-97
lines changed

test/built-ins/Iterator/prototype/drop/exhaustion-does-not-call-return.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,21 @@ info: |
1616
features: [iterator-helpers]
1717
flags: []
1818
---*/
19+
function* g() {
20+
yield 0;
21+
yield 1;
22+
yield 2;
23+
}
24+
1925
class TestIterator extends Iterator {
20-
constructor() {
21-
super();
22-
this._remaining = 3;
23-
}
24-
next() {
25-
if (this._remaining > 0) {
26-
return {
27-
done: false,
28-
value: this._remaining--,
29-
};
30-
} else {
31-
return {
32-
done: true,
33-
value: undefined,
34-
};
35-
}
26+
get next() {
27+
let n = g();
28+
return function() {
29+
return n.next();
30+
};
3631
}
3732
return() {
38-
if (this._remaining <= 0) {
39-
throw new Test262Error();
40-
}
41-
return {};
33+
throw new Test262Error();
4234
}
4335
}
4436

test/built-ins/Iterator/prototype/filter/exhaustion-does-not-call-return.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,21 @@ info: |
1313
features: [iterator-helpers]
1414
flags: []
1515
---*/
16+
function* g() {
17+
yield 0;
18+
yield 1;
19+
yield 2;
20+
}
21+
1622
class TestIterator extends Iterator {
17-
constructor() {
18-
super();
19-
this._remaining = 3;
20-
}
21-
next() {
22-
if (this._remaining > 0) {
23-
return {
24-
done: false,
25-
value: this._remaining--,
26-
};
27-
} else {
28-
return {
29-
done: true,
30-
value: undefined,
31-
};
32-
}
23+
get next() {
24+
let n = g();
25+
return function() {
26+
return n.next();
27+
};
3328
}
3429
return() {
35-
if (this._remaining <= 0) {
36-
throw new Test262Error();
37-
}
38-
return {};
30+
throw new Test262Error();
3931
}
4032
}
4133

test/built-ins/Iterator/prototype/flatMap/exhaustion-does-not-call-return.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,21 @@ info: |
1010
features: [iterator-helpers]
1111
flags: []
1212
---*/
13+
function* g() {
14+
yield 0;
15+
yield 1;
16+
yield 2;
17+
}
18+
1319
class TestIterator extends Iterator {
14-
constructor() {
15-
super();
16-
this._remaining = 3;
17-
}
18-
next() {
19-
if (this._remaining > 0) {
20-
return {
21-
done: false,
22-
value: this._remaining--,
23-
};
24-
} else {
25-
return {
26-
done: true,
27-
value: undefined,
28-
};
29-
}
20+
get next() {
21+
let n = g();
22+
return function() {
23+
return n.next();
24+
};
3025
}
3126
return() {
32-
if (this._remaining <= 0) {
33-
throw new Test262Error();
34-
}
35-
return {};
27+
throw new Test262Error();
3628
}
3729
}
3830

test/built-ins/Iterator/prototype/map/exhaustion-does-not-call-return.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,21 @@ info: |
1010
features: [iterator-helpers]
1111
flags: []
1212
---*/
13+
function* g() {
14+
yield 0;
15+
yield 1;
16+
yield 2;
17+
}
18+
1319
class TestIterator extends Iterator {
14-
constructor() {
15-
super();
16-
this._remaining = 3;
17-
}
18-
next() {
19-
if (this._remaining > 0) {
20-
return {
21-
done: false,
22-
value: this._remaining--,
23-
};
24-
} else {
25-
return {
26-
done: true,
27-
value: undefined,
28-
};
29-
}
20+
get next() {
21+
let n = g();
22+
return function() {
23+
return n.next();
24+
};
3025
}
3126
return() {
32-
if (this._remaining <= 0) {
33-
throw new Test262Error();
34-
}
35-
return {};
27+
throw new Test262Error();
3628
}
3729
}
3830

test/built-ins/Iterator/prototype/take/exhaustion-calls-return.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,18 @@ info: |
1313
features: [iterator-helpers]
1414
flags: []
1515
---*/
16+
function* g() {
17+
yield 0;
18+
yield 1;
19+
yield 2;
20+
}
21+
1622
class TestIterator extends Iterator {
17-
constructor() {
18-
super();
19-
this._remaining = 3;
20-
}
21-
next() {
22-
if (this._remaining > 0) {
23-
return {
24-
done: false,
25-
value: this._remaining--,
26-
};
27-
} else {
28-
return {
29-
done: true,
30-
value: undefined,
31-
};
32-
}
23+
get next() {
24+
let n = g();
25+
return function() {
26+
return n.next();
27+
};
3328
}
3429
return() {
3530
throw new Test262Error();

test/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*---
44
esid: sec-iteratorprototype.toArray
55
description: >
6-
Iterator.prototype.toArray returns undefined when the iterator has already been exhausted
6+
Iterator.prototype.toArray returns an empty array when the iterator has already been exhausted
77
info: |
88
%Iterator.prototype%.toArray ( )
99

0 commit comments

Comments
 (0)