OLD | NEW |
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 // Flags: --harmony-iterator-close | 5 // Flags: --harmony-iterator-close |
6 | 6 |
7 | 7 |
8 function* g() { yield 42; return 88 }; | 8 function* g() { yield 42; return 88 }; |
9 | 9 |
10 | 10 |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 assertThrowsEquals(() => { | 1003 assertThrowsEquals(() => { |
1004 [x] = g(); | 1004 [x] = g(); |
1005 }, 666); | 1005 }, 666); |
1006 | 1006 |
1007 assertThrowsEquals(() => { | 1007 assertThrowsEquals(() => { |
1008 (([x]) => x)(g()); | 1008 (([x]) => x)(g()); |
1009 }, 666); | 1009 }, 666); |
1010 } | 1010 } |
1011 | 1011 |
1012 | 1012 |
| 1013 // Value throws. |
| 1014 { |
| 1015 g.prototype.next = () => ({get value() {throw 666}}); |
| 1016 g.prototype.return = () => { assertUnreachable() }; |
| 1017 |
| 1018 |
| 1019 assertThrowsEquals(() => { |
| 1020 for (var x of g()) {} |
| 1021 }, 666); |
| 1022 |
| 1023 assertThrowsEquals(() => { |
| 1024 for (let x of g()) {} |
| 1025 }, 666); |
| 1026 |
| 1027 assertThrowsEquals(() => { |
| 1028 for (const x of g()) {} |
| 1029 }, 666); |
| 1030 |
| 1031 assertThrowsEquals(() => { |
| 1032 for (x of g()) {} |
| 1033 }, 666); |
| 1034 |
| 1035 assertThrowsEquals(() => { |
| 1036 var [x] = g(); |
| 1037 }, 666); |
| 1038 |
| 1039 assertThrowsEquals(() => { |
| 1040 let [x] = g(); |
| 1041 }, 666); |
| 1042 |
| 1043 assertThrowsEquals(() => { |
| 1044 const [x] = g(); |
| 1045 }, 666); |
| 1046 |
| 1047 assertThrowsEquals(() => { |
| 1048 [x] = g(); |
| 1049 }, 666); |
| 1050 |
| 1051 assertThrowsEquals(() => { |
| 1052 (([x]) => x)(g()); |
| 1053 }, 666); |
| 1054 } |
| 1055 |
| 1056 |
| 1057 // Done throws. |
| 1058 { |
| 1059 g.prototype.next = () => ({get done() {throw 666}}); |
| 1060 g.prototype.return = () => { assertUnreachable() }; |
| 1061 |
| 1062 |
| 1063 assertThrowsEquals(() => { |
| 1064 for (var x of g()) {} |
| 1065 }, 666); |
| 1066 |
| 1067 assertThrowsEquals(() => { |
| 1068 for (let x of g()) {} |
| 1069 }, 666); |
| 1070 |
| 1071 assertThrowsEquals(() => { |
| 1072 for (const x of g()) {} |
| 1073 }, 666); |
| 1074 |
| 1075 assertThrowsEquals(() => { |
| 1076 for (x of g()) {} |
| 1077 }, 666); |
| 1078 |
| 1079 assertThrowsEquals(() => { |
| 1080 var [x] = g(); |
| 1081 }, 666); |
| 1082 |
| 1083 assertThrowsEquals(() => { |
| 1084 let [x] = g(); |
| 1085 }, 666); |
| 1086 |
| 1087 assertThrowsEquals(() => { |
| 1088 const [x] = g(); |
| 1089 }, 666); |
| 1090 |
| 1091 assertThrowsEquals(() => { |
| 1092 [x] = g(); |
| 1093 }, 666); |
| 1094 |
| 1095 assertThrowsEquals(() => { |
| 1096 (([x]) => x)(g()); |
| 1097 }, 666); |
| 1098 } |
| 1099 |
| 1100 |
1013 // Nested loops. | 1101 // Nested loops. |
1014 { | 1102 { |
1015 function* g1() { yield 1; yield 2; throw 3; } | 1103 function* g1() { yield 1; yield 2; throw 3; } |
1016 function* g2() { yield -1; yield -2; throw -3; } | 1104 function* g2() { yield -1; yield -2; throw -3; } |
1017 | 1105 |
1018 assertDoesNotThrow(() => { | 1106 assertDoesNotThrow(() => { |
1019 for (let x of g1()) { | 1107 for (let x of g1()) { |
1020 for (let y of g2()) { | 1108 for (let y of g2()) { |
1021 if (y == -2) break; | 1109 if (y == -2) break; |
1022 } | 1110 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 for (let x of g1()) { | 1231 for (let x of g1()) { |
1144 try { | 1232 try { |
1145 for (let y of g2()) { | 1233 for (let y of g2()) { |
1146 } | 1234 } |
1147 } catch (_) {} | 1235 } catch (_) {} |
1148 if (x == 2) break; | 1236 if (x == 2) break; |
1149 } | 1237 } |
1150 }, 5); | 1238 }, 5); |
1151 assertEquals([1], log); | 1239 assertEquals([1], log); |
1152 } | 1240 } |
OLD | NEW |