OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-do-expressions --harmony-sloppy-let --allow-natives-syntax | 5 // Flags: --harmony-do-expressions --harmony-sloppy-let --allow-natives-syntax |
6 // Flags: --harmony-default-parameters --harmony-destructuring | 6 // Flags: --harmony-default-parameters --harmony-destructuring |
| 7 // Flags: --harmony-completion |
7 | 8 |
8 function returnValue(v) { return v; } | 9 function returnValue(v) { return v; } |
9 function MyError() {} | 10 function MyError() {} |
10 var global = this; | 11 var global = this; |
11 | 12 |
12 function TestBasic() { | 13 function TestBasic() { |
13 // Looping and lexical declarations | 14 // Looping and lexical declarations |
14 assertEquals(512, returnValue(do { | 15 assertEquals(512, returnValue(do { |
15 let n = 2; | 16 let n = 2; |
16 for (let i = 0; i < 4; i++) n <<= 2; | 17 for (let i = 0; i < 4; i++) n <<= 2; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 var last_name = "Jetson"; | 161 var last_name = "Jetson"; |
161 function fn1(name = do { first_name + " " + last_name }) { | 162 function fn1(name = do { first_name + " " + last_name }) { |
162 return name; | 163 return name; |
163 } | 164 } |
164 assertEquals("George Jetson", fn1()); | 165 assertEquals("George Jetson", fn1()); |
165 | 166 |
166 var _items = [1, 2, 3, NaN, 4, 5]; | 167 var _items = [1, 2, 3, NaN, 4, 5]; |
167 function fn2(items = do { | 168 function fn2(items = do { |
168 let items = []; | 169 let items = []; |
169 for (var el of _items) { | 170 for (var el of _items) { |
170 if (el !== el) break; | 171 if (el !== el) { |
| 172 items; |
| 173 break; |
| 174 } |
171 items.push(el), items; | 175 items.push(el), items; |
172 } | 176 } |
173 }) { | 177 }) { |
174 return items; | 178 return items; |
175 } | 179 } |
176 assertEquals([1, 2, 3], fn2()); | 180 assertEquals([1, 2, 3], fn2()); |
177 | 181 |
178 function thrower() { throw new MyError(); } | 182 function thrower() { throw new MyError(); } |
179 function fn3(exception = do { try { thrower(); } catch (e) { e } }) { | 183 function fn3(exception = do { try { thrower(); } catch (e) { e } }) { |
180 return exception; | 184 return exception; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 let nums = []; | 268 let nums = []; |
265 for (let i = 0; i < 1000; ++i) { | 269 for (let i = 0; i < 1000; ++i) { |
266 let value = (Math.random() * 100) | 0; | 270 let value = (Math.random() * 100) | 0; |
267 nums.push(value === 0 ? 1 : value), nums; | 271 nums.push(value === 0 ? 1 : value), nums; |
268 } | 272 } |
269 }; | 273 }; |
270 assertEquals(numbers.length, 1000); | 274 assertEquals(numbers.length, 1000); |
271 } | 275 } |
272 | 276 |
273 for (var i = 0; i < 64; ++i) TestOSR(); | 277 for (var i = 0; i < 64; ++i) TestOSR(); |
OLD | NEW |