Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: test/mjsunit/es6/iterator-close.js

Issue 2119353002: [parser] Fix bug in for-of desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: gsave Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 function* g() { yield 42; return 88 }; 6 function* g() { yield 42; return 88 };
7 7
8 8
9 // Return method is "undefined". 9 // Return method is "undefined".
10 { 10 {
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 log = []; 959 log = [];
960 assertThrowsEquals(() => { 960 assertThrowsEquals(() => {
961 (([x]) => x)(g()) 961 (([x]) => x)(g())
962 }, 23); 962 }, 23);
963 assertEquals([[]], log); 963 assertEquals([[]], log);
964 } 964 }
965 965
966 966
967 // Next method throws. 967 // Next method throws.
968 { 968 {
969 let closed = false;
969 g.prototype.next = () => { throw 666; }; 970 g.prototype.next = () => { throw 666; };
970 g.prototype.return = () => { assertUnreachable() }; 971 g.prototype.return = () => { closed = true; };
971 972
972 973
973 assertThrowsEquals(() => { 974 assertThrowsEquals(() => {
974 for (var x of g()) {} 975 for (var x of g()) {}
975 }, 666); 976 }, 666);
976 977
977 assertThrowsEquals(() => { 978 assertThrowsEquals(() => {
978 for (let x of g()) {} 979 for (let x of g()) {}
979 }, 666); 980 }, 666);
980 981
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 const [...x] = g(); 1019 const [...x] = g();
1019 }, 666); 1020 }, 666);
1020 1021
1021 assertThrowsEquals(() => { 1022 assertThrowsEquals(() => {
1022 [...x] = g(); 1023 [...x] = g();
1023 }, 666); 1024 }, 666);
1024 1025
1025 assertThrowsEquals(() => { 1026 assertThrowsEquals(() => {
1026 (([...x]) => x)(g()); 1027 (([...x]) => x)(g());
1027 }, 666); 1028 }, 666);
1029
1030
1031 assertFalse(closed);
1028 } 1032 }
1029 1033
1030 1034
1031 // Value throws. 1035 // Value throws.
1032 { 1036 {
1037 let closed = false;
1033 g.prototype.next = () => ({get value() {throw 666}}); 1038 g.prototype.next = () => ({get value() {throw 666}});
1034 g.prototype.return = () => { assertUnreachable() }; 1039 g.prototype.return = () => { closed = true; };
1035 1040
1036 1041
1037 assertThrowsEquals(() => { 1042 assertThrowsEquals(() => {
1038 for (var x of g()) {} 1043 for (var x of g()) {}
1039 }, 666); 1044 }, 666);
1040 1045
1041 assertThrowsEquals(() => { 1046 assertThrowsEquals(() => {
1042 for (let x of g()) {} 1047 for (let x of g()) {}
1043 }, 666); 1048 }, 666);
1044 1049
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 const [...x] = g(); 1087 const [...x] = g();
1083 }, 666); 1088 }, 666);
1084 1089
1085 assertThrowsEquals(() => { 1090 assertThrowsEquals(() => {
1086 [...x] = g(); 1091 [...x] = g();
1087 }, 666); 1092 }, 666);
1088 1093
1089 assertThrowsEquals(() => { 1094 assertThrowsEquals(() => {
1090 (([...x]) => x)(g()); 1095 (([...x]) => x)(g());
1091 }, 666); 1096 }, 666);
1097
1098
1099 assertFalse(closed);
1092 } 1100 }
1093 1101
1094 1102
1095 // Done throws. 1103 // Done throws.
1096 { 1104 {
1105 let closed = false;
1097 g.prototype.next = () => ({get done() {throw 666}}); 1106 g.prototype.next = () => ({get done() {throw 666}});
1098 g.prototype.return = () => { assertUnreachable() }; 1107 g.prototype.return = () => { closed = true; };
1099 1108
1100 1109
1101 assertThrowsEquals(() => { 1110 assertThrowsEquals(() => {
1102 for (var x of g()) {} 1111 for (var x of g()) {}
1103 }, 666); 1112 }, 666);
1104 1113
1105 assertThrowsEquals(() => { 1114 assertThrowsEquals(() => {
1106 for (let x of g()) {} 1115 for (let x of g()) {}
1107 }, 666); 1116 }, 666);
1108 1117
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 const [...x] = g(); 1155 const [...x] = g();
1147 }, 666); 1156 }, 666);
1148 1157
1149 assertThrowsEquals(() => { 1158 assertThrowsEquals(() => {
1150 [...x] = g(); 1159 [...x] = g();
1151 }, 666); 1160 }, 666);
1152 1161
1153 assertThrowsEquals(() => { 1162 assertThrowsEquals(() => {
1154 (([...x]) => x)(g()); 1163 (([...x]) => x)(g());
1155 }, 666); 1164 }, 666);
1165
1166
1167 assertFalse(closed);
1156 } 1168 }
1157 1169
1158 1170
1159 // Nested loops. 1171 // Nested loops.
1160 { 1172 {
1161 function* g1() { yield 1; yield 2; throw 3; } 1173 function* g1() { yield 1; yield 2; throw 3; }
1162 function* g2() { yield -1; yield -2; throw -3; } 1174 function* g2() { yield -1; yield -2; throw -3; }
1163 1175
1164 assertDoesNotThrow(() => { 1176 assertDoesNotThrow(() => {
1165 for (let x of g1()) { 1177 for (let x of g1()) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 })()); 1373 })());
1362 1374
1363 assertEquals(42, (() => { 1375 assertEquals(42, (() => {
1364 for (let x of g()) return 42; 1376 for (let x of g()) return 42;
1365 })()); 1377 })());
1366 1378
1367 assertThrowsEquals(() => { 1379 assertThrowsEquals(() => {
1368 for (let x of g()) throw 42; 1380 for (let x of g()) throw 42;
1369 }, 42); 1381 }, 42);
1370 } 1382 }
OLDNEW
« src/parsing/parser.cc ('K') | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698